[ofw] [PATCH] dapl v2: scm, cma: thread doesn't always get teminated on library close.

Arlin Davis arlin.r.davis at intel.com
Thu Sep 17 11:32:25 PDT 2009


DAPL doesn't actually wait for the async processing thread to exit before
allowing the library to close.  It will wait up to 10 seconds, which under
heavy load isn't enough time.  Since the thread is created by an application
level thread, it will continue to run as long as the application runs.  But
if the application closes the library, then all library data and code is
invalid, which can result in the thread running something that's not
library code and accessing freed memory.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
 dapl/openib_cma/device.c |    8 +-------
 dapl/openib_scm/device.c |    8 +-------
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/dapl/openib_cma/device.c b/dapl/openib_cma/device.c
index 743e8fa..c1c1ee2 100644
--- a/dapl/openib_cma/device.c
+++ b/dapl/openib_cma/device.c
@@ -562,8 +562,6 @@ DAT_RETURN dapli_ib_thread_init(void)
 
 void dapli_ib_thread_destroy(void)
 {
-	int retries = 10;
-
 	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
 		     " ib_thread_destroy(%d)\n", dapl_os_getpid());
 	/* 
@@ -578,11 +576,7 @@ void dapli_ib_thread_destroy(void)
 		goto bail;
 
 	g_ib_thread_state = IB_THREAD_CANCEL;
-	if (dapls_thread_signal() == -1)
-		dapl_log(DAPL_DBG_TYPE_UTIL,
-			 " destroy: thread wakeup error = %s\n",
-			 strerror(errno));
-	while ((g_ib_thread_state != IB_THREAD_EXIT) && (retries--)) {
+	while ((g_ib_thread_state != IB_THREAD_EXIT)) {
 		dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
 			     " ib_thread_destroy: waiting for ib_thread\n");
 		if (dapls_thread_signal() == -1)
diff --git a/dapl/openib_scm/device.c b/dapl/openib_scm/device.c
index 9c91b78..bb72279 100644
--- a/dapl/openib_scm/device.c
+++ b/dapl/openib_scm/device.c
@@ -545,8 +545,6 @@ DAT_RETURN dapli_ib_thread_init(void)
 
 void dapli_ib_thread_destroy(void)
 {
-	int retries = 10;
-
 	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
 		     " ib_thread_destroy(%d)\n", dapl_os_getpid());
 	/* 
@@ -561,11 +559,7 @@ void dapli_ib_thread_destroy(void)
 		goto bail;
 
 	g_ib_thread_state = IB_THREAD_CANCEL;
-	if (dapls_thread_signal() == -1)
-		dapl_log(DAPL_DBG_TYPE_UTIL,
-			 " destroy: thread wakeup error = %s\n",
-			 strerror(errno));
-	while ((g_ib_thread_state != IB_THREAD_EXIT) && (retries--)) {
+	while (g_ib_thread_state != IB_THREAD_EXIT) {
 		dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
 			     " ib_thread_destroy: waiting for ib_thread\n");
 		if (dapls_thread_signal() == -1)
-- 
1.5.2.5





More information about the ofw mailing list