]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
librdmacm: Check 'init' under mutex
authorSean Hefty <sean.hefty@intel.com>
Tue, 26 Nov 2013 21:16:19 +0000 (13:16 -0800)
committerSean Hefty <sean.hefty@intel.com>
Tue, 26 Nov 2013 21:16:19 +0000 (13:16 -0800)
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 <sean.hefty@intel.com>
src/acm.c

index 45bcb8131846db24d382532d3d9d19f41b4df0c7..fa06d319cd500985241786fd8881677e737168fa 100644 (file)
--- 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);
 }