From fb40ba872213cc60b140ab4b5a9098ca86e95709 Mon Sep 17 00:00:00 2001 From: sleybo Date: Mon, 7 May 2007 08:55:50 +0000 Subject: [PATCH] [WSD] wait for all WQ to return before destroying the socket. (transition to err and then to reset ) git-svn-id: svn://openib.tc.cornell.edu/gen1@652 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/ulp/wsd/user/ibsp_iblow.c | 22 +++++++++++++++++++++- trunk/ulp/wsd/user/sockinfo.c | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/trunk/ulp/wsd/user/ibsp_iblow.c b/trunk/ulp/wsd/user/ibsp_iblow.c index 9e7d3807..ff980ef6 100644 --- a/trunk/ulp/wsd/user/ibsp_iblow.c +++ b/trunk/ulp/wsd/user/ibsp_iblow.c @@ -37,7 +37,7 @@ #endif #include "ibsp_iblow.tmh" #endif - +#include #include "ibspdll.h" #ifdef PERFMON_ENABLED @@ -968,7 +968,27 @@ ib_destroy_socket( if( socket_info->qp ) { + + + ib_qp_mod_t qp_mod; + cl_atomic_inc( &socket_info->ref_cnt1 ); + + cl_memclr( &qp_mod, sizeof(ib_qp_mod_t) ); + qp_mod.req_state = IB_QPS_ERROR; + status = ib_modify_qp(socket_info->qp, &qp_mod); + if( status != IB_SUCCESS ) + { + IBSP_ERROR( ("ib_modify_qp returned %s\n", + ib_get_err_str( status )) ); + deref_socket_info( socket_info ); + } + + + /* Wait for all work requests to get flushed. */ + while( socket_info->send_cnt || socket_info->send_cnt ) + cl_thread_suspend( 0 ); + status = ib_destroy_qp( socket_info->qp, deref_socket_info ); if( status != IB_SUCCESS ) { diff --git a/trunk/ulp/wsd/user/sockinfo.c b/trunk/ulp/wsd/user/sockinfo.c index e471851f..e837e429 100644 --- a/trunk/ulp/wsd/user/sockinfo.c +++ b/trunk/ulp/wsd/user/sockinfo.c @@ -144,7 +144,7 @@ free_socket_info( CL_ASSERT( !p_socket->qp ); CL_ASSERT( !p_socket->conn_item.p_map ); - + CL_ASSERT(!p_socket->send_cnt && !p_socket->recv_cnt); cl_spinlock_destroy( &p_socket->mutex1 ); cl_spinlock_destroy( &p_socket->send_lock ); -- 2.41.0