[WSD] wait for all WQ to return before destroying the socket.
authorsleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 7 May 2007 08:55:50 +0000 (08:55 +0000)
committersleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 7 May 2007 08:55:50 +0000 (08:55 +0000)
(transition to err and then to reset )

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@652 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/wsd/user/ibsp_iblow.c
ulp/wsd/user/sockinfo.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
index e471851..e837e42 100644 (file)
@@ -144,7 +144,7 @@ free_socket_info(
 \r
        CL_ASSERT( !p_socket->qp );\r
        CL_ASSERT( !p_socket->conn_item.p_map );\r
-\r
+       CL_ASSERT(!p_socket->send_cnt && !p_socket->recv_cnt);\r
        cl_spinlock_destroy( &p_socket->mutex1 );\r
 \r
        cl_spinlock_destroy( &p_socket->send_lock );\r