mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-28 11:27:32 +09:00
Revert "[network] SocketTransport2 cleanup"
This reverts commit b924810a3e.
This commit is contained in:
parent
1d6c0f2e87
commit
94cafe3a4a
2 changed files with 14 additions and 29 deletions
|
|
@ -931,6 +931,7 @@ nsresult
|
||||||
nsSocketTransport::InitWithConnectedSocket(PRFileDesc *fd, const NetAddr *addr)
|
nsSocketTransport::InitWithConnectedSocket(PRFileDesc *fd, const NetAddr *addr)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
||||||
|
NS_ASSERTION(!mFD.IsInitialized(), "already initialized");
|
||||||
|
|
||||||
char buf[kNetAddrMaxCStrBufSize];
|
char buf[kNetAddrMaxCStrBufSize];
|
||||||
NetAddrToString(addr, buf, sizeof(buf));
|
NetAddrToString(addr, buf, sizeof(buf));
|
||||||
|
|
@ -956,7 +957,6 @@ nsSocketTransport::InitWithConnectedSocket(PRFileDesc *fd, const NetAddr *addr)
|
||||||
{
|
{
|
||||||
MutexAutoLock lock(mLock);
|
MutexAutoLock lock(mLock);
|
||||||
|
|
||||||
NS_ASSERTION(!mFD.IsInitialized(), "already initialized");
|
|
||||||
mFD = fd;
|
mFD = fd;
|
||||||
mFDref = 1;
|
mFDref = 1;
|
||||||
mFDconnected = 1;
|
mFDconnected = 1;
|
||||||
|
|
@ -1031,7 +1031,6 @@ nsSocketTransport::ResolveHost()
|
||||||
this, SocketHost().get(), SocketPort(),
|
this, SocketHost().get(), SocketPort(),
|
||||||
mConnectionFlags & nsSocketTransport::BYPASS_CACHE ?
|
mConnectionFlags & nsSocketTransport::BYPASS_CACHE ?
|
||||||
" bypass cache" : ""));
|
" bypass cache" : ""));
|
||||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
|
|
@ -1238,7 +1237,6 @@ nsresult
|
||||||
nsSocketTransport::InitiateSocket()
|
nsSocketTransport::InitiateSocket()
|
||||||
{
|
{
|
||||||
SOCKET_LOG(("nsSocketTransport::InitiateSocket [this=%p]\n", this));
|
SOCKET_LOG(("nsSocketTransport::InitiateSocket [this=%p]\n", this));
|
||||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
bool isLocal;
|
bool isLocal;
|
||||||
|
|
@ -1322,14 +1320,11 @@ nsSocketTransport::InitiateSocket()
|
||||||
//
|
//
|
||||||
// if we already have a connected socket, then just attach and return.
|
// if we already have a connected socket, then just attach and return.
|
||||||
//
|
//
|
||||||
{
|
if (mFD.IsInitialized()) {
|
||||||
MutexAutoLock lock(mLock);
|
|
||||||
if (mFD.IsInitialized()) {
|
|
||||||
rv = mSocketTransportService->AttachSocket(mFD, this);
|
rv = mSocketTransportService->AttachSocket(mFD, this);
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
mAttached = true;
|
mAttached = true;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -1394,20 +1389,19 @@ nsSocketTransport::InitiateSocket()
|
||||||
opt.value.linger.linger = 0;
|
opt.value.linger.linger = 0;
|
||||||
PR_SetSocketOption(fd, &opt);
|
PR_SetSocketOption(fd, &opt);
|
||||||
#endif
|
#endif
|
||||||
// up to here, mFD will only be accessed by us
|
|
||||||
|
// 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
|
// assign mFD so that we can properly handle OnSocketDetached before we've
|
||||||
// established a connection.
|
// established a connection.
|
||||||
{
|
{
|
||||||
MutexAutoLock lock(mLock);
|
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;
|
mFD = fd;
|
||||||
mFDref = 1;
|
mFDref = 1;
|
||||||
mFDconnected = false;
|
mFDconnected = false;
|
||||||
|
|
@ -1552,12 +1546,8 @@ nsSocketTransport::RecoverFromError()
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
#ifdef DEBUG
|
// OK to check this outside mLock
|
||||||
{
|
NS_ASSERTION(!mFDconnected, "socket should not be connected");
|
||||||
MutexAutoLock lock(mLock);
|
|
||||||
NS_ASSERTION(!mFDconnected, "socket should not be connected");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// all connection failures need to be reported to DNS so that the next
|
// all connection failures need to be reported to DNS so that the next
|
||||||
// time we will use a different address if available.
|
// time we will use a different address if available.
|
||||||
|
|
@ -1809,7 +1799,6 @@ nsSocketTransport::ReleaseFD_Locked(PRFileDesc *fd)
|
||||||
void
|
void
|
||||||
nsSocketTransport::OnSocketEvent(uint32_t type, nsresult status, nsISupports *param)
|
nsSocketTransport::OnSocketEvent(uint32_t type, nsresult status, nsISupports *param)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
|
||||||
SOCKET_LOG(("nsSocketTransport::OnSocketEvent [this=%p type=%u status=%x param=%p]\n",
|
SOCKET_LOG(("nsSocketTransport::OnSocketEvent [this=%p type=%u status=%x param=%p]\n",
|
||||||
this, type, status, param));
|
this, type, status, param));
|
||||||
|
|
||||||
|
|
@ -1922,7 +1911,6 @@ nsSocketTransport::OnSocketEvent(uint32_t type, nsresult status, nsISupports *pa
|
||||||
void
|
void
|
||||||
nsSocketTransport::OnSocketReady(PRFileDesc *fd, int16_t outFlags)
|
nsSocketTransport::OnSocketReady(PRFileDesc *fd, int16_t outFlags)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
|
||||||
SOCKET_LOG(("nsSocketTransport::OnSocketReady [this=%p outFlags=%hd]\n",
|
SOCKET_LOG(("nsSocketTransport::OnSocketReady [this=%p outFlags=%hd]\n",
|
||||||
this, outFlags));
|
this, outFlags));
|
||||||
|
|
||||||
|
|
@ -2431,7 +2419,6 @@ nsSocketTransport::Bind(NetAddr *aLocalAddr)
|
||||||
NS_ENSURE_ARG(aLocalAddr);
|
NS_ENSURE_ARG(aLocalAddr);
|
||||||
|
|
||||||
MutexAutoLock lock(mLock);
|
MutexAutoLock lock(mLock);
|
||||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
|
||||||
if (mAttached) {
|
if (mAttached) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -350,13 +350,11 @@ private:
|
||||||
|
|
||||||
void OnMsgInputPending()
|
void OnMsgInputPending()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
|
||||||
if (mState == STATE_TRANSFERRING)
|
if (mState == STATE_TRANSFERRING)
|
||||||
mPollFlags |= (PR_POLL_READ | PR_POLL_EXCEPT);
|
mPollFlags |= (PR_POLL_READ | PR_POLL_EXCEPT);
|
||||||
}
|
}
|
||||||
void OnMsgOutputPending()
|
void OnMsgOutputPending()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
|
||||||
if (mState == STATE_TRANSFERRING)
|
if (mState == STATE_TRANSFERRING)
|
||||||
mPollFlags |= (PR_POLL_WRITE | PR_POLL_EXCEPT);
|
mPollFlags |= (PR_POLL_WRITE | PR_POLL_EXCEPT);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue