[ofw] [PATCH 8/9] dapl-2.0: scm, cma: fini code can be called multiple times and hang via fork

Davis, Arlin R arlin.r.davis at intel.com
Wed May 19 11:25:25 PDT 2010


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 at intel.com>
---
 dapl/openib_cma/device.c |    8 ++++++--
 dapl/openib_scm/device.c |    7 +++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/dapl/openib_cma/device.c b/dapl/openib_cma/device.c
index c9fc8c3..99b8c55 100644
--- a/dapl/openib_cma/device.c
+++ b/dapl/openib_cma/device.c
@@ -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);
diff --git a/dapl/openib_scm/device.c b/dapl/openib_scm/device.c
index 03d38a6..a5b0742 100644
--- a/dapl/openib_scm/device.c
+++ b/dapl/openib_scm/device.c
@@ -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;
-- 
1.5.2.5




More information about the ofw mailing list