[WSD] wait for all WQ to return before destroying the socket.
[mirror/winof/.git] / ulp / wsd / user / ibsp_iblow.c
index 9e7d380..ff980ef 100644 (file)
@@ -37,7 +37,7 @@
 #endif\r
 #include "ibsp_iblow.tmh"\r
 #endif\r
-\r
+#include <complib/cl_thread.h>\r
 #include "ibspdll.h"\r
 \r
 #ifdef PERFMON_ENABLED\r
@@ -968,7 +968,27 @@ ib_destroy_socket(
 \r
        if( socket_info->qp )\r
        {\r
+\r
+\r
+               ib_qp_mod_t             qp_mod;\r
+               \r
                cl_atomic_inc( &socket_info->ref_cnt1 );\r
+\r
+               cl_memclr( &qp_mod, sizeof(ib_qp_mod_t) );\r
+               qp_mod.req_state = IB_QPS_ERROR;\r
+               status = ib_modify_qp(socket_info->qp, &qp_mod);\r
+               if( status != IB_SUCCESS )\r
+               {\r
+                       IBSP_ERROR( ("ib_modify_qp returned %s\n",\r
+                               ib_get_err_str( status )) );\r
+                       deref_socket_info( socket_info );\r
+               }\r
+\r
+                       \r
+               /* Wait for all work requests to get flushed. */\r
+               while( socket_info->send_cnt || socket_info->send_cnt  )\r
+                       cl_thread_suspend( 0 );\r
+\r
                status = ib_destroy_qp( socket_info->qp, deref_socket_info );\r
                if( status != IB_SUCCESS )\r
                {\r