diff options
author | Moonchild <moonchild@palemoon.org> | 2022-03-22 13:16:52 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-04-03 01:14:36 +0200 |
commit | 6ac6a949e798f575218b0899a2152d6d7e0fad7c (patch) | |
tree | 40eed5fc37f88c16ddd04d70aff4cdc94dd07b4a /netwerk | |
parent | f1ff1d89393396b7e1451df3eb03274fb8236a9a (diff) | |
download | uxp-6ac6a949e798f575218b0899a2152d6d7e0fad7c.tar.gz |
Revert "[network] SocketTransport2 cleanup"
This reverts commit 86cbe641a521db21bb83f90eebb8f632c6504e40.
Diffstat (limited to 'netwerk')
-rw-r--r-- | netwerk/base/nsSocketTransport2.cpp | 33 | ||||
-rw-r--r-- | netwerk/base/nsSocketTransport2.h | 2 |
2 files changed, 13 insertions, 22 deletions
diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp index 04a258c6d0..3c6804760a 100644 --- a/netwerk/base/nsSocketTransport2.cpp +++ b/netwerk/base/nsSocketTransport2.cpp @@ -930,6 +930,7 @@ nsresult nsSocketTransport::InitWithConnectedSocket(PRFileDesc *fd, const NetAddr *addr) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread"); + NS_ASSERTION(!mFD.IsInitialized(), "already initialized"); char buf[kNetAddrMaxCStrBufSize]; NetAddrToString(addr, buf, sizeof(buf)); @@ -955,7 +956,6 @@ nsSocketTransport::InitWithConnectedSocket(PRFileDesc *fd, const NetAddr *addr) { MutexAutoLock lock(mLock); - NS_ASSERTION(!mFD.IsInitialized(), "already initialized"); mFD = fd; mFDref = 1; mFDconnected = 1; @@ -1319,14 +1319,11 @@ nsSocketTransport::InitiateSocket() // // if we already have a connected socket, then just attach and return. // - { - MutexAutoLock lock(mlock); - if (mFD.IsInitialized()) { + if (mFD.IsInitialized()) { rv = mSocketTransportService->AttachSocket(mFD, this); if (NS_SUCCEEDED(rv)) - mAttached = true; + mAttached = true; return rv; - } } // @@ -1392,18 +1389,18 @@ nsSocketTransport::InitiateSocket() PR_SetSocketOption(fd, &opt); #endif + // inform socket transport about this newly created socket... + rv = mSocketTransportService->AttachSocket(fd, this); + if (NS_FAILED(rv)) { + CloseSocket(fd); + return rv; + } + mAttached = true; + // assign mFD so that we can properly handle OnSocketDetached before we've // established a connection. { MutexAutoLock lock(mLock); - // inform socket transport about this newly created socket... - rv = mSocketTransportService->AttachSocket(fd, this); - if (NS_FAILED(rv)) { - CloseSocket(fd); - return rv; - } - mAttached = true; - mFD = fd; mFDref = 1; mFDconnected = false; @@ -1548,12 +1545,8 @@ nsSocketTransport::RecoverFromError() nsresult rv; -#ifdef DEBUG - { - MutexAutoLock lock(mLock); - NS_ASSERTION(!mFDconnected, "socket should not be connected"); - } -#endif + // OK to check this outside mLock + NS_ASSERTION(!mFDconnected, "socket should not be connected"); // all connection failures need to be reported to DNS so that the next // time we will use a different address if available. diff --git a/netwerk/base/nsSocketTransport2.h b/netwerk/base/nsSocketTransport2.h index 89b75efa57..cb107e6e79 100644 --- a/netwerk/base/nsSocketTransport2.h +++ b/netwerk/base/nsSocketTransport2.h @@ -350,13 +350,11 @@ private: void OnMsgInputPending() { - MOZ_ASSERT(OnSocketThread(), "not on socket thread"); if (mState == STATE_TRANSFERRING) mPollFlags |= (PR_POLL_READ | PR_POLL_EXCEPT); } void OnMsgOutputPending() { - MOZ_ASSERT(OnSocketThread(), "not on socket thread"); if (mState == STATE_TRANSFERRING) mPollFlags |= (PR_POLL_WRITE | PR_POLL_EXCEPT); } |