From: tzachid Date: Tue, 22 Nov 2005 09:14:59 +0000 (+0000) Subject: Remove the hack that was used to support multiple threads. (Rev 771) X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=486a45e59cc710c0f5da6dc370fb2c9668482480;p=~shefty%2Frdma-win.git Remove the hack that was used to support multiple threads. (Rev 771) git-svn-id: svn://openib.tc.cornell.edu/gen1@185 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/ulp/sdp/kernel/SdpDriver.cpp b/trunk/ulp/sdp/kernel/SdpDriver.cpp index c99d859d..07a3db9d 100644 --- a/trunk/ulp/sdp/kernel/SdpDriver.cpp +++ b/trunk/ulp/sdp/kernel/SdpDriver.cpp @@ -34,6 +34,22 @@ SdpDriver *g_pSdpDriver = NULL; +FAST_IO_DISPATCH FastIoDispatch = +{ + FIELD_OFFSET(FAST_IO_DISPATCH, FastIoDeviceControl), + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + SdpDriver::FastDispatch +}; + + VOID DriverUnload ( IN PDRIVER_OBJECT pDriverObject ) @@ -149,6 +165,78 @@ Cleanup: } +// TODO: Make sure that this function is used correctly, and that +// parameters are being checked well. +BOOLEAN SdpDriver::FastDispatch( + PFILE_OBJECT pFileObject, + BOOLEAN Wait, + PVOID pInputBuffer, + ULONG nInputBufferLength, + PVOID pOutputBuffer, + ULONG nOutputBufferLength, + ULONG IoControlCode, + PIO_STATUS_BLOCK IoStatus, + PDEVICE_OBJECT pDeviceObject + ) +{ + NTSTATUS rc; + ULONG nSize = 0; + ASSERT(FALSE); // Don't just use this function without modifications + + UNREFERENCED_PARAMETER(pDeviceObject); + + UNREFERENCED_PARAMETER(Wait); + + // IOCTLs are allowed only for user mode processes + if (UserMode != ExGetPreviousMode()) { + return (BOOLEAN)FALSE; + } + + __try { + if (pInputBuffer || nInputBufferLength) { + ProbeForRead(pInputBuffer, nInputBufferLength, sizeof(UCHAR)); + } + } __except(EXCEPTION_EXECUTE_HANDLER) { //??? what should I do + ASSERT(FALSE); + pInputBuffer = NULL; + nInputBufferLength = 0; + } + + __try { + if (pOutputBuffer || nOutputBufferLength) { + ProbeForWrite(pOutputBuffer, nOutputBufferLength, sizeof(UCHAR)); + } + } __except(EXCEPTION_EXECUTE_HANDLER) { + ASSERT(FALSE); + pOutputBuffer = NULL; + nOutputBufferLength = 0; + } + + IO_STACK_LOCATION isl; + isl.FileObject = pFileObject; + + // Dispatch the request + rc = g_pSdpDriver->DispatchDeviceIoControl( + NULL, + NULL, + &isl, + pInputBuffer, + nInputBufferLength, + pOutputBuffer, + nOutputBufferLength, + IoControlCode, + nSize + ); + + if (rc != STATUS_PENDING) { + IoStatus->Information = nSize; + IoStatus->Status = rc; + } + + return ((rc == STATUS_PENDING) ? (BOOLEAN)FALSE : (BOOLEAN)TRUE); +} + + NTSTATUS SdpDriver::Dispatch( IN PDEVICE_OBJECT pDeviceObject, @@ -349,18 +437,6 @@ SdpDriver::Init(PDEVICE_OBJECT pDevObj, PDRIVER_OBJECT DriverObject) goto Cleanup; } - m_SdpGlobalSockets = new SdpUserFile; - if (m_SdpGlobalSockets == NULL) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("new SdpUserFile failed \n")); - goto Cleanup; - } - - rc = m_SdpGlobalSockets->Init(); - if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("m_SdpGlobalSockets->Init failed rc = 0x%x\n", rc )); - goto Cleanup; - } - ExInitializeFastMutex(&m_ThreadsMutex); Cleanup: @@ -369,10 +445,6 @@ Cleanup: m_pSdpArp->Shutdown(); delete m_pSdpArp; } - if (m_SdpGlobalSockets) { - m_SdpGlobalSockets->Shutdown(); - delete m_SdpGlobalSockets; - } } return rc; } @@ -381,7 +453,6 @@ VOID SdpDriver::Shutdown() { m_pSdpArp->Shutdown(); - m_SdpGlobalSockets->Shutdown(); WaitForAllThreadsToDie(); } @@ -584,8 +655,7 @@ SdpDriver::DispatchDeviceIoControl( } if (pWspAcceptOut->pAccaptedSocket != NULL) { pAcceptedSdpSocket = (SdpSocket *) pWspAcceptOut->pAccaptedSocket; - //rc = pSdpUserFile->AddSocket(pAcceptedSdpSocket); - rc = g_pSdpDriver->m_SdpGlobalSockets->AddSocket(pAcceptedSdpSocket); + rc = pSdpUserFile->AddSocket(pAcceptedSdpSocket); if (!NT_SUCCESS(rc)) { SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpUserFile->AddSocket failed rc = 0x%x\n", rc )); pAcceptedSdpSocket->Shutdown(); diff --git a/trunk/ulp/sdp/kernel/SdpDriver.h b/trunk/ulp/sdp/kernel/SdpDriver.h index 6852a098..e1b23931 100644 --- a/trunk/ulp/sdp/kernel/SdpDriver.h +++ b/trunk/ulp/sdp/kernel/SdpDriver.h @@ -50,7 +50,6 @@ public: m_al_handle = NULL; m_pDevObj = NULL; m_pSdpArp = NULL; - m_SdpGlobalSockets = NULL; } NTSTATUS Init(PDEVICE_OBJECT pDevObj, PDRIVER_OBJECT DriverObject); @@ -65,7 +64,21 @@ public: NTSTATUS Dispatch( IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIrp - ); + ); + + static + BOOLEAN FastDispatch( + PFILE_OBJECT pFileObject, + BOOLEAN Wait, + PVOID pInputBuffer, + ULONG nInputBufferLength, + PVOID pOutputBuffer, + ULONG nOutputBufferLength, + ULONG IoControlCode, + PIO_STATUS_BLOCK IoStatus, + PDEVICE_OBJECT pDeviceObject + ); + NTSTATUS DispatchDeviceIoControl( IN PFILE_OBJECT pDeviceObject, @@ -89,7 +102,6 @@ public: ib_al_handle_t m_al_handle ; SdpArp *m_pSdpArp; - SdpUserFile *m_SdpGlobalSockets; private: diff --git a/trunk/ulp/sdp/kernel/SdpUserFile.cpp b/trunk/ulp/sdp/kernel/SdpUserFile.cpp index f46920f7..898b32fc 100644 --- a/trunk/ulp/sdp/kernel/SdpUserFile.cpp +++ b/trunk/ulp/sdp/kernel/SdpUserFile.cpp @@ -109,7 +109,7 @@ VOID SdpUserFile::RemoveSocket(SdpSocket *pSdpSocket) } -SdpSocket *SdpUserFile::SocketByPointer(VOID *Socket, bool LookInGlobal) +SdpSocket *SdpUserFile::SocketByPointer(VOID *Socket) { NTSTATUS rc = STATUS_SUCCESS; SdpSocket *pSdpSocket = NULL; @@ -140,25 +140,6 @@ SdpSocket *SdpUserFile::SocketByPointer(VOID *Socket, bool LookInGlobal) Lock.Unlock(); - if (pSdpSocket == NULL && LookInGlobal == true) { - // We are looking in the gloabl pool - pSdpSocket = g_pSdpDriver->m_SdpGlobalSockets->SocketByPointer(Socket, false); - if (pSdpSocket) { - // We will now move this socket to the correct place -#if 0 - RemoveSocket(pSdpSocket); // removes it no meter from - rc = AddSocket(pSdpSocket); - if(!NT_SUCCESS(rc)) { - // We free the socket and return NULL - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("AddSocket failed rc = 0x%x\n", rc )); - pSdpSocket->Release(); - pSdpSocket = NULL; - } -#endif - } - - - } return pSdpSocket; } diff --git a/trunk/ulp/sdp/kernel/SdpUserFile.h b/trunk/ulp/sdp/kernel/SdpUserFile.h index c014dfe2..c115de66 100644 --- a/trunk/ulp/sdp/kernel/SdpUserFile.h +++ b/trunk/ulp/sdp/kernel/SdpUserFile.h @@ -58,7 +58,7 @@ public: NTSTATUS Init(); VOID Shutdown(); - SdpSocket *SocketByPointer(VOID *Socket, bool LookInGlobal = true); + SdpSocket *SocketByPointer(VOID *Socket); NTSTATUS AddSocket(SdpSocket *pSdpSocket);