#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
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
SdpDriver::Shutdown()\r
{\r
m_pSdpArp->Shutdown();\r
+ m_SdpGlobalSockets->Shutdown();\r
WaitForAllThreadsToDie();\r
\r
}\r
}\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
// 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
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
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
return rc;\r
}\r
\r
- VOID SignalError(NTSTATUS rc) {ASSERT (FALSE);\r
+ VOID SignalError(NTSTATUS rc) {\r
m_flags |= ERROR_SIGNALLED;\r
} \r
\r
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
\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
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
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
\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
}\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
}\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
\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
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