[WSD] Fix race between CQ thread info cleanup and thread exit.
[mirror/winof/.git] / ulp / wsd / user / ibsp_iblow.c
index dc545d8..f793b5c 100644 (file)
@@ -639,6 +639,7 @@ ib_destroy_cq_tinfo(
        ib_wc_t *done_wclist;\r
        ib_api_status_t status;\r
        HANDLE h_cq_thread;\r
        ib_wc_t *done_wclist;\r
        ib_api_status_t status;\r
        HANDLE h_cq_thread;\r
+       DWORD cq_thread_id;\r
 \r
        IBSP_ENTER( IBSP_DBG_HW );\r
 \r
 \r
        IBSP_ENTER( IBSP_DBG_HW );\r
 \r
@@ -684,16 +685,17 @@ ib_destroy_cq_tinfo(
                   reference cq_tinfo after signaling  */\r
                h_cq_thread = cq_tinfo->ib_cq_thread;\r
                cq_tinfo->ib_cq_thread = NULL;\r
                   reference cq_tinfo after signaling  */\r
                h_cq_thread = cq_tinfo->ib_cq_thread;\r
                cq_tinfo->ib_cq_thread = NULL;\r
+               cq_thread_id = cq_tinfo->ib_cq_thread_id;\r
 \r
                cq_tinfo->ib_cq_thread_exit_wanted = TRUE;\r
                cl_waitobj_signal( cq_tinfo->cq_waitobj );\r
 \r
                /* Wait for ib_cq_thread to die, if we are not running on it */\r
 \r
                cq_tinfo->ib_cq_thread_exit_wanted = TRUE;\r
                cl_waitobj_signal( cq_tinfo->cq_waitobj );\r
 \r
                /* Wait for ib_cq_thread to die, if we are not running on it */\r
-               if( GetCurrentThreadId() != cq_tinfo->ib_cq_thread_id )\r
+               if( GetCurrentThreadId() != cq_thread_id )\r
                {\r
                        fzprint(("%s():%d:0x%x:0x%x: Waiting for ib_cq_thread=0x%x to die\n",\r
                                         __FUNCTION__, __LINE__, GetCurrentProcessId(), GetCurrentThreadId(),\r
                {\r
                        fzprint(("%s():%d:0x%x:0x%x: Waiting for ib_cq_thread=0x%x to die\n",\r
                                         __FUNCTION__, __LINE__, GetCurrentProcessId(), GetCurrentThreadId(),\r
-                                        cq_tinfo->ib_cq_thread_id ));\r
+                                        cq_thread_id ));\r
                        if( WaitForSingleObject( h_cq_thread, INFINITE ) != WAIT_OBJECT_0 )\r
                        {\r
                                IBSP_ERROR( ("WaitForSingleObject failed\n") );\r
                        if( WaitForSingleObject( h_cq_thread, INFINITE ) != WAIT_OBJECT_0 )\r
                        {\r
                                IBSP_ERROR( ("WaitForSingleObject failed\n") );\r