From: tzachid Date: Mon, 21 Nov 2005 12:25:08 +0000 (+0000) Subject: Improve the handling of CloseSocket on a listening socket. (Rev 356) X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=f61fc4c004d8e2540a09108b197ed7288c586b48;p=~shefty%2Frdma-win.git Improve the handling of CloseSocket on a listening socket. (Rev 356) git-svn-id: svn://openib.tc.cornell.edu/gen1@176 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/ulp/sdp/kernel/SdpArp.h b/trunk/ulp/sdp/kernel/SdpArp.h index 09b92a33..2b433b1b 100644 --- a/trunk/ulp/sdp/kernel/SdpArp.h +++ b/trunk/ulp/sdp/kernel/SdpArp.h @@ -57,6 +57,18 @@ public: + 154; return STATUS_SUCCESS; } + + if (DestIp == 11 * 256*256*256 + + 4 * 256*256 + + 8 * 256 + + + 152) { + *SrcIp = 11 * 256*256*256 + + 4 * 256*256 + + 8 * 256 + + + 151; + return STATUS_SUCCESS; + } + ASSERT(FALSE); *SrcIp = 0; @@ -123,6 +135,26 @@ public: *SrcCaGuid = CL_NTOH64(0x2c9000100d050); return STATUS_SUCCESS; } + + if (SourceAddr == 11 * 256*256*256 + + 4 * 256*256 + + 8 * 256 + + + 151) { + + *SrcPortGuid = CL_NTOH64(0x2c9010a66d25a);//????? swlab63 + *SrcCaGuid = CL_NTOH64(0x2c9010a66d259); + return STATUS_SUCCESS; + } + + if (SourceAddr == 11 * 256*256*256 + + 4 * 256*256 + + 8 * 256 + + + 152) { + + *SrcPortGuid = CL_NTOH64(0x2c9010b29b661);//????? swlab63 + *SrcCaGuid = CL_NTOH64(0x2c9010b29b660); + return STATUS_SUCCESS; + } ASSERT(FALSE); *SrcPortGuid = 0; @@ -173,6 +205,15 @@ public: return STATUS_SUCCESS; } + + if (DestAddr == 11 * 256*256*256 + + 4 * 256*256 + + 8 * 256 + + + 152) { + *DestPortGuid = CL_NTOH64(0x2c9010b29b661);//????? swlab57 + + return STATUS_SUCCESS; + } ASSERT(FALSE); diff --git a/trunk/ulp/sdp/kernel/SdpBufferPool.cpp b/trunk/ulp/sdp/kernel/SdpBufferPool.cpp index dbf8f3b5..750edbd3 100644 --- a/trunk/ulp/sdp/kernel/SdpBufferPool.cpp +++ b/trunk/ulp/sdp/kernel/SdpBufferPool.cpp @@ -80,6 +80,7 @@ BufferPool::BufferPool() m_PostCreditsWhenCan = false; m_CreditsCurrentlyPosted = false; m_CreditdBufferDescriptor = NULL; + m_pSdpSocket = NULL; } @@ -511,7 +512,9 @@ Cleanup: VOID BufferPool::AssertLocked() { #if DBG - m_pSdpSocket->AssertLocked(); + if (m_pSdpSocket) { + m_pSdpSocket->AssertLocked(); + } #endif } diff --git a/trunk/ulp/sdp/kernel/SdpRecvPool.cpp b/trunk/ulp/sdp/kernel/SdpRecvPool.cpp index bd3372cd..ba928e76 100644 --- a/trunk/ulp/sdp/kernel/SdpRecvPool.cpp +++ b/trunk/ulp/sdp/kernel/SdpRecvPool.cpp @@ -11,6 +11,7 @@ RecvPool::RecvPool() m_ClientWaiting = false; m_DisConnRecieved = false; m_LocaleAdvertisedBuffers = 0; + m_pSdpSocket = NULL; } NTSTATUS @@ -428,7 +429,9 @@ VOID RecvPool::AssertLocked() { #if DBG - m_pSdpSocket->AssertLocked(); + if (m_pSdpSocket) { + m_pSdpSocket->AssertLocked(); + } #endif } diff --git a/trunk/ulp/sdp/kernel/SdpSocket.cpp b/trunk/ulp/sdp/kernel/SdpSocket.cpp index 9d39e6ca..bd3b1e50 100644 --- a/trunk/ulp/sdp/kernel/SdpSocket.cpp +++ b/trunk/ulp/sdp/kernel/SdpSocket.cpp @@ -804,6 +804,7 @@ NTSTATUS SdpSocket::WSPListen( SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_cm_listen failed ib_status = 0x%d\n", ib_status )); rc = IB2Status(ib_status); pWspListenOut->Errno = IbalToWsaError( ib_status ); + m_Lock.Unlock(); // Error ignored as this is already an error pass goto Cleanup; } @@ -982,6 +983,8 @@ SdpSocket::WSPCloseSocket( NTSTATUS rc = STATUS_SUCCESS; SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p state = %s \n",this, SS2String(m_state))); OBJECT_ATTRIBUTES attr; + HANDLE ThreadHandle; + if (!m_Lock.Lock()) { SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Failed to lock this = 0x%p \n",this)); @@ -1017,54 +1020,54 @@ SdpSocket::WSPCloseSocket( m_Lock.Unlock(); // Error ignored as this is already an error pass goto Cleanup; } - - // We will now create a thread that will be resposible for the - // destruction of this socket - AddRef(); - - - /* Create a new thread, storing both the handle and thread id. */ - InitializeObjectAttributes( &attr, NULL, OBJ_KERNEL_HANDLE, NULL, NULL ); + } else { + // Already set the event, so that the created thread won't have to wait + // for anything + KeSetEvent( &m_DisconectSentEvent, IO_NO_INCREMENT, FALSE ); + } - HANDLE ThreadHandle; - rc = PsCreateSystemThread( - &ThreadHandle, - THREAD_ALL_ACCESS, - &attr, - NULL, - NULL, - ::CloseSocketThread, - this - ); + // We will now create a thread that will be resposible for the + // destruction of this socket + AddRef(); - if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("PsCreateSystemThread failed rc = 0x%x\n", rc )); - m_Lock.Unlock(); // Error ignored as this is already an error pass - // The thread wasn't created so we should remove the refferance - Release(); - goto Cleanup; - } + /* Create a new thread, storing both the handle and thread id. */ + InitializeObjectAttributes( &attr, NULL, OBJ_KERNEL_HANDLE, NULL, NULL ); + + rc = PsCreateSystemThread( + &ThreadHandle, + THREAD_ALL_ACCESS, + &attr, + NULL, + NULL, + ::CloseSocketThread, + this + ); - ASSERT(m_pCloseSocketThread != NULL); - // Convert the thread into a handle - rc = ObReferenceObjectByHandle( - ThreadHandle, - THREAD_ALL_ACCESS, - NULL, - KernelMode, - &m_pCloseSocketThread->ThreadObject, - NULL - ); - ASSERT(rc == STATUS_SUCCESS); // According to MSDN, if I set the params - // correctly I shouldn't get an error - - rc = ZwClose(ThreadHandle); - ASSERT(NT_SUCCESS(rc)); // Should always succeed + if (!NT_SUCCESS(rc)) { + SDP_PRINT(SDP_ERR, SDP_SOCKET, ("PsCreateSystemThread failed rc = 0x%x\n", rc )); + m_Lock.Unlock(); // Error ignored as this is already an error pass + // The thread wasn't created so we should remove the refferance + Release(); + goto Cleanup; + } - g_pSdpDriver->AddThread(m_pCloseSocketThread); - m_pCloseSocketThread = NULL; // Will be delated when the callback thread is deleted + ASSERT(m_pCloseSocketThread != NULL); + // Convert the thread into a handle + rc = ObReferenceObjectByHandle( + ThreadHandle, + THREAD_ALL_ACCESS, + NULL, + KernelMode, + &m_pCloseSocketThread->ThreadObject, + NULL + ); + ASSERT(rc == STATUS_SUCCESS); // According to MSDN, must succeed if I set the params + + rc = ZwClose(ThreadHandle); + ASSERT(NT_SUCCESS(rc)); // Should always succeed - } + g_pSdpDriver->AddThread(m_pCloseSocketThread); + m_pCloseSocketThread = NULL; // Will be delated when the callback thread is deleted rc = m_Lock.Unlock(); if (rc == STATUS_SHUTDOWN_IN_PROGRESS) { @@ -1657,11 +1660,14 @@ SdpSocket::CmDreqCallback(IN ib_cm_dreq_rec_t *p_cm_dreq_rec) NTSTATUS rc = STATUS_SUCCESS; ib_cm_drep_t cm_drep; ib_api_status_t ib_status; + bool Locked; // Take the lock and verify the state - rc = m_Lock.Lock(); - if (!NT_SUCCESS(rc)) { + Locked = m_Lock.Lock(); + // BUGBUG: It seems that even when the lock fails we should send + // drep + if (!Locked) { SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Lock failed rc = 0x%x\n", rc )); goto Cleanup; } @@ -1698,11 +1704,6 @@ SdpSocket::CmDreqCallback(IN ib_cm_dreq_rec_t *p_cm_dreq_rec) Cleanup: -/* - if (pSocket != NULL) { - pSocket->Release(); - } -*/ // Who should take care of the errors that were found here (if found)???????? return;