]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
A hack that allows threading to work and various bug fixes (Rev 450)
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 21 Nov 2005 12:28:10 +0000 (12:28 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 21 Nov 2005 12:28:10 +0000 (12:28 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@179 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/ulp/sdp/kernel/Precompile.h
trunk/ulp/sdp/kernel/SdpDriver.cpp
trunk/ulp/sdp/kernel/SdpDriver.h
trunk/ulp/sdp/kernel/SdpLock.h
trunk/ulp/sdp/kernel/SdpRecvPool.cpp
trunk/ulp/sdp/kernel/SdpSocket.cpp
trunk/ulp/sdp/kernel/SdpUserFile.cpp
trunk/ulp/sdp/kernel/SdpUserFile.h
trunk/ulp/sdp/todo

index 0fca28d936116ff5c93e3383050f2922927077b8..f1741e1f6cad74cbe41cbc1dca5e089a03d15e1d 100644 (file)
@@ -22,9 +22,9 @@ class SdpArp;
 #include "sdpLock.h"\r
 #include "RefCount.h"\r
 #include "SdpBufferPool.h"\r
+#include "SdpUserFile.h"\r
 #include "sdpdriver.h"\r
 #include "SdpShared.h"\r
-#include "SdpUserFile.h"\r
 #include "SdpRecvPool.h"\r
 #include "SdpConnectionList.h"\r
 #include "SdpSocket.h"\r
index f975c88f821698feb475357321c9b31aee8813c2..207c760f3585beb1348e4b96e0fdbdde9ab94446 100644 (file)
@@ -319,14 +319,31 @@ SdpDriver::Init(PDEVICE_OBJECT pDevObj, PDRIVER_OBJECT  DriverObject)
         SDP_PRINT(SDP_ERR, SDP_DRIVER, ("m_pSdpArp->Init failed rc = 0x%x\n", rc ));        \r
         goto Cleanup;\r
     }\r
+    \r
+    m_SdpGlobalSockets = new SdpUserFile; \r
+    if (m_SdpGlobalSockets == NULL) {\r
+        SDP_PRINT(SDP_ERR, SDP_DRIVER, ("new SdpUserFile failed \n"));        \r
+        goto Cleanup;\r
+    }\r
+\r
+    rc = m_SdpGlobalSockets->Init();\r
+    if (!NT_SUCCESS(rc)) {\r
+        SDP_PRINT(SDP_ERR, SDP_DRIVER, ("m_SdpGlobalSockets->Init failed rc = 0x%x\n", rc ));        \r
+        goto Cleanup;\r
+    }\r
 \r
     ExInitializeFastMutex(&m_ThreadsMutex);\r
     \r
 Cleanup:\r
     if (!NT_SUCCESS(rc)) {\r
         if (m_pSdpArp) {\r
+            m_pSdpArp->Shutdown();\r
             delete m_pSdpArp;\r
         }\r
+        if (m_SdpGlobalSockets) {\r
+            m_SdpGlobalSockets->Shutdown();\r
+            delete m_SdpGlobalSockets;\r
+        }\r
     }\r
     return rc;\r
 }\r
@@ -335,6 +352,7 @@ VOID
 SdpDriver::Shutdown()\r
 {\r
     m_pSdpArp->Shutdown();\r
+    m_SdpGlobalSockets->Shutdown();\r
     WaitForAllThreadsToDie();\r
 \r
 }\r
@@ -537,7 +555,8 @@ SdpDriver::DispatchDeviceIoControl(
             }\r
             if (pWspAcceptOut->pAccaptedSocket != NULL) {\r
                 pAcceptedSdpSocket = (SdpSocket *) pWspAcceptOut->pAccaptedSocket;\r
-                rc = pSdpUserFile->AddSocket(pAcceptedSdpSocket);\r
+                //rc = pSdpUserFile->AddSocket(pAcceptedSdpSocket);\r
+                rc = g_pSdpDriver->m_SdpGlobalSockets->AddSocket(pAcceptedSdpSocket);\r
                 if (!NT_SUCCESS(rc)) {\r
                     SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpUserFile->AddSocket failed rc = 0x%x\n", rc ));\r
                     pAcceptedSdpSocket->Shutdown();\r
@@ -569,6 +588,8 @@ SdpDriver::DispatchDeviceIoControl(
             // be accessable for the user. (currently succesfull or not)\r
             // BUGBUG: Change this behavior while the linger don't linger staff is fixed\r
             pSdpUserFile->RemoveSocket(pSdpSocket); // Must succed\r
+            // BUGBUG: are we taking the socket from the correct place\r
+            // It is possible that not, but the chanses of an error seems small\r
             if (!NT_SUCCESS(rc)) {\r
                 SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpSocket->WSPCloseSocket failed rc = 0x%x\n", rc ));        \r
                 goto Cleanup; \r
index 0dd2793b7d7475992aa1b33ac29e9fbea32a1b61..9f66c4120e47a31502156387d6e9aa7cc83343be 100644 (file)
@@ -20,6 +20,7 @@ public:
         m_al_handle = NULL;\r
         m_pDevObj = NULL;\r
         m_pSdpArp = NULL;\r
+        m_SdpGlobalSockets = NULL;\r
     }\r
     \r
        NTSTATUS Init(PDEVICE_OBJECT pDevObj, PDRIVER_OBJECT  DriverObject);\r
@@ -58,6 +59,8 @@ public:
     ib_al_handle_t m_al_handle ;\r
     SdpArp *m_pSdpArp;\r
 \r
+    SdpUserFile *m_SdpGlobalSockets;\r
+\r
 private:\r
 \r
     VOID WaitForThreadsToDie(LARGE_INTEGER  *pWWaitTime);\r
index b911893215e0e8255a2a6b5dd04b2eca5677f404..af447de84132f082f09cc88d55093b5f3c2735c0 100644 (file)
@@ -284,7 +284,7 @@ Cleanup:
         return rc;\r
     }\r
 \r
-    VOID SignalError(NTSTATUS rc) {ASSERT (FALSE);\r
+    VOID SignalError(NTSTATUS rc) {\r
         m_flags |= ERROR_SIGNALLED;\r
     } \r
 \r
index ba928e76941f2dfbbdb4fa1762cb62a8bc38c374..a49e75299480163e8563477d59b743c9ba9b8aaa 100644 (file)
@@ -64,8 +64,8 @@ RecvPool::Init(
 NTSTATUS\r
 RecvPool::RecievedBuffer(BufferDescriptor *pBufferDescriptor, bool error)\r
 {\r
-    SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p pBufferDescriptor = 0x%p error = %s\n"\r
-        ,m_pSdpSocket, pBufferDescriptor, error ? "true" : "false"));\r
+    SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p pBufferDescriptor = 0x%p sucess = %s\n"\r
+        ,m_pSdpSocket, pBufferDescriptor, error ? "false" : "true"));\r
     AssertLocked();\r
     NTSTATUS rc = STATUS_SUCCESS;\r
 \r
index 59a31b1340f3ba7969e51cbe2fe1b0b3edd25419..b68379782fdf805647279bf196662d69d519f3b7 100644 (file)
@@ -339,8 +339,8 @@ SdpSocket::WSPRecv(
 \r
         if ((m_state != SS_CONNECTED && m_state!= SS_CONNECTED_DREP_SENT ) ) {\r
             // We can not recv now.\r
-            SDP_PRINT(SDP_WARN, SDP_SOCKET, ("Can't recv now, m_state = %s\n",\r
-                SS2String(m_state)\r
+            SDP_PRINT(SDP_WARN, SDP_SOCKET, ("Can't recv now, m_state = %s this = %p\n",\r
+                SS2String(m_state), this\r
             ));\r
             rc = STATUS_SHUTDOWN_IN_PROGRESS;\r
             pWspRecvOut->Errno = WSAENOTCONN;\r
@@ -915,6 +915,7 @@ SdpSocket::WSPAccept(
 Cleanup:    \r
     ASSERT(Locked == false);\r
     if (NT_SUCCESS(rc) ) {\r
+        SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p returning socket 0x%p \n",this, pNewSocket));\r
         pWspAcceptOut->pAccaptedSocket = pNewSocket;\r
         pWspAcceptOut->IP = IP;\r
         pWspAcceptOut->Port = Port;\r
@@ -1561,11 +1562,12 @@ ErrorLocked:
 VOID \r
 SdpSocket::CmRtuCallback(IN   ib_cm_rtu_rec_t *p_cm_rtu_rec)\r
 {\r
-    SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p\n", this));\r
     NTSTATUS rc = STATUS_SUCCESS;\r
     ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);\r
 \r
     SdpSocket *pSocket = (SdpSocket *) p_cm_rtu_rec->qp_context;\r
+    SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p pSocket = 0x%p\n", this, pSocket));\r
+\r
     // In order to make our model more consistent we increase the refcount here.\r
     // (This is not a must since this is a callback and we are gurantied that the last\r
     // callback won't happen untill we free IBAL)\r
index d675f374a965540a46e8d0557f1300802a93f4c1..760d7084dfad72ad7789a560d3821bd6ffbf14a8 100644 (file)
@@ -2,6 +2,12 @@
 \r
 #include "Precompile.h"\r
 \r
+SdpUserFile::SdpUserFile()\r
+{\r
+    InitializeListHead(&m_SocketsList);\r
+    m_shutdown = false;\r
+}\r
+\r
 NTSTATUS SdpUserFile::Init()\r
 {\r
     KeInitializeSpinLock(&m_Lock);\r
@@ -73,8 +79,9 @@ VOID SdpUserFile::RemoveSocket(SdpSocket *pSdpSocket)
 }\r
 \r
 \r
-SdpSocket *SdpUserFile::SocketByPointer(VOID *Socket)\r
+SdpSocket *SdpUserFile::SocketByPointer(VOID *Socket, bool LookInGlobal)\r
 {\r
+    NTSTATUS rc = STATUS_SUCCESS;\r
     SdpSocket *pSdpSocket = NULL;\r
     PLIST_ENTRY pNext;\r
     CSpinLockWrapper Lock(m_Lock);\r
@@ -93,11 +100,34 @@ SdpSocket *SdpUserFile::SocketByPointer(VOID *Socket)
         }\r
         pNext = pNext->Flink;\r
     }\r
+    if (pSdpSocket != Socket) {\r
+        // We have found something, but this is not the correct object\r
+        pSdpSocket = NULL;\r
+    }\r
     if (pSdpSocket) {   \r
         pSdpSocket->AddRef();\r
     }\r
     \r
     Lock.Unlock();\r
+\r
+    if (pSdpSocket == NULL && LookInGlobal == true) {\r
+        // We are looking in the gloabl pool\r
+        pSdpSocket = g_pSdpDriver->m_SdpGlobalSockets->SocketByPointer(Socket, false);\r
+        if (pSdpSocket) {\r
+            // We will now move this socket to the correct place\r
+            RemoveSocket(pSdpSocket); // removes it no meter from\r
+            rc = AddSocket(pSdpSocket);\r
+            if(!NT_SUCCESS(rc)) {\r
+                // We free the socket and return NULL\r
+                SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("AddSocket failed rc = 0x%x\n", rc ));\r
+                pSdpSocket->Release();\r
+                pSdpSocket = NULL;\r
+            }\r
+            \r
+        }\r
+        \r
+\r
+    }\r
     return pSdpSocket;\r
 }\r
 \r
index 1e782d3c18b57e69a76e63a47e926781c23c066e..68c31ecb97998b91b37960adf373d9e7a5a5721c 100644 (file)
@@ -23,10 +23,12 @@ private:
     \r
 public:\r
 \r
+    SdpUserFile();\r
+\r
     NTSTATUS Init();\r
     VOID Shutdown();\r
 \r
-    SdpSocket *SocketByPointer(VOID *Socket);\r
+    SdpSocket *SocketByPointer(VOID *Socket, bool LookInGlobal = true);\r
     \r
     NTSTATUS AddSocket(SdpSocket *pSdpSocket);\r
 \r
index 1813675b6101e77e9fa3b6b900a5eb56c4cbbf73..b5bb951a65c71f9eca61eb811a00252c32a77a53 100644 (file)
@@ -26,6 +26,9 @@ general:
        Close the IPOIB device: Probably based on the example from src\general\toaster\toastmon\toastmon.c\r
        proabably (EventCategoryDeviceInterfaceChange)\r
        \r
+       Find a better solution for threading and remove the current solution.\r
+       Fix the race of sdp user file\r
+       \r
 \r
 USER MODE:\r
 \r