Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 170e545

Browse files
committed
Initialize rsocket in critical section
1 parent d5e9ae9 commit 170e545

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/common/pg_rsocket.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
#ifdef WITH_RSOCKET
2222

23+
#include <pthread.h>
24+
2325
/*
2426
* Copy of defines from dynloader.h
2527
*/
@@ -91,15 +93,22 @@ get_function(const char *name)
9193
return func;
9294
}
9395

96+
static pthread_mutex_t rsocket_init_mutex = PTHREAD_MUTEX_INITIALIZER;
97+
9498
/*
9599
* Loads librdmacm and loads pointers to rsocket functions
96100
*/
97101
void
98102
initialize_rsocket(void)
99103
{
104+
pthread_mutex_lock(rsocket_init_mutex);
105+
100106
/* librdmacm was loaded already */
101107
if (rdmacm_handle != NULL)
108+
{
109+
pthread_mutex_unlock(rsocket_init_mutex);
102110
return;
111+
}
103112

104113
rdmacm_handle = pg_dlopen(RDMACM_NAME);
105114
if (rdmacm_handle == NULL)
@@ -159,6 +168,8 @@ initialize_rsocket(void)
159168
#if !defined(WIN32)
160169
rcalls->fcntl = get_function("rfcntl");
161170
#endif
171+
172+
pthread_mutex_unlock(rsocket_init_mutex);
162173
}
163174

164175
#endif /* WITH_RSOCKET */

0 commit comments

Comments
 (0)