Remove the hack that was used to support multiple threads. (Rev 771)
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 22 Nov 2005 09:14:59 +0000 (09:14 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 22 Nov 2005 09:14:59 +0000 (09:14 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@185 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/sdp/kernel/SdpDriver.cpp
ulp/sdp/kernel/SdpDriver.h
ulp/sdp/kernel/SdpUserFile.cpp
ulp/sdp/kernel/SdpUserFile.h

index c99d859..07a3db9 100644 (file)
 \r
 SdpDriver *g_pSdpDriver = NULL;\r
 \r
+FAST_IO_DISPATCH FastIoDispatch =\r
+{\r
+    FIELD_OFFSET(FAST_IO_DISPATCH, FastIoDeviceControl),\r
+    NULL,\r
+    NULL,\r
+    NULL,\r
+    NULL,\r
+    NULL,\r
+    NULL,\r
+    NULL,\r
+    NULL,\r
+    NULL,\r
+    SdpDriver::FastDispatch\r
+};\r
+\r
+\r
 VOID DriverUnload (\r
         IN PDRIVER_OBJECT      pDriverObject   \r
         ) \r
@@ -149,6 +165,78 @@ Cleanup:
 \r
 }\r
 \r
+// TODO: Make sure that this function is used correctly, and that\r
+// parameters are being checked well.\r
+BOOLEAN SdpDriver::FastDispatch(\r
+    PFILE_OBJECT pFileObject,\r
+    BOOLEAN Wait,\r
+    PVOID pInputBuffer,\r
+    ULONG nInputBufferLength,\r
+    PVOID pOutputBuffer,\r
+    ULONG nOutputBufferLength,\r
+    ULONG IoControlCode,\r
+    PIO_STATUS_BLOCK IoStatus,\r
+    PDEVICE_OBJECT pDeviceObject\r
+    )\r
+{\r
+    NTSTATUS rc;\r
+    ULONG nSize = 0;\r
+    ASSERT(FALSE); // Don't just use this function without modifications\r
+\r
+    UNREFERENCED_PARAMETER(pDeviceObject);\r
+\r
+    UNREFERENCED_PARAMETER(Wait);\r
+\r
+    // IOCTLs are allowed only for user mode processes\r
+    if (UserMode != ExGetPreviousMode()) {\r
+        return (BOOLEAN)FALSE;\r
+    }\r
+\r
+    __try {\r
+        if (pInputBuffer || nInputBufferLength) {\r
+            ProbeForRead(pInputBuffer, nInputBufferLength, sizeof(UCHAR));\r
+        }\r
+    } __except(EXCEPTION_EXECUTE_HANDLER) { //??? what should I do\r
+        ASSERT(FALSE);\r
+        pInputBuffer = NULL;\r
+        nInputBufferLength = 0;\r
+    }\r
+\r
+    __try {\r
+        if (pOutputBuffer || nOutputBufferLength) {\r
+            ProbeForWrite(pOutputBuffer, nOutputBufferLength, sizeof(UCHAR));\r
+        }\r
+    } __except(EXCEPTION_EXECUTE_HANDLER) {\r
+        ASSERT(FALSE);\r
+        pOutputBuffer = NULL;\r
+        nOutputBufferLength = 0;\r
+    }\r
+\r
+    IO_STACK_LOCATION isl;\r
+    isl.FileObject = pFileObject;\r
+\r
+    // Dispatch the request\r
+    rc = g_pSdpDriver->DispatchDeviceIoControl(\r
+            NULL,\r
+            NULL,\r
+            &isl,\r
+            pInputBuffer,\r
+            nInputBufferLength,\r
+            pOutputBuffer,\r
+            nOutputBufferLength,\r
+            IoControlCode,\r
+            nSize\r
+            );\r
+\r
+    if (rc != STATUS_PENDING) {\r
+        IoStatus->Information = nSize;\r
+        IoStatus->Status = rc;\r
+    }\r
+\r
+    return ((rc == STATUS_PENDING) ? (BOOLEAN)FALSE : (BOOLEAN)TRUE);\r
+}\r
+\r
+\r
 \r
 NTSTATUS SdpDriver::Dispatch(\r
     IN PDEVICE_OBJECT pDeviceObject,\r
@@ -349,18 +437,6 @@ SdpDriver::Init(PDEVICE_OBJECT pDevObj, PDRIVER_OBJECT  DriverObject)
         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
@@ -369,10 +445,6 @@ Cleanup:
             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
@@ -381,7 +453,6 @@ VOID
 SdpDriver::Shutdown()\r
 {\r
     m_pSdpArp->Shutdown();\r
-    m_SdpGlobalSockets->Shutdown();\r
     WaitForAllThreadsToDie();\r
 \r
 }\r
@@ -584,8 +655,7 @@ SdpDriver::DispatchDeviceIoControl(
             }\r
             if (pWspAcceptOut->pAccaptedSocket != NULL) {\r
                 pAcceptedSdpSocket = (SdpSocket *) pWspAcceptOut->pAccaptedSocket;\r
-                //rc = pSdpUserFile->AddSocket(pAcceptedSdpSocket);\r
-                rc = g_pSdpDriver->m_SdpGlobalSockets->AddSocket(pAcceptedSdpSocket);\r
+                rc = pSdpUserFile->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
index 6852a09..e1b2393 100644 (file)
@@ -50,7 +50,6 @@ 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
@@ -65,7 +64,21 @@ public:
        NTSTATUS Dispatch(\r
                IN PDEVICE_OBJECT pDeviceObject,\r
                IN PIRP pIrp\r
-               );\r
+               );\r
+\r
+    static \r
+    BOOLEAN FastDispatch(\r
+        PFILE_OBJECT pFileObject,\r
+        BOOLEAN Wait,\r
+        PVOID pInputBuffer,\r
+        ULONG nInputBufferLength,\r
+        PVOID pOutputBuffer,\r
+        ULONG nOutputBufferLength,\r
+        ULONG IoControlCode,\r
+        PIO_STATUS_BLOCK IoStatus,\r
+        PDEVICE_OBJECT pDeviceObject\r
+        );\r
+\r
 \r
        NTSTATUS DispatchDeviceIoControl(\r
         IN PFILE_OBJECT pDeviceObject,\r
@@ -89,7 +102,6 @@ public:
     ib_al_handle_t m_al_handle ;\r
     SdpArp *m_pSdpArp;\r
 \r
-    SdpUserFile *m_SdpGlobalSockets;\r
 \r
 private:\r
 \r
index f46920f..898b32f 100644 (file)
@@ -109,7 +109,7 @@ VOID SdpUserFile::RemoveSocket(SdpSocket *pSdpSocket)
 }\r
 \r
 \r
-SdpSocket *SdpUserFile::SocketByPointer(VOID *Socket, bool LookInGlobal)\r
+SdpSocket *SdpUserFile::SocketByPointer(VOID *Socket)\r
 {\r
     NTSTATUS rc = STATUS_SUCCESS;\r
     SdpSocket *pSdpSocket = NULL;\r
@@ -140,25 +140,6 @@ SdpSocket *SdpUserFile::SocketByPointer(VOID *Socket, bool LookInGlobal)
     \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
-#if 0            \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
-#endif            \r
-        }\r
-        \r
-\r
-    }\r
     return pSdpSocket;\r
 }\r
 \r
index c014dfe..c115de6 100644 (file)
@@ -58,7 +58,7 @@ public:
     NTSTATUS Init();\r
     VOID Shutdown();\r
 \r
-    SdpSocket *SocketByPointer(VOID *Socket, bool LookInGlobal = true);\r
+    SdpSocket *SocketByPointer(VOID *Socket);\r
     \r
     NTSTATUS AddSocket(SdpSocket *pSdpSocket);\r
 \r