[WSD] Add locking around state checks.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 27 Sep 2005 00:25:10 +0000 (00:25 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 27 Sep 2005 00:25:10 +0000 (00:25 +0000)
Signed-off-by: Fab Tillier (ftillier@silverstorm.com)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@88 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/wsd/user/extensions.c
ulp/wsd/user/ibspdll.c

index ff8456b..83f95c6 100644 (file)
@@ -336,15 +336,22 @@ do_rdma_op(
 \r
        CL_ASSERT( wr_type == WR_RDMA_WRITE || wr_type == WR_RDMA_READ );\r
 \r
-       /* Check the state of the socket */\r
-       if( socket_info->socket_state != IBSP_CONNECTED )\r
+       cl_spinlock_acquire( &socket_info->mutex );\r
+       switch( socket_info->socket_state )\r
        {\r
+       case IBSP_CONNECTED:\r
+       case IBSP_DISCONNECTED:\r
+               break;\r
+\r
+       default:\r
+               cl_spinlock_release( &socket_info->mutex );\r
                IBSP_ERROR_EXIT(\r
                        ("Socket is not in connected socket_state state=%s\n",\r
                        IBSP_SOCKET_STATE_STR( socket_info->socket_state )) );\r
                *lpErrno = WSAENOTCONN;\r
                return SOCKET_ERROR;\r
        }\r
+       cl_spinlock_release( &socket_info->mutex );\r
 \r
        if( socket_info->qp_error )\r
        {\r
index cd28646..eb47fb4 100644 (file)
@@ -1571,15 +1571,22 @@ IBSPRecv(
                return SOCKET_ERROR;\r
        }\r
 \r
-       /* Check the state of the socket */\r
-       if( socket_info->socket_state != IBSP_CONNECTED )\r
+       cl_spinlock_acquire( &socket_info->mutex );\r
+       switch( socket_info->socket_state )\r
        {\r
+       case IBSP_CONNECTED:\r
+       case IBSP_DISCONNECTED:\r
+               break;\r
+\r
+       default:\r
+               cl_spinlock_release( &socket_info->mutex );\r
                IBSP_ERROR_EXIT(\r
                        ("Socket is not in connected socket_state state=%s\n",\r
                        IBSP_SOCKET_STATE_STR( socket_info->socket_state )) );\r
                *lpErrno = WSAENOTCONN;\r
                return SOCKET_ERROR;\r
        }\r
+       cl_spinlock_release( &socket_info->mutex );\r
 \r
        if( socket_info->qp_error != 0 )\r
        {\r
@@ -1782,7 +1789,6 @@ IBSPSend(
        CL_ASSERT( lpOverlapped != NULL );\r
 \r
        cl_spinlock_acquire( &socket_info->mutex );\r
-       /* Check the state of the socket */\r
        switch( socket_info->socket_state )\r
        {\r
        case IBSP_CONNECTED:\r
@@ -1790,7 +1796,10 @@ IBSPSend(
                break;\r
 \r
        default:\r
-               IBSP_ERROR_EXIT( ("Socket is not in connected socket_state \n") );\r
+               cl_spinlock_release( &socket_info->mutex );\r
+               IBSP_ERROR_EXIT(\r
+                       ("Socket is not in connected socket_state state=%s\n",\r
+                       IBSP_SOCKET_STATE_STR( socket_info->socket_state )) );\r
                *lpErrno = WSAENOTCONN;\r
                return SOCKET_ERROR;\r
        }\r