]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[WSD] Fix error flow in IBSPDuplicateSocket.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 14 Aug 2006 19:23:34 +0000 (19:23 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 14 Aug 2006 19:23:34 +0000 (19:23 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@454 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/ulp/wsd/user/ibsp_duplicate.c

index 1838054da263857c35f900c6819c1c2309075116..0c49c81becb4fcf3c860c1c14effd33518bb0ec2 100644 (file)
@@ -215,13 +215,6 @@ IBSPDuplicateSocket(
                return SOCKET_ERROR;\r
        }\r
 \r
-       IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_DUPLICATING_OLD );\r
-\r
-       /* We changed the state - remove from connection map. */\r
-       ibsp_conn_remove( socket_info );\r
-\r
-       cl_spinlock_release( &socket_info->mutex );\r
-\r
        /* Create a GUID to use as unique identifier for this duplication. */\r
        UuidCreate( &guid );\r
        create_name( fname, dwProcessId, &guid );\r
@@ -230,6 +223,7 @@ IBSPDuplicateSocket(
                PAGE_READWRITE, 0, sizeof(struct ibsp_duplicate_info), fname );\r
        if( !h_dup_info )\r
        {\r
+               cl_spinlock_release( &socket_info->mutex );\r
                IBSP_ERROR_EXIT(\r
                        ("CreateFileMapping for %s failed with %d\n",\r
                        fname, GetLastError()) );\r
@@ -241,6 +235,7 @@ IBSPDuplicateSocket(
        dup_info = MapViewOfFile( h_dup_info, FILE_MAP_WRITE, 0, 0, 0 );\r
        if( !dup_info )\r
        {\r
+               cl_spinlock_release( &socket_info->mutex );\r
                IBSP_ERROR_EXIT(\r
                        ("MapViewOfFile failed with %d\n", GetLastError()) );\r
                CloseHandle( h_dup_info );\r
@@ -265,6 +260,7 @@ IBSPDuplicateSocket(
        h_target_process = OpenProcess( PROCESS_DUP_HANDLE, FALSE, dwProcessId );\r
        if( !h_target_process )\r
        {\r
+               cl_spinlock_release( &socket_info->mutex );\r
                IBSP_ERROR_EXIT(\r
                        ("OpenProcess failed with %d\n", GetLastError()) );\r
                CloseHandle( h_dup_info );\r
@@ -276,20 +272,25 @@ IBSPDuplicateSocket(
                h_target_process, &h_target_dup_info, 0, TRUE,\r
                DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS ) )\r
        {\r
+               cl_spinlock_release( &socket_info->mutex );\r
                IBSP_ERROR_EXIT(\r
                        ("DuplicateHandle failed with %d\n", GetLastError()) );\r
                CloseHandle( h_target_process );\r
+               CloseHandle( h_dup_info );\r
                *lpErrno = WSAENETDOWN;\r
                return SOCKET_ERROR;\r
        }\r
 \r
        CloseHandle( h_target_process );\r
+       CloseHandle( h_dup_info );\r
 \r
        CL_ASSERT( !((ULONG_PTR)h_target_dup_info >> 32) );\r
        lpProtocolInfo->dwProviderReserved = (DWORD)(ULONG_PTR)h_target_dup_info;\r
 \r
        socket_info->duplicate.identifier = guid;\r
 \r
+       IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_DUPLICATING_OLD );\r
+\r
        memset( &reason, 0, sizeof(reason) );\r
        reason.type = DISC_DUPLICATING;\r
        reason.duplicating.identifier = guid;\r
@@ -301,6 +302,11 @@ IBSPDuplicateSocket(
         */\r
        ib_disconnect( socket_info, &reason );\r
 \r
+       /* We changed the state - remove from connection map. */\r
+       ibsp_conn_remove( socket_info );\r
+\r
+       cl_spinlock_release( &socket_info->mutex );\r
+\r
        wait_cq_drain( socket_info );\r
 \r
        cl_spinlock_acquire( &socket_info->mutex );\r