Improve the handling of CloseSocket on a listening socket. (Rev 356)
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 21 Nov 2005 12:25:08 +0000 (12:25 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 21 Nov 2005 12:25:08 +0000 (12:25 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@176 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/sdp/kernel/SdpArp.h
ulp/sdp/kernel/SdpBufferPool.cpp
ulp/sdp/kernel/SdpRecvPool.cpp
ulp/sdp/kernel/SdpSocket.cpp

index 09b92a3..2b433b1 100644 (file)
@@ -57,6 +57,18 @@ public:
                       + 154;\r
             return STATUS_SUCCESS;\r
         }\r
+\r
+        if (DestIp == 11 * 256*256*256 + \r
+                      4 * 256*256 +\r
+                      8 * 256 +\r
+                      + 152) {\r
+            *SrcIp = 11 * 256*256*256 + \r
+                      4 * 256*256 +\r
+                      8 * 256 +\r
+                      + 151;\r
+            return STATUS_SUCCESS;\r
+        }\r
+\r
         \r
         ASSERT(FALSE);\r
         *SrcIp = 0;\r
@@ -123,6 +135,26 @@ public:
             *SrcCaGuid = CL_NTOH64(0x2c9000100d050);\r
             return STATUS_SUCCESS;\r
         }\r
+\r
+        if (SourceAddr == 11 * 256*256*256 + \r
+                      4 * 256*256 +\r
+                      8 * 256 +\r
+                      + 151) {\r
+\r
+            *SrcPortGuid = CL_NTOH64(0x2c9010a66d25a);//????? swlab63\r
+            *SrcCaGuid = CL_NTOH64(0x2c9010a66d259);\r
+            return STATUS_SUCCESS;\r
+        }\r
+        \r
+        if (SourceAddr == 11 * 256*256*256 + \r
+                      4 * 256*256 +\r
+                      8 * 256 +\r
+                      + 152) {\r
+\r
+            *SrcPortGuid = CL_NTOH64(0x2c9010b29b661);//????? swlab63\r
+            *SrcCaGuid = CL_NTOH64(0x2c9010b29b660);\r
+            return STATUS_SUCCESS;\r
+        }\r
         \r
         ASSERT(FALSE);\r
         *SrcPortGuid = 0;\r
@@ -173,6 +205,15 @@ public:
             \r
             return STATUS_SUCCESS;\r
         }\r
+\r
+        if (DestAddr == 11 * 256*256*256 + \r
+                      4 * 256*256 +\r
+                      8 * 256 +\r
+                      + 152) {\r
+            *DestPortGuid =   CL_NTOH64(0x2c9010b29b661);//????? swlab57\r
+            \r
+            return STATUS_SUCCESS;\r
+        }\r
         \r
         \r
         ASSERT(FALSE);\r
index dbf8f3b..750edbd 100644 (file)
@@ -80,6 +80,7 @@ BufferPool::BufferPool()
     m_PostCreditsWhenCan = false;\r
     m_CreditsCurrentlyPosted = false;\r
     m_CreditdBufferDescriptor = NULL;\r
+    m_pSdpSocket = NULL;\r
 \r
 }\r
 \r
@@ -511,7 +512,9 @@ Cleanup:
 VOID \r
 BufferPool::AssertLocked() {\r
 #if DBG\r
-    m_pSdpSocket->AssertLocked();\r
+    if (m_pSdpSocket) {\r
+        m_pSdpSocket->AssertLocked();\r
+    }\r
 #endif\r
 }\r
 \r
index bd3372c..ba928e7 100644 (file)
@@ -11,6 +11,7 @@ RecvPool::RecvPool()
     m_ClientWaiting = false;\r
     m_DisConnRecieved = false;\r
     m_LocaleAdvertisedBuffers = 0;\r
+    m_pSdpSocket = NULL;\r
 }\r
 \r
 NTSTATUS \r
@@ -428,7 +429,9 @@ VOID
 RecvPool::AssertLocked()\r
 {\r
 #if DBG\r
-    m_pSdpSocket->AssertLocked();\r
+    if (m_pSdpSocket) {\r
+        m_pSdpSocket->AssertLocked();\r
+    }\r
 #endif\r
 }\r
 \r
index 9d39e6c..bd3b1e5 100644 (file)
@@ -804,6 +804,7 @@ NTSTATUS SdpSocket::WSPListen(
         SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_cm_listen failed ib_status = 0x%d\n", ib_status ));\r
         rc = IB2Status(ib_status);\r
         pWspListenOut->Errno = IbalToWsaError( ib_status );\r
+        m_Lock.Unlock(); // Error ignored as this is already an error pass\r
         goto Cleanup;\r
     }\r
         \r
@@ -982,6 +983,8 @@ SdpSocket::WSPCloseSocket(
     NTSTATUS rc = STATUS_SUCCESS;\r
     SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p state = %s \n",this, SS2String(m_state)));\r
     OBJECT_ATTRIBUTES   attr;\r
+    HANDLE  ThreadHandle;\r
+\r
 \r
     if (!m_Lock.Lock()) {\r
         SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Failed to lock this = 0x%p \n",this));\r
@@ -1017,54 +1020,54 @@ SdpSocket::WSPCloseSocket(
             m_Lock.Unlock(); // Error ignored as this is already an error pass\r
             goto Cleanup;\r
         }\r
-\r
-        // We will now create a thread that will be resposible for the\r
-        // destruction of this socket\r
-        AddRef();\r
-\r
-\r
-        /* Create a new thread, storing both the handle and thread id. */\r
-        InitializeObjectAttributes( &attr, NULL, OBJ_KERNEL_HANDLE, NULL, NULL );\r
+    } else {\r
+        // Already set the event, so that the created thread won't have to wait\r
+        // for anything\r
+        KeSetEvent( &m_DisconectSentEvent, IO_NO_INCREMENT, FALSE );\r
+    }\r
         \r
-        HANDLE  ThreadHandle;\r
-        rc = PsCreateSystemThread(\r
-            &ThreadHandle, \r
-            THREAD_ALL_ACCESS,\r
-            &attr,\r
-            NULL,\r
-            NULL,\r
-            ::CloseSocketThread,\r
-            this\r
-            );\r
+    // We will now create a thread that will be resposible for the\r
+    // destruction of this socket\r
+    AddRef();\r
 \r
-        if (!NT_SUCCESS(rc)) {\r
-            SDP_PRINT(SDP_ERR, SDP_SOCKET, ("PsCreateSystemThread failed rc = 0x%x\n", rc ));\r
-            m_Lock.Unlock(); // Error ignored as this is already an error pass\r
-            // The thread wasn't created so we should remove the refferance\r
-            Release();  \r
-            goto Cleanup;\r
-        }\r
+    /* Create a new thread, storing both the handle and thread id. */\r
+    InitializeObjectAttributes( &attr, NULL, OBJ_KERNEL_HANDLE, NULL, NULL );\r
+    \r
+    rc = PsCreateSystemThread(\r
+        &ThreadHandle, \r
+        THREAD_ALL_ACCESS,\r
+        &attr,\r
+        NULL,\r
+        NULL,\r
+        ::CloseSocketThread,\r
+        this\r
+        );\r
 \r
-        ASSERT(m_pCloseSocketThread != NULL);\r
-        // Convert the thread into a handle\r
-        rc = ObReferenceObjectByHandle(\r
-              ThreadHandle,\r
-              THREAD_ALL_ACCESS,\r
-              NULL,\r
-              KernelMode,\r
-              &m_pCloseSocketThread->ThreadObject,\r
-              NULL\r
-              );\r
-        ASSERT(rc == STATUS_SUCCESS); // According to MSDN, if I set the params\r
-                                     // correctly I shouldn't get an error\r
-        \r
-        rc = ZwClose(ThreadHandle);\r
-        ASSERT(NT_SUCCESS(rc)); // Should always succeed\r
+    if (!NT_SUCCESS(rc)) {\r
+        SDP_PRINT(SDP_ERR, SDP_SOCKET, ("PsCreateSystemThread failed rc = 0x%x\n", rc ));\r
+        m_Lock.Unlock(); // Error ignored as this is already an error pass\r
+        // The thread wasn't created so we should remove the refferance\r
+        Release();  \r
+        goto Cleanup;\r
+    }\r
 \r
-        g_pSdpDriver->AddThread(m_pCloseSocketThread);\r
-        m_pCloseSocketThread = NULL; // Will be delated when the callback thread is deleted\r
+    ASSERT(m_pCloseSocketThread != NULL);\r
+    // Convert the thread into a handle\r
+    rc = ObReferenceObjectByHandle(\r
+          ThreadHandle,\r
+          THREAD_ALL_ACCESS,\r
+          NULL,\r
+          KernelMode,\r
+          &m_pCloseSocketThread->ThreadObject,\r
+          NULL\r
+          );\r
+    ASSERT(rc == STATUS_SUCCESS); // According to MSDN, must succeed if I set the params\r
+    \r
+    rc = ZwClose(ThreadHandle);\r
+    ASSERT(NT_SUCCESS(rc)); // Should always succeed\r
 \r
-    }\r
+    g_pSdpDriver->AddThread(m_pCloseSocketThread);\r
+    m_pCloseSocketThread = NULL; // Will be delated when the callback thread is deleted\r
 \r
     rc = m_Lock.Unlock();\r
     if (rc == STATUS_SHUTDOWN_IN_PROGRESS) {\r
@@ -1657,11 +1660,14 @@ SdpSocket::CmDreqCallback(IN   ib_cm_dreq_rec_t *p_cm_dreq_rec)
     NTSTATUS rc = STATUS_SUCCESS;\r
     ib_cm_drep_t cm_drep;\r
     ib_api_status_t ib_status;\r
+    bool Locked;\r
 \r
 \r
     // Take the lock and verify the state\r
-    rc = m_Lock.Lock();\r
-    if (!NT_SUCCESS(rc)) {\r
+    Locked = m_Lock.Lock();\r
+    // BUGBUG: It seems that even when the lock fails we should send\r
+    // drep\r
+    if (!Locked) {\r
         SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Lock failed rc = 0x%x\n", rc ));\r
         goto Cleanup;\r
     }\r
@@ -1698,11 +1704,6 @@ SdpSocket::CmDreqCallback(IN   ib_cm_dreq_rec_t *p_cm_dreq_rec)
 \r
 Cleanup:\r
 \r
-/*\r
-    if (pSocket != NULL) {\r
-        pSocket->Release();\r
-    }\r
-*/  \r
     // Who should take care of the errors that were found here (if found)????????\r
     return;\r
 \r