]> git.openfabrics.org - ~ardavis/dapl.git/commitdiff
scm, cma: fini code can be called multiple times and hang via fork
authorArlin Davis <arlin.r.davis@intel.com>
Mon, 17 May 2010 23:15:21 +0000 (16:15 -0700)
committerArlin Davis <arlin.r.davis@intel.com>
Mon, 17 May 2010 23:15:21 +0000 (16:15 -0700)
The providers should protect against forked child exits and
not cleanup until the parent init actually exits. Otherwise,
the child will hang trying to cleanup dapl thread. Modify to
check process id for proper init to fini cleanup and limit
cleanup to parent only.

Signed-off-by: Arlin Davis <arlin.r.davis@intel.com>
dapl/openib_cma/device.c
dapl/openib_scm/device.c

index c9fc8c3b4b55c12cd5801f6ea84b8ce65d105298..99b8c5536b962cce0bf522fc71e054e0d713be2b 100644 (file)
@@ -197,9 +197,10 @@ static int getipaddr(char *name, char *addr, int len)
  *     0 success, -1 error
  *
  */
+DAT_UINT32 g_parent = 0;
 int32_t dapls_ib_init(void)
 {
-       dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " dapl_ib_init: \n");
+       g_parent = dapl_os_getpid();
 
        /* initialize hca_list lock */
        dapl_os_lock_init(&g_hca_lock);
@@ -215,7 +216,10 @@ int32_t dapls_ib_init(void)
 
 int32_t dapls_ib_release(void)
 {
-       dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " dapl_ib_release: \n");
+       /* only parent will cleanup */
+       if (dapl_os_getpid() != g_parent)
+               return 0;
+
        dapli_ib_thread_destroy();
        if (g_cm_events != NULL)
                rdma_destroy_event_channel(g_cm_events);
index 03d38a6b0683ff005aaede5bd21398d3248316f9..a5b0742f46b06476a5cf764274dd5557d57f3a3d 100644 (file)
@@ -216,8 +216,11 @@ static void destroy_cr_pipe(IN DAPL_HCA * hca_ptr)
  *     0 success, -1 error
  *
  */
+DAT_UINT32 g_parent = 0;
 int32_t dapls_ib_init(void)
 {
+        g_parent = dapl_os_getpid();
+
        /* initialize hca_list */
        dapl_os_lock_init(&g_hca_lock);
        dapl_llist_init_head(&g_hca_list);
@@ -230,6 +233,10 @@ int32_t dapls_ib_init(void)
 
 int32_t dapls_ib_release(void)
 {
+        /* only parent init will cleanup */
+        if (dapl_os_getpid() != g_parent)
+                return 0;
+       
        dapli_ib_thread_destroy();
        dapls_os_release();
        return 0;