From: Sean Hefty Date: Tue, 26 Nov 2013 21:16:19 +0000 (-0800) Subject: librdmacm: Check 'init' under mutex X-Git-Tag: v1.0.18~4 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=ea5851998c11b8211170179a6d924d4935fec0a1;p=~shefty%2Flibrdmacm.git librdmacm: Check 'init' under mutex ucma_ib_init() does a quick check that access to ibacm has been initialized. This check is done outside of the acm_lock mutex. We need to check init again inside of holding the mutex to ensure that we don't run the initialization code twice. Signed-off-by: Sean Hefty --- diff --git a/src/acm.c b/src/acm.c index 45bcb813..fa06d319 100644 --- a/src/acm.c +++ b/src/acm.c @@ -137,6 +137,9 @@ void ucma_ib_init(void) return; pthread_mutex_lock(&acm_lock); + if (init) + goto unlock; + if (!ucma_set_server_port()) goto out; @@ -155,6 +158,7 @@ void ucma_ib_init(void) } out: init = 1; +unlock: pthread_mutex_unlock(&acm_lock); }