Bug 1692120 - Avoid accessing nsSocketTransport::mCondition on main thread r=necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D105596
This commit is contained in:
Kershaw Chang 2021-02-18 10:52:59 +00:00
parent 75b24e8485
commit 67fbb1e79d
6 changed files with 31 additions and 8 deletions

View File

@ -189,6 +189,10 @@ class FakeSocketTransportProvider : public nsISocketTransport {
MOZ_ASSERT(false);
return NS_OK;
}
NS_IMETHOD GetStatus(nsresult* aStatus) override {
MOZ_ASSERT(false);
return NS_OK;
}
// nsITransport
NS_IMETHOD OpenInputStream(uint32_t aFlags, uint32_t aSegmentSize,

View File

@ -215,5 +215,8 @@ MockedSocketTransport::GetRetryDnsIfPossible(bool*) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockedSocketTransport::GetStatus(nsresult*) { return NS_ERROR_NOT_IMPLEMENTED; }
} // namespace dom
} // namespace mozilla

View File

@ -348,4 +348,9 @@ interface nsISocketTransport : nsITransport
* e.g. NS_ERROR_CONNECTION_REFUSED, NS_ERROR_RESET, etc.
*/
readonly attribute boolean retryDnsIfPossible;
/**
* Return the current status of the socket.
*/
[noscript] readonly attribute nsresult status;
};

View File

@ -2564,10 +2564,6 @@ nsSocketTransport::GetPeerAddr(NetAddr* addr) {
// we can freely access mNetAddr from any thread without being
// inside a critical section.
if (NS_FAILED(mCondition)) {
return mCondition;
}
if (!mNetAddrIsSet) {
SOCKET_LOG(
("nsSocketTransport::GetPeerAddr [this=%p state=%d] "
@ -2587,10 +2583,6 @@ nsSocketTransport::GetSelfAddr(NetAddr* addr) {
// we can freely access mSelfAddr from any thread without being
// inside a critical section.
if (NS_FAILED(mCondition)) {
return mCondition;
}
if (!mSelfAddrIsSet) {
SOCKET_LOG(
("nsSocketTransport::GetSelfAddr [this=%p state=%d] "
@ -3374,5 +3366,13 @@ nsSocketTransport::GetRetryDnsIfPossible(bool* aRetryDns) {
return NS_OK;
}
NS_IMETHODIMP
nsSocketTransport::GetStatus(nsresult* aStatus) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
*aStatus = mCondition;
return NS_OK;
}
} // namespace net
} // namespace mozilla

View File

@ -90,6 +90,12 @@ nsresult Http3Session::Init(const nsHttpConnectionInfo* aConnInfo,
Unused << mSocketTransport->GetSecurityInfo(getter_AddRefs(info));
mSocketControl = do_QueryObject(info);
nsresult status = NS_OK;
Unused << mSocketTransport->GetStatus(&status);
if (NS_FAILED(status)) {
return status;
}
// Get the local and remote address neqo needs it.
NetAddr selfAddr;
nsresult rv = mSocketTransport->GetSelfAddr(&selfAddr);

View File

@ -2152,6 +2152,11 @@ SocketTransportShim::GetRetryDnsIfPossible(bool* aRetry) {
return mWrapped->GetRetryDnsIfPossible(aRetry);
}
NS_IMETHODIMP
SocketTransportShim::GetStatus(nsresult* aStatus) {
return mWrapped->GetStatus(aStatus);
}
NS_IMPL_ISUPPORTS(TLSFilterTransaction, nsITimerCallback, nsINamed)
NS_IMPL_ISUPPORTS(SocketTransportShim, nsISocketTransport, nsITransport)
NS_IMPL_ISUPPORTS(InputStreamShim, nsIInputStream, nsIAsyncInputStream)