Bug 1360236 - make gSocketThread an internal implementation detail of nsSocketTransportService; r=mcmanus

This change makes the code a little cleaner and reduces the number of
places we call PR_GetCurrentThread, which is important for Quantum DOM
scheduling work.

The conversion was largely automatic, via:

find netwerk/ -name \*.cpp | \
  xargs sed -i -e 's/MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread[^;]*/MOZ_ASSERT(OnSocketThread(), "not on socket thread")/'

and related invocations, with a few manual tweaks at the end.
This commit is contained in:
Nathan Froyd 2017-04-27 14:34:42 -04:00
Родитель cded42efc3
Коммит 042857aede
24 изменённых файлов: 264 добавлений и 260 удалений

Просмотреть файл

@ -55,7 +55,7 @@ TokenBucketCancelable::TokenBucketCancelable(ATokenBucketEvent *event)
NS_IMETHODIMP
TokenBucketCancelable::Cancel(nsresult reason)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mEvent = nullptr;
return NS_OK;
}
@ -171,7 +171,7 @@ EventTokenBucket::SetRate(uint32_t eventsPerSecond,
void
EventTokenBucket::ClearCredits()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
SOCKET_LOG(("EventTokenBucket::ClearCredits %p\n", this));
mCredit = 0;
}
@ -179,21 +179,21 @@ EventTokenBucket::ClearCredits()
uint32_t
EventTokenBucket::BurstEventsAvailable()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
return static_cast<uint32_t>(mCredit / mUnitCost);
}
uint32_t
EventTokenBucket::QueuedEvents()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
return mEvents.GetSize();
}
void
EventTokenBucket::Pause()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
SOCKET_LOG(("EventTokenBucket::Pause %p\n", this));
if (mPaused || mStopped)
return;
@ -208,7 +208,7 @@ EventTokenBucket::Pause()
void
EventTokenBucket::UnPause()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
SOCKET_LOG(("EventTokenBucket::UnPause %p\n", this));
if (!mPaused || mStopped)
return;
@ -221,7 +221,7 @@ EventTokenBucket::UnPause()
void
EventTokenBucket::Stop()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
SOCKET_LOG(("EventTokenBucket::Stop %p armed=%d\n", this, mTimerArmed));
mStopped = true;
CleanupTimers();
@ -237,7 +237,7 @@ EventTokenBucket::Stop()
nsresult
EventTokenBucket::SubmitEvent(ATokenBucketEvent *event, nsICancelable **cancelable)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
SOCKET_LOG(("EventTokenBucket::SubmitEvent %p\n", this));
if (mStopped || !mTimer)
@ -278,7 +278,7 @@ EventTokenBucket::TryImmediateDispatch(TokenBucketCancelable *cancelable)
void
EventTokenBucket::DispatchEvents()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
SOCKET_LOG(("EventTokenBucket::DispatchEvents %p %d\n", this, mPaused));
if (mPaused || mStopped)
return;
@ -304,7 +304,7 @@ EventTokenBucket::DispatchEvents()
void
EventTokenBucket::UpdateTimer()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mTimerArmed || mPaused || mStopped || !mEvents.GetSize() || !mTimer)
return;
@ -337,7 +337,7 @@ EventTokenBucket::UpdateTimer()
NS_IMETHODIMP
EventTokenBucket::Notify(nsITimer *timer)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
#ifdef XP_WIN
if (timer == mFineGrainResetTimer) {
@ -361,7 +361,7 @@ EventTokenBucket::Notify(nsITimer *timer)
void
EventTokenBucket::UpdateCredits()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
TimeStamp now = TimeStamp::Now();
TimeDuration elapsed = now - mLastUpdate;

Просмотреть файл

@ -278,7 +278,7 @@ NetworkActivityMonitor::AttachIOLayer(PRFileDesc *fd)
nsresult
NetworkActivityMonitor::DataInOut(Direction direction)
{
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (gInstance) {
PRIntervalTime now = PR_IntervalNow();

Просмотреть файл

@ -31,7 +31,7 @@ static PRIOMethods *sPollableEventLayerMethodsPtr = nullptr;
static void LazyInitSocket()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (sPollableEventLayerMethodsPtr) {
return;
}
@ -140,7 +140,7 @@ PollableEvent::PollableEvent()
, mSignaled(false)
{
MOZ_COUNT_CTOR(PollableEvent);
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// create pair of prfiledesc that can be used as a poll()ble
// signal. on windows use a localhost socket pair, and on
// unix use a pipe.
@ -257,7 +257,7 @@ PollableEvent::Signal()
// behavior on windows to be as before bug 698882, e.g. write to the socket
// also if an event dispatch is on the socket thread and writing to the
// socket for each event. See bug 1292181.
if (PR_GetCurrentThread() == gSocketThread) {
if (OnSocketThread()) {
SOCKET_LOG(("PollableEvent::Signal OnSocketThread nop\n"));
return true;
}
@ -287,7 +287,7 @@ bool
PollableEvent::Clear()
{
// necessary because of the "dont signal on socket thread" optimization
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
SOCKET_LOG(("PollableEvent::Clear\n"));
mSignaled = false;

Просмотреть файл

@ -69,7 +69,7 @@ void
TLSServerSocket::CreateClientTransport(PRFileDesc* aClientFD,
const NetAddr& aClientAddr)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsresult rv;
RefPtr<nsSocketTransport> trans = new nsSocketTransport;

Просмотреть файл

@ -264,7 +264,7 @@ ThrottleQueue::~ThrottleQueue()
NS_IMETHODIMP
ThrottleQueue::RecordRead(uint32_t aBytesRead)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
ThrottleEntry entry;
entry.mTime = TimeStamp::Now();
entry.mBytesRead = aBytesRead;
@ -276,7 +276,7 @@ ThrottleQueue::RecordRead(uint32_t aBytesRead)
NS_IMETHODIMP
ThrottleQueue::Available(uint32_t aRemaining, uint32_t* aAvailable)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
TimeStamp now = TimeStamp::Now();
TimeStamp oneSecondAgo = now - TimeDuration::FromSeconds(1);
size_t i;
@ -338,7 +338,7 @@ ThrottleQueue::WrapStream(nsIInputStream* aInputStream, nsIAsyncInputStream** aR
NS_IMETHODIMP
ThrottleQueue::Notify(nsITimer* aTimer)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// A notified reader may need to push itself back on the queue.
// Swap out the list of readers so that this works properly.
nsTArray<RefPtr<ThrottleInputStream>> events;
@ -357,7 +357,7 @@ ThrottleQueue::Notify(nsITimer* aTimer)
void
ThrottleQueue::QueueStream(ThrottleInputStream* aStream)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mAsyncEvents.IndexOf(aStream) == mAsyncEvents.NoIndex) {
mAsyncEvents.AppendElement(aStream);
@ -384,7 +384,7 @@ ThrottleQueue::QueueStream(ThrottleInputStream* aStream)
void
ThrottleQueue::DequeueStream(ThrottleInputStream* aStream)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mAsyncEvents.RemoveElement(aStream);
}

Просмотреть файл

@ -270,7 +270,7 @@ nsSocketInputStream::OnSocketReady(nsresult condition)
SOCKET_LOG(("nsSocketInputStream::OnSocketReady [this=%p cond=%" PRIx32 "]\n",
this, static_cast<uint32_t>(condition)));
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsCOMPtr<nsIInputStreamCallback> callback;
{
@ -534,7 +534,7 @@ nsSocketOutputStream::OnSocketReady(nsresult condition)
SOCKET_LOG(("nsSocketOutputStream::OnSocketReady [this=%p cond=%" PRIx32 "]\n",
this, static_cast<uint32_t>(condition)));
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsCOMPtr<nsIOutputStreamCallback> callback;
{
@ -937,7 +937,7 @@ nsSocketTransport::InitWithFilename(const char *filename)
nsresult
nsSocketTransport::InitWithConnectedSocket(PRFileDesc *fd, const NetAddr *addr)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
NS_ASSERTION(!mFD.IsInitialized(), "already initialized");
char buf[kNetAddrMaxCStrBufSize];
@ -1692,7 +1692,7 @@ nsSocketTransport::OnMsgInputClosed(nsresult reason)
SOCKET_LOG(("nsSocketTransport::OnMsgInputClosed [this=%p reason=%" PRIx32 "]\n",
this, static_cast<uint32_t>(reason)));
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mInputClosed = true;
// check if event should affect entire transport
@ -1714,7 +1714,7 @@ nsSocketTransport::OnMsgOutputClosed(nsresult reason)
SOCKET_LOG(("nsSocketTransport::OnMsgOutputClosed [this=%p reason=%" PRIx32 "]\n",
this, static_cast<uint32_t>(reason)));
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mOutputClosed = true;
// check if event should affect entire transport
@ -1732,7 +1732,7 @@ nsSocketTransport::OnMsgOutputClosed(nsresult reason)
void
nsSocketTransport::OnSocketConnected()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
SOCKET_LOG((" advancing to STATE_TRANSFERRING\n"));
mPollFlags = (PR_POLL_READ | PR_POLL_WRITE | PR_POLL_EXCEPT);
@ -1768,7 +1768,7 @@ nsSocketTransport::OnSocketConnected()
void
nsSocketTransport::SetSocketName(PRFileDesc *fd)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mSelfAddrIsSet) {
return;
}
@ -1816,8 +1816,6 @@ STS_PRCloseOnSocketTransport(PRFileDesc *fd)
{
if (gSocketTransportService) {
// Can't PR_Close() a socket off STS thread. Thunk it to STS to die
// FIX - Should use RUN_ON_THREAD once it's generally available
// RUN_ON_THREAD(gSocketThread,WrapRunnableNM(&PR_Close, mFD);
gSocketTransportService->Dispatch(new ThunkPRClose(fd), NS_DISPATCH_NORMAL);
} else {
// something horrible has happened
@ -1839,7 +1837,7 @@ nsSocketTransport::ReleaseFD_Locked(PRFileDesc *fd)
gSocketTransportService->MaxTimeForPrClosePref())) {
// If shutdown last to long, let the socket leak and do not close it.
SOCKET_LOG(("Intentional leak"));
} else if (PR_GetCurrentThread() == gSocketThread) {
} else if (OnSocketThread()) {
SOCKET_LOG(("nsSocketTransport: calling PR_Close [this=%p]\n", this));
CloseSocket(mFD,
mSocketTransportService->IsTelemetryEnabledAndNotSleepPhase());
@ -2098,7 +2096,7 @@ nsSocketTransport::OnSocketDetached(PRFileDesc *fd)
SOCKET_LOG(("nsSocketTransport::OnSocketDetached [this=%p cond=%" PRIx32 "]\n",
this, static_cast<uint32_t>(mCondition)));
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// if we didn't initiate this detach, then be sure to pass an error
// condition up to our consumers. (e.g., STS is shutting down.)
@ -2405,7 +2403,7 @@ nsSocketTransport::GetPort(int32_t *port)
NS_IMETHODIMP
nsSocketTransport::GetNetworkInterfaceId(nsACString &aNetworkInterfaceId)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
aNetworkInterfaceId = mNetworkInterfaceId;
return NS_OK;
}
@ -2413,7 +2411,7 @@ nsSocketTransport::GetNetworkInterfaceId(nsACString &aNetworkInterfaceId)
NS_IMETHODIMP
nsSocketTransport::SetNetworkInterfaceId(const nsACString &aNetworkInterfaceId)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mNetworkInterfaceId = aNetworkInterfaceId;
return NS_OK;
}
@ -2756,7 +2754,7 @@ nsSocketTransport::SetConnectionFlags(uint32_t value)
void
nsSocketTransport::OnKeepaliveEnabledPrefChange(bool aEnabled)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// The global pref toggles keepalive as a system feature; it only affects
// an individual socket if keepalive has been specifically enabled for it.
@ -2846,7 +2844,7 @@ NS_IMETHODIMP
nsSocketTransport::SetKeepaliveEnabled(bool aEnable)
{
#if defined(XP_WIN) || defined(XP_UNIX) || defined(XP_MACOSX)
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (aEnable == mKeepaliveEnabled) {
SOCKET_LOG(("nsSocketTransport::SetKeepaliveEnabled [%p] already %s.",
@ -2897,7 +2895,7 @@ nsSocketTransport::SetKeepaliveVals(int32_t aIdleTime,
int32_t aRetryInterval)
{
#if defined(XP_WIN) || defined(XP_UNIX) || defined(XP_MACOSX)
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (NS_WARN_IF(aIdleTime <= 0 || kMaxTCPKeepIdle < aIdleTime)) {
return NS_ERROR_INVALID_ARG;
}
@ -3048,7 +3046,7 @@ static void LogNSPRError(const char* aPrefix, const void *aObjPtr)
nsresult
nsSocketTransport::PRFileDescAutoLock::SetKeepaliveEnabled(bool aEnable)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!(aEnable && !gSocketTransportService->IsKeepaliveEnabled()),
"Cannot enable keepalive if global pref is disabled!");
if (aEnable && !gSocketTransportService->IsKeepaliveEnabled()) {
@ -3071,7 +3069,7 @@ nsSocketTransport::PRFileDescAutoLock::SetKeepaliveEnabled(bool aEnable)
static void LogOSError(const char *aPrefix, const void *aObjPtr)
{
#if defined(DEBUG)
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
#ifdef XP_WIN
DWORD errCode = WSAGetLastError();
@ -3110,7 +3108,7 @@ nsSocketTransport::PRFileDescAutoLock::SetKeepaliveVals(bool aEnabled,
int aProbeCount)
{
#if defined(XP_WIN) || defined(XP_UNIX) || defined(XP_MACOSX)
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (NS_WARN_IF(aIdleTime <= 0 || kMaxTCPKeepIdle < aIdleTime)) {
return NS_ERROR_INVALID_ARG;
}

Просмотреть файл

@ -413,7 +413,7 @@ private:
void OnInputClosed(nsresult reason)
{
// no need to post an event if called on the socket thread
if (PR_GetCurrentThread() == gSocketThread)
if (OnSocketThread())
OnMsgInputClosed(reason);
else
PostEvent(MSG_INPUT_CLOSED, reason);
@ -421,7 +421,7 @@ private:
void OnInputPending()
{
// no need to post an event if called on the socket thread
if (PR_GetCurrentThread() == gSocketThread)
if (OnSocketThread())
OnMsgInputPending();
else
PostEvent(MSG_INPUT_PENDING);
@ -429,7 +429,7 @@ private:
void OnOutputClosed(nsresult reason)
{
// no need to post an event if called on the socket thread
if (PR_GetCurrentThread() == gSocketThread)
if (OnSocketThread())
OnMsgOutputClosed(reason); // XXX need to not be inside lock!
else
PostEvent(MSG_OUTPUT_CLOSED, reason);
@ -437,7 +437,7 @@ private:
void OnOutputPending()
{
// no need to post an event if called on the socket thread
if (PR_GetCurrentThread() == gSocketThread)
if (OnSocketThread())
OnMsgOutputPending();
else
PostEvent(MSG_OUTPUT_PENDING);

Просмотреть файл

@ -41,7 +41,7 @@ LazyLogModule gUDPSocketLog("UDPSocket");
LazyLogModule gTCPSocketLog("TCPSocket");
nsSocketTransportService *gSocketTransportService = nullptr;
Atomic<PRThread*, Relaxed> gSocketThread;
static Atomic<PRThread*, Relaxed> gSocketThread;
#define SEND_BUFFER_PREF "network.tcp.sendbuffer"
#define KEEPALIVE_ENABLED_PREF "network.tcp.keepalive.enabled"
@ -60,6 +60,13 @@ Atomic<PRThread*, Relaxed> gSocketThread;
uint32_t nsSocketTransportService::gMaxCount;
PRCallOnceType nsSocketTransportService::gMaxCountInitOnce;
// Utility functions
bool
OnSocketThread()
{
return PR_GetCurrentThread() == gSocketThread;
}
//-----------------------------------------------------------------------------
// ctor/dtor (called on the main/UI thread by the service manager)
@ -174,7 +181,7 @@ nsSocketTransportService::NotifyWhenCanAttachSocket(nsIRunnable *event)
{
SOCKET_LOG(("nsSocketTransportService::NotifyWhenCanAttachSocket\n"));
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (CanAttachSocket()) {
return Dispatch(event, NS_DISPATCH_NORMAL);
@ -190,7 +197,7 @@ nsSocketTransportService::AttachSocket(PRFileDesc *fd, nsASocketHandler *handler
{
SOCKET_LOG(("nsSocketTransportService::AttachSocket [handler=%p]\n", handler));
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (!CanAttachSocket()) {
return NS_ERROR_NOT_AVAILABLE;
@ -783,7 +790,7 @@ nsSocketTransportService::OnDispatchedEvent(nsIThreadInternal *thread)
// behavior on windows to be as before bug 698882, e.g. write to the socket
// also if an event dispatch is on the socket thread and writing to the
// socket for each event.
if (PR_GetCurrentThread() == gSocketThread) {
if (OnSocketThread()) {
// this check is redundant to one done inside ::Signal(), but
// we can do it here and skip obtaining the lock - given that
// this is a relatively common occurance its worth the
@ -1288,7 +1295,7 @@ void
nsSocketTransportService::OnKeepaliveEnabledPrefChange()
{
// Dispatch to socket thread if we're not executing there.
if (PR_GetCurrentThread() != gSocketThread) {
if (!OnSocketThread()) {
gSocketTransportService->Dispatch(
NewRunnableMethod(
this, &nsSocketTransportService::OnKeepaliveEnabledPrefChange),
@ -1429,7 +1436,7 @@ nsSocketTransportService::GetSendBufferSize(int32_t *value)
void
nsSocketTransportService::ProbeMaxCount()
{
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mProbedMaxCount)
return;
@ -1581,7 +1588,7 @@ nsSocketTransportService::AnalyzeConnection(nsTArray<SocketInfo> *data,
void
nsSocketTransportService::GetSocketConnections(nsTArray<SocketInfo> *data)
{
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
for (uint32_t i = 0; i < mActiveCount; i++)
AnalyzeConnection(data, &mActiveList[i], true);
for (uint32_t i = 0; i < mIdleCount; i++)

Просмотреть файл

@ -274,7 +274,7 @@ private:
};
extern nsSocketTransportService *gSocketTransportService;
extern Atomic<PRThread*, Relaxed> gSocketThread;
bool OnSocketThread();
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -45,7 +45,7 @@ public:
// nsASocketHandler methods
virtual void OnSocketReady(PRFileDesc* fd, int16_t outFlags) override
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(fd == mFD);
if (outFlags & (PR_POLL_ERR | PR_POLL_HUP | PR_POLL_NVAL)) {
@ -62,7 +62,7 @@ public:
virtual void OnSocketDetached(PRFileDesc *fd) override
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mThread);
MOZ_ASSERT(fd == mFD);
@ -107,7 +107,7 @@ public:
nsresult Init()
{
MOZ_ASSERT(PR_GetCurrentThread() != gSocketThread);
MOZ_ASSERT(!OnSocketThread(), "on socket thread");
mThread = NS_GetCurrentThread();
if (!mService) {
@ -130,7 +130,7 @@ public:
void Close()
{
MOZ_ASSERT(PR_GetCurrentThread() != gSocketThread);
MOZ_ASSERT(!OnSocketThread(), "on socket thread");
if (!gSocketTransportService) {
Deallocate();
@ -160,7 +160,7 @@ private:
void OnMsgClose()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (NS_FAILED(mCondition)) {
return;
@ -179,7 +179,7 @@ private:
void OnMsgAttach()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (NS_FAILED(mCondition)) {
return;
@ -197,7 +197,7 @@ private:
nsresult TryAttach()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsresult rv;

Просмотреть файл

@ -53,7 +53,7 @@ BrowseReplyRunnable::Reply(DNSServiceRef aSdRef,
const char* aReplyDomain,
void* aContext)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
BrowseOperator* obj(reinterpret_cast<BrowseOperator*>(aContext));
if (!obj) {
@ -116,7 +116,7 @@ RegisterReplyRunnable::Reply(DNSServiceRef aSdRef,
const char* domain,
void* aContext)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
RegisterOperator* obj(reinterpret_cast<RegisterOperator*>(aContext));
if (!obj) {
@ -196,7 +196,7 @@ ResolveReplyRunnable::Reply(DNSServiceRef aSdRef,
const unsigned char* aTxtRecord,
void* aContext)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
ResolveOperator* obj(reinterpret_cast<ResolveOperator*>(aContext));
if (!obj) {
@ -268,7 +268,7 @@ GetAddrInfoReplyRunnable::Reply(DNSServiceRef aSdRef,
uint32_t aTTL,
void* aContext)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
GetAddrInfoOperator* obj(reinterpret_cast<GetAddrInfoOperator*>(aContext));
if (!obj) {

Просмотреть файл

@ -35,7 +35,7 @@ nsHttpConnectionMgr::PrintDiagnostics()
void
nsHttpConnectionMgr::OnMsgPrintDiagnostics(int32_t, ARefBase *)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);

Просмотреть файл

@ -113,7 +113,7 @@ AddStaticElement(const nsCString &name)
static void
InitializeStaticHeaders()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (!gStaticHeaders) {
gStaticHeaders = new nsDeque();
gStaticReporter = new HpackStaticTableReporter();

Просмотреть файл

@ -114,7 +114,7 @@ Http2Session::Http2Session(nsISocketTransport *aSocketTransport, uint32_t versio
, mAttemptingEarlyData(attemptingEarlyData)
, mOriginFrameActivated(false)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
static uint64_t sSerial;
mSerial = ++sSerial;
@ -234,7 +234,7 @@ static Http2ControlFx sControlFunctions[] = {
bool
Http2Session::RoomForMoreConcurrent()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
return (mConcurrent < mMaxConcurrent);
}
@ -256,7 +256,7 @@ Http2Session::IdleTime()
uint32_t
Http2Session::ReadTimeoutTick(PRIntervalTime now)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::ReadTimeoutTick %p delta since last read %ds\n",
this, PR_IntervalToSeconds(now - mLastReadEpoch)));
@ -334,7 +334,7 @@ Http2Session::ReadTimeoutTick(PRIntervalTime now)
uint32_t
Http2Session::RegisterStreamID(Http2Stream *stream, uint32_t aNewID)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mNextStreamID < 0xfffffff0,
"should have stopped admitting streams");
MOZ_ASSERT(!(aNewID & 1),
@ -374,7 +374,7 @@ Http2Session::AddStream(nsAHttpTransaction *aHttpTransaction,
bool aUseTunnel,
nsIInterfaceRequestor *aCallbacks)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// integrity check
if (mStreamTransactionHash.Get(aHttpTransaction)) {
@ -444,7 +444,7 @@ void
Http2Session::QueueStream(Http2Stream *stream)
{
// will be removed via processpending or a shutdown path
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!stream->CountAsActive());
MOZ_ASSERT(!stream->Queued());
@ -466,7 +466,7 @@ Http2Session::QueueStream(Http2Stream *stream)
void
Http2Session::ProcessPending()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
Http2Stream*stream;
while (RoomForMoreConcurrent() &&
@ -486,7 +486,7 @@ nsresult
Http2Session::NetworkRead(nsAHttpSegmentWriter *writer, char *buf,
uint32_t count, uint32_t *countWritten)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (!count) {
*countWritten = 0;
@ -590,7 +590,7 @@ Http2Session::SpdyVersion()
uint32_t
Http2Session::GetWriteQueueSize()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
return mReadyForWrite.GetSize();
}
@ -598,7 +598,7 @@ Http2Session::GetWriteQueueSize()
void
Http2Session::ChangeDownstreamState(enum internalStateType newState)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::ChangeDownstreamState() %p from %X to %X",
this, mDownstreamState, newState));
@ -608,7 +608,7 @@ Http2Session::ChangeDownstreamState(enum internalStateType newState)
void
Http2Session::ResetDownstreamState()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::ResetDownstreamState() %p", this));
ChangeDownstreamState(BUFFERING_FRAME_HEADER);
@ -649,7 +649,7 @@ Http2Session::TryToActivate(Http2Stream *aStream)
void
Http2Session::IncrementConcurrent(Http2Stream *stream)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!stream->StreamID() || (stream->StreamID() & 1),
"Do not activate pushed streams");
@ -714,7 +714,7 @@ Http2Session::CreateFrameHeader(uint8_t *dest, uint16_t frameLength,
void
Http2Session::MaybeDecrementConcurrent(Http2Stream *aStream)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("MaybeDecrementConcurrent %p id=0x%X concurrent=%d active=%d\n",
this, aStream->StreamID(), mConcurrent, aStream->CountAsActive()));
@ -750,7 +750,7 @@ Http2Session::UncompressAndDiscard(bool isPush)
void
Http2Session::GeneratePing(bool isAck)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::GeneratePing %p isAck=%d\n", this, isAck));
char *packet = EnsureOutputBuffer(kFrameHeaderBytes + 8);
@ -773,7 +773,7 @@ void
Http2Session::GenerateSettingsAck()
{
// need to generate ack of this settings frame
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::GenerateSettingsAck %p\n", this));
char *packet = EnsureOutputBuffer(kFrameHeaderBytes);
@ -786,7 +786,7 @@ Http2Session::GenerateSettingsAck()
void
Http2Session::GeneratePriority(uint32_t aID, uint8_t aPriorityWeight)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::GeneratePriority %p %X %X\n",
this, aID, aPriorityWeight));
@ -804,7 +804,7 @@ Http2Session::GeneratePriority(uint32_t aID, uint8_t aPriorityWeight)
void
Http2Session::GenerateRstStream(uint32_t aStatusCode, uint32_t aID)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// make sure we don't do this twice for the same stream (at least if we
// have a stream entry for it)
@ -831,7 +831,7 @@ Http2Session::GenerateRstStream(uint32_t aStatusCode, uint32_t aID)
void
Http2Session::GenerateGoAway(uint32_t aStatusCode)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::GenerateGoAway %p code=%X\n", this, aStatusCode));
mClientGoAwayReason = aStatusCode;
@ -862,7 +862,7 @@ Http2Session::GenerateGoAway(uint32_t aStatusCode)
void
Http2Session::SendHello()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::SendHello %p\n", this));
// sized for magic + 5 settings and a session window update and 5 priority frames
@ -991,7 +991,7 @@ bool
Http2Session::VerifyStream(Http2Stream *aStream, uint32_t aOptionalID = 0)
{
// This is annoying, but at least it is O(1)
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
#ifndef DEBUG
// Only do the real verification in debug builds
@ -1048,7 +1048,7 @@ void
Http2Session::CleanupStream(Http2Stream *aStream, nsresult aResult,
errorType aResetCode)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::CleanupStream %p %p 0x%X %" PRIX32 "\n",
this, aStream, aStream ? aStream->StreamID() : 0, static_cast<uint32_t>(aResult)));
if (!aStream) {
@ -1126,7 +1126,7 @@ Http2Session::CleanupStream(Http2Stream *aStream, nsresult aResult,
void
Http2Session::CleanupStream(uint32_t aID, nsresult aResult, errorType aResetCode)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
Http2Stream *stream = mStreamIDHash.Get(aID);
LOG3(("Http2Session::CleanupStream %p by ID 0x%X to stream %p\n",
this, aID, stream));
@ -1158,7 +1158,7 @@ Http2Session::RemoveStreamFromQueues(Http2Stream *aStream)
void
Http2Session::CloseStream(Http2Stream *aStream, nsresult aResult)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::CloseStream %p %p 0x%x %" PRIX32 "\n",
this, aStream, aStream->StreamID(), static_cast<uint32_t>(aResult)));
@ -2297,7 +2297,7 @@ Http2Session::RecvAltSvc(Http2Session *self)
void
Http2Session::Received421(nsHttpConnectionInfo *ci)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::Recevied421 %p %d\n", this, mOriginFrameActivated));
if (!mOriginFrameActivated || !ci) {
return;
@ -2325,7 +2325,7 @@ Http2Session::RecvUnused(Http2Session *self)
nsresult
Http2Session::RecvOrigin(Http2Session *self)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(self->mInputFrameType == FRAME_TYPE_ORIGIN);
LOG3(("Http2Session::RecvOrigin %p Flags 0x%X id 0x%X\n", self,
self->mInputFrameFlags, self->mInputFrameID));
@ -2417,7 +2417,7 @@ void
Http2Session::OnTransportStatus(nsITransport* aTransport,
nsresult aStatus, int64_t aProgress)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
switch (aStatus) {
// These should appear only once, deliver to the first
@ -2474,7 +2474,7 @@ nsresult
Http2Session::ReadSegmentsAgain(nsAHttpSegmentReader *reader,
uint32_t count, uint32_t *countRead, bool *again)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!mSegmentReader || !reader || (mSegmentReader == reader),
"Inconsistent Write Function Callback");
@ -2710,7 +2710,7 @@ Http2Session::WriteSegmentsAgain(nsAHttpSegmentWriter *writer,
uint32_t count, uint32_t *countWritten,
bool *again)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::WriteSegments %p InternalState %X\n",
this, mDownstreamState));
@ -3342,7 +3342,7 @@ Http2Session::UpdateLocalRwin(Http2Stream *stream, uint32_t bytes)
void
Http2Session::Close(nsresult aReason)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mClosed)
return;
@ -3386,7 +3386,7 @@ void
Http2Session::CloseTransaction(nsAHttpTransaction *aTransaction,
nsresult aResult)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::CloseTransaction %p %p %" PRIx32, this, aTransaction,
static_cast<uint32_t>(aResult)));
@ -3419,7 +3419,7 @@ nsresult
Http2Session::OnReadSegment(const char *buf,
uint32_t count, uint32_t *countRead)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsresult rv;
// If we can release old queued data then we can try and write the new
@ -3514,7 +3514,7 @@ nsresult
Http2Session::OnWriteSegment(char *buf,
uint32_t count, uint32_t *countWritten)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsresult rv;
if (!mSegmentWriter) {
@ -3644,7 +3644,7 @@ Http2Session::ConnectSlowConsumer(Http2Stream *stream)
uint32_t
Http2Session::FindTunnelCount(nsHttpConnectionInfo *aConnInfo)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
uint32_t rv = 0;
mTunnelHash.Get(aConnInfo->HashKey(), &rv);
return rv;
@ -3653,7 +3653,7 @@ Http2Session::FindTunnelCount(nsHttpConnectionInfo *aConnInfo)
void
Http2Session::RegisterTunnel(Http2Stream *aTunnel)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsHttpConnectionInfo *ci = aTunnel->Transaction()->ConnectionInfo();
uint32_t newcount = FindTunnelCount(ci) + 1;
mTunnelHash.Remove(ci->HashKey());
@ -3665,7 +3665,7 @@ Http2Session::RegisterTunnel(Http2Stream *aTunnel)
void
Http2Session::UnRegisterTunnel(Http2Stream *aTunnel)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsHttpConnectionInfo *ci = aTunnel->Transaction()->ConnectionInfo();
MOZ_ASSERT(FindTunnelCount(ci));
uint32_t newcount = FindTunnelCount(ci) - 1;
@ -3700,7 +3700,7 @@ void
Http2Session::DispatchOnTunnel(nsAHttpTransaction *aHttpTransaction,
nsIInterfaceRequestor *aCallbacks)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsHttpTransaction *trans = aHttpTransaction->QueryHttpTransaction();
nsHttpConnectionInfo *ci = aHttpTransaction->ConnectionInfo();
MOZ_ASSERT(trans);
@ -3737,7 +3737,7 @@ Http2Session::DispatchOnTunnel(nsAHttpTransaction *aHttpTransaction,
bool
Http2Session::MaybeReTunnel(nsAHttpTransaction *aHttpTransaction)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsHttpTransaction *trans = aHttpTransaction->QueryHttpTransaction();
LOG(("Http2Session::MaybeReTunnel %p trans=%p\n", this, trans));
if (!trans || trans->TunnelProvider() != this) {
@ -3885,7 +3885,7 @@ Http2Session::ConfirmTLSProfile()
void
Http2Session::TransactionHasDataToWrite(nsAHttpTransaction *caller)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::TransactionHasDataToWrite %p trans=%p", this, caller));
// a trapped signal from the http transaction to the connection that
@ -3918,7 +3918,7 @@ Http2Session::TransactionHasDataToWrite(nsAHttpTransaction *caller)
void
Http2Session::TransactionHasDataToRecv(nsAHttpTransaction *caller)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::TransactionHasDataToRecv %p trans=%p", this, caller));
// a signal from the http transaction to the connection that it will consume more
@ -3937,7 +3937,7 @@ Http2Session::TransactionHasDataToRecv(nsAHttpTransaction *caller)
void
Http2Session::TransactionHasDataToWrite(Http2Stream *stream)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Session::TransactionHasDataToWrite %p stream=%p ID=0x%x",
this, stream, stream->StreamID()));
@ -4038,7 +4038,7 @@ Http2Session::Available()
nsHttpRequestHead *
Http2Session::RequestHead()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(false,
"Http2Session::RequestHead() "
"should not be called after http/2 is setup");
@ -4082,7 +4082,7 @@ Http2Session::TakeSubTransactions(
nsAHttpConnection *
Http2Session::Connection()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
return mConnection;
}
@ -4112,7 +4112,7 @@ Http2Session::PushBack(const char *buf, uint32_t len)
void
Http2Session::SendPing()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mPreviousUsed) {
// alredy in progress, get out
@ -4136,7 +4136,7 @@ Http2Session::SendPing()
bool
Http2Session::TestOriginFrame(const nsACString &hostname, int32_t port)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mOriginFrameActivated);
nsAutoCString key(hostname);

Просмотреть файл

@ -75,7 +75,7 @@ Http2Stream::Http2Stream(nsAHttpTransaction *httpTransaction,
, mIsTunnel(false)
, mPlainTextTunnel(false)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG3(("Http2Stream::Http2Stream %p", this));
@ -121,7 +121,7 @@ Http2Stream::ReadSegments(nsAHttpSegmentReader *reader,
LOG3(("Http2Stream %p ReadSegments reader=%p count=%d state=%x",
this, reader, count, mUpstreamState));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsresult rv = NS_ERROR_UNEXPECTED;
mRequestBlockedOnRead = 0;
@ -288,7 +288,7 @@ Http2Stream::WriteSegments(nsAHttpSegmentWriter *writer,
uint32_t count,
uint32_t *countWritten)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!mSegmentWriter, "segment writer in progress");
LOG3(("Http2Stream::WriteSegments %p count=%d state=%x",
@ -390,7 +390,7 @@ Http2Stream::ParseHttpRequestHeaders(const char *buf,
// Returns NS_OK even if the headers are incomplete
// set mRequestHeadersDone flag if they are complete
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mUpstreamState == GENERATING_HEADERS);
MOZ_ASSERT(!mRequestHeadersDone);
@ -974,7 +974,7 @@ Http2Stream::GenerateDataFrameHeader(uint32_t dataLength, bool lastFrame)
LOG3(("Http2Stream::GenerateDataFrameHeader %p len=%d last=%d",
this, dataLength, lastFrame));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!mTxInlineFrameUsed, "inline frame not empty");
MOZ_ASSERT(!mTxStreamFrameSize, "stream frame not empty");
@ -1306,7 +1306,7 @@ Http2Stream::OnReadSegment(const char *buf,
LOG3(("Http2Stream::OnReadSegment %p count=%d state=%x",
this, count, mUpstreamState));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mSegmentReader, "OnReadSegment with null mSegmentReader");
nsresult rv = NS_ERROR_UNEXPECTED;
@ -1451,7 +1451,7 @@ Http2Stream::OnWriteSegment(char *buf,
LOG3(("Http2Stream::OnWriteSegment %p count=%d state=%x 0x%X\n",
this, count, mUpstreamState, mStreamID));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mSegmentWriter);
if (mPushSource) {
@ -1485,7 +1485,7 @@ Http2Stream::OnWriteSegment(char *buf,
void
Http2Stream::ClearTransactionsBlockedOnTunnel()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (!mIsTunnel) {
return;

Просмотреть файл

@ -23,6 +23,7 @@
#include "nsNetCID.h"
#include "nsServiceManagerUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsSocketTransportService2.h"
namespace mozilla {
namespace net {
@ -44,7 +45,7 @@ TLSFilterTransaction::TLSFilterTransaction(nsAHttpTransaction *aWrapped,
, mForce(false)
, mNudgeCounter(0)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("TLSFilterTransaction ctor %p\n", this));
nsCOMPtr<nsISocketProvider> provider;
@ -257,7 +258,7 @@ TLSFilterTransaction::OnWriteSegment(char *aData,
uint32_t *outCountRead)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mSegmentWriter);
LOG(("TLSFilterTransaction::OnWriteSegment %p max=%d\n", this, aCount));
if (!mSecInfo) {
@ -291,7 +292,7 @@ TLSFilterTransaction::OnWriteSegment(char *aData,
int32_t
TLSFilterTransaction::FilterInput(char *aBuf, int32_t aAmount)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mSegmentWriter);
LOG(("TLSFilterTransaction::FilterInput max=%d\n", aAmount));
@ -316,7 +317,7 @@ nsresult
TLSFilterTransaction::ReadSegments(nsAHttpSegmentReader *aReader,
uint32_t aCount, uint32_t *outCountRead)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("TLSFilterTransaction::ReadSegments %p max=%d\n", this, aCount));
if (!mTransaction) {
@ -342,7 +343,7 @@ nsresult
TLSFilterTransaction::WriteSegments(nsAHttpSegmentWriter *aWriter,
uint32_t aCount, uint32_t *outCountWritten)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("TLSFilterTransaction::WriteSegments %p max=%d\n", this, aCount));
if (!mTransaction) {
@ -378,7 +379,7 @@ TLSFilterTransaction::GetTransactionSecurityInfo(nsISupports **outSecInfo)
nsresult
TLSFilterTransaction::NudgeTunnel(NudgeTunnelCallback *aCallback)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("TLSFilterTransaction %p NudgeTunnel\n", this));
mNudgeCallback = nullptr;
@ -434,7 +435,7 @@ TLSFilterTransaction::NudgeTunnel(NudgeTunnelCallback *aCallback)
NS_IMETHODIMP
TLSFilterTransaction::Notify(nsITimer *timer)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("TLSFilterTransaction %p NudgeTunnel notify\n", this));
if (timer != mTimer) {
@ -984,7 +985,7 @@ SpdyConnectTransaction::~SpdyConnectTransaction()
void
SpdyConnectTransaction::ForcePlainText()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!mInputDataUsed && !mInputDataSize && !mInputDataOffset);
MOZ_ASSERT(!mForcePlainText);
MOZ_ASSERT(!mTunnelTransport, "call before mapstreamtohttpconnection");
@ -1044,7 +1045,7 @@ SpdyConnectTransaction::MapStreamToHttpConnection(nsISocketTransport *aTransport
nsresult
SpdyConnectTransaction::Flush(uint32_t count, uint32_t *countRead)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("SpdyConnectTransaction::Flush %p count %d avail %d\n",
this, count, mOutputDataUsed - mOutputDataOffset));
@ -1088,7 +1089,7 @@ SpdyConnectTransaction::ReadSegments(nsAHttpSegmentReader *reader,
uint32_t count,
uint32_t *countRead)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("SpdyConnectTransaction::ReadSegments %p count %d conn %p\n",
this, count, mTunneledConn.get()));
@ -1152,7 +1153,7 @@ SpdyConnectTransaction::ReadSegments(nsAHttpSegmentReader *reader,
void
SpdyConnectTransaction::CreateShimError(nsresult code)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(NS_FAILED(code));
if (mTunnelStreamOut && NS_SUCCEEDED(mTunnelStreamOut->mStatus)) {
@ -1177,7 +1178,7 @@ SpdyConnectTransaction::WriteSegments(nsAHttpSegmentWriter *writer,
uint32_t count,
uint32_t *countWritten)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("SpdyConnectTransaction::WriteSegments %p max=%d cb=%p\n",
this, count, mTunneledConn ? mTunnelStreamIn->mCallback : nullptr));
@ -1245,7 +1246,7 @@ NS_IMETHODIMP
OutputStreamShim::AsyncWait(nsIOutputStreamCallback *callback,
unsigned int, unsigned int, nsIEventTarget *target)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
bool currentThread;
if (target &&
@ -1322,7 +1323,7 @@ OutputStreamShim::Flush()
NS_IMETHODIMP
OutputStreamShim::Write(const char * aBuf, uint32_t aCount, uint32_t *_retval)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (NS_FAILED(mStatus)) {
return mStatus;
@ -1379,7 +1380,7 @@ NS_IMETHODIMP
InputStreamShim::AsyncWait(nsIInputStreamCallback *callback,
unsigned int, unsigned int, nsIEventTarget *target)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
bool currentThread;
if (target &&
@ -1435,7 +1436,7 @@ InputStreamShim::Available(uint64_t *_retval)
NS_IMETHODIMP
InputStreamShim::Read(char *aBuf, uint32_t aCount, uint32_t *_retval)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (NS_FAILED(mStatus)) {
return mStatus;

Просмотреть файл

@ -556,7 +556,7 @@ npnComplete:
void
nsHttpConnection::OnTunnelNudged(TLSFilterTransaction *trans)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnection::OnTunnelNudged %p\n", this));
if (trans != mTLSFilter) {
return;
@ -569,7 +569,7 @@ nsHttpConnection::OnTunnelNudged(TLSFilterTransaction *trans)
nsresult
nsHttpConnection::Activate(nsAHttpTransaction *trans, uint32_t caps, int32_t pri)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnection::Activate [this=%p trans=%p caps=%x]\n",
this, trans, caps));
@ -746,7 +746,7 @@ nsresult
nsHttpConnection::AddTransaction(nsAHttpTransaction *httpTransaction,
int32_t priority)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mSpdySession && mUsingSpdyVersion,
"AddTransaction to live http connection without spdy");
@ -781,7 +781,7 @@ nsHttpConnection::Close(nsresult reason, bool aIsShutdown)
LOG(("nsHttpConnection::Close [this=%p reason=%" PRIx32 "]\n",
this, static_cast<uint32_t>(reason)));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// Ensure TCP keepalive timer is stopped.
if (mTCPKeepaliveTransitionTimer) {
@ -844,7 +844,7 @@ nsHttpConnection::InitSSLParams(bool connectingToProxy, bool proxyStartSSL)
{
LOG(("nsHttpConnection::InitSSLParams [this=%p] connectingToProxy=%d\n",
this, connectingToProxy));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsresult rv;
nsCOMPtr<nsISupports> securityInfo;
@ -1012,7 +1012,7 @@ nsHttpConnection::OnHeadersAvailable(nsAHttpTransaction *trans,
LOG(("nsHttpConnection::OnHeadersAvailable [this=%p trans=%p response-head=%p]\n",
this, trans, responseHead));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
NS_ENSURE_ARG_POINTER(trans);
MOZ_ASSERT(responseHead, "No response head?");
@ -1261,7 +1261,7 @@ nsHttpConnection::TakeTransport(nsISocketTransport **aTransport,
uint32_t
nsHttpConnection::ReadTimeoutTick(PRIntervalTime now)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// make sure timer didn't tick before Activate()
if (!mTransaction)
@ -1328,7 +1328,7 @@ nsHttpConnection::UpdateTCPKeepalive(nsITimer *aTimer, void *aClosure)
void
nsHttpConnection::GetSecurityInfo(nsISupports **secinfo)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnection::GetSecurityInfo trans=%p tlsfilter=%p socket=%p\n",
mTransaction.get(), mTLSFilter.get(), mSocketTransport.get()));
@ -1380,7 +1380,7 @@ nsHttpConnection::ResumeSend()
{
LOG(("nsHttpConnection::ResumeSend [this=%p]\n", this));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mSocketOut)
return mSocketOut->AsyncWait(this, 0, 0, nullptr);
@ -1394,7 +1394,7 @@ nsHttpConnection::ResumeRecv()
{
LOG(("nsHttpConnection::ResumeRecv [this=%p]\n", this));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// mResponseThrottled is an indication from above layers to stop reading
// the socket.
@ -1437,7 +1437,7 @@ public:
NS_IMETHOD Run() override
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mDoRecv) {
if (!mConn->mSocketIn)
@ -1460,7 +1460,7 @@ private:
void
nsHttpConnection::ForceSendIO(nsITimer *aTimer, void *aClosure)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsHttpConnection *self = static_cast<nsHttpConnection *>(aClosure);
MOZ_ASSERT(aTimer == self->mForceSendTimer);
self->mForceSendTimer = nullptr;
@ -1470,7 +1470,7 @@ nsHttpConnection::ForceSendIO(nsITimer *aTimer, void *aClosure)
nsresult
nsHttpConnection::MaybeForceSendIO()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// due to bug 1213084 sometimes real I/O events do not get serviced when
// NSPR derived I/O events are ready and this can cause a deadlock with
// https over https proxying. Normally we would expect the write callback to
@ -1493,7 +1493,7 @@ nsresult
nsHttpConnection::ForceRecv()
{
LOG(("nsHttpConnection::ForceRecv [this=%p]\n", this));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
return NS_DispatchToCurrentThread(new HttpConnectionForceIO(this, true));
}
@ -1503,7 +1503,7 @@ nsresult
nsHttpConnection::ForceSend()
{
LOG(("nsHttpConnection::ForceSend [this=%p]\n", this));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mTLSFilter) {
return mTLSFilter->NudgeTunnel(this);
@ -1515,7 +1515,7 @@ void
nsHttpConnection::BeginIdleMonitoring()
{
LOG(("nsHttpConnection::BeginIdleMonitoring [this=%p]\n", this));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!mTransaction, "BeginIdleMonitoring() while active");
MOZ_ASSERT(!mUsingSpdyVersion, "Idle monitoring of spdy not allowed");
@ -1529,7 +1529,7 @@ void
nsHttpConnection::EndIdleMonitoring()
{
LOG(("nsHttpConnection::EndIdleMonitoring [this=%p]\n", this));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!mTransaction, "EndIdleMonitoring() while active");
if (mIdleMonitoring) {
@ -1559,7 +1559,7 @@ nsHttpConnection::CloseTransaction(nsAHttpTransaction *trans, nsresult reason,
MOZ_ASSERT((trans == mTransaction) ||
(mTLSFilter && mTLSFilter->Transaction() == trans));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mCurrentBytesRead > mMaxBytesRead)
mMaxBytesRead = mCurrentBytesRead;
@ -1860,7 +1860,7 @@ nsHttpConnection::OnSocketReadable()
void
nsHttpConnection::SetupSecondaryTLS()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!mTLSFilter);
LOG(("nsHttpConnection %p SetupSecondaryTLS %s %d\n",
this, mConnInfo->Origin(), mConnInfo->OriginPort()));
@ -2108,7 +2108,7 @@ nsHttpConnection::DisableTCPKeepalives()
void nsHttpConnection::ThrottleResponse(bool aThrottle)
{
LOG(("nsHttpConnection::ThrottleResponse this=%p, throttle=%d", this, aThrottle));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (aThrottle) {
mResponseThrottled = true;
@ -2161,7 +2161,7 @@ NS_IMETHODIMP
nsHttpConnection::OnInputStreamReady(nsIAsyncInputStream *in)
{
MOZ_ASSERT(in == mSocketIn, "unexpected stream");
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mIdleMonitoring) {
MOZ_ASSERT(!mTransaction, "Idle Input Event While Active");
@ -2202,7 +2202,7 @@ nsHttpConnection::OnInputStreamReady(nsIAsyncInputStream *in)
NS_IMETHODIMP
nsHttpConnection::OnOutputStreamReady(nsIAsyncOutputStream *out)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(out == mSocketOut, "unexpected socket");
// if the transaction was dropped...
if (!mTransaction) {
@ -2249,7 +2249,7 @@ nsHttpConnection::GetInterface(const nsIID &iid, void **result)
// nss thread, not the ui thread as the above comment says. So there is
// indeed a chance of mTransaction going away. bug 615342
MOZ_ASSERT(PR_GetCurrentThread() != gSocketThread);
MOZ_ASSERT(!OnSocketThread(), "on socket thread");
nsCOMPtr<nsIInterfaceRequestor> callbacks;
{

Просмотреть файл

@ -553,7 +553,7 @@ nsHttpConnectionMgr::UpdateRequestTokenBucket(EventTokenBucket *aBucket)
nsresult
nsHttpConnectionMgr::ClearConnectionHistory()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
nsAutoPtr<nsConnectionEntry>& ent = iter.Data();
@ -572,7 +572,7 @@ nsHttpConnectionMgr::ClearConnectionHistory()
nsresult
nsHttpConnectionMgr::CloseIdleConnection(nsHttpConnection *conn)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::CloseIdleConnection %p conn=%p",
this, conn));
@ -595,7 +595,7 @@ nsHttpConnectionMgr::CloseIdleConnection(nsHttpConnection *conn)
nsresult
nsHttpConnectionMgr::RemoveIdleConnection(nsHttpConnection *conn)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::RemoveIdleConnection %p conn=%p",
this, conn));
@ -619,7 +619,7 @@ nsHttpConnectionMgr::FindCoalescableConnectionByHashKey(nsConnectionEntry *ent,
const nsCString &key,
bool justKidding)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(ent->mConnInfo);
nsHttpConnectionInfo *ci = ent->mConnInfo;
@ -691,7 +691,7 @@ nsHttpConnection *
nsHttpConnectionMgr::FindCoalescableConnection(nsConnectionEntry *ent,
bool justKidding)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(ent->mConnInfo);
nsHttpConnectionInfo *ci = ent->mConnInfo;
LOG(("FindCoalescableConnection %s\n", ci->HashKey().get()));
@ -726,7 +726,7 @@ void
nsHttpConnectionMgr::UpdateCoalescingForNewConn(nsHttpConnection *newConn,
nsConnectionEntry *ent)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(newConn);
MOZ_ASSERT(newConn->ConnectionInfo());
MOZ_ASSERT(ent);
@ -797,7 +797,7 @@ void
nsHttpConnectionMgr::ReportSpdyConnection(nsHttpConnection *conn,
bool usingSpdy)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (!conn->ConnectionInfo()) {
return;
}
@ -838,7 +838,7 @@ nsHttpConnectionMgr::DispatchPendingQ(nsTArray<RefPtr<nsHttpConnectionMgr::Pendi
nsConnectionEntry *ent,
bool considerAll)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
PendingTransactionInfo *pendingTransInfo = nullptr;
nsresult rv;
@ -953,7 +953,7 @@ nsHttpConnectionMgr::MaxPersistConnections(nsConnectionEntry *ent) const
bool
nsHttpConnectionMgr::ProcessPendingQForEntry(nsConnectionEntry *ent, bool considerAll)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::ProcessPendingQForEntry "
"[ci=%s ent=%p active=%" PRIuSIZE " idle=%" PRIuSIZE " urgent-start-queue=%" PRIuSIZE
@ -1081,7 +1081,7 @@ nsHttpConnectionMgr::ProcessPendingQForEntry(nsConnectionEntry *ent, bool consid
bool
nsHttpConnectionMgr::ProcessPendingQForEntry(nsHttpConnectionInfo *ci)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsConnectionEntry *ent = mCT.Get(ci->HashKey());
if (ent)
@ -1155,7 +1155,7 @@ nsHttpConnectionMgr::ClosePersistentConnections(nsConnectionEntry *ent)
bool
nsHttpConnectionMgr::RestrictConnections(nsConnectionEntry *ent)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (ent->AvailableForDispatchNow()) {
// this might be a h2/spdy connection in this connection entry that
@ -1217,7 +1217,7 @@ nsHttpConnectionMgr::MakeNewConnection(nsConnectionEntry *ent,
LOG(("nsHttpConnectionMgr::MakeNewConnection %p ent=%p trans=%p",
this, ent, trans));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
uint32_t halfOpenLength = ent->mHalfOpens.Length();
for (uint32_t i = 0; i < halfOpenLength; i++) {
@ -1354,7 +1354,7 @@ nsHttpConnectionMgr::TryDispatchTransaction(nsConnectionEntry *ent,
bool onlyReusedConnection,
PendingTransactionInfo *pendingTransInfo)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsHttpTransaction *trans = pendingTransInfo->mTransaction;
@ -1688,7 +1688,7 @@ nsHttpConnectionMgr::ReportProxyTelemetry(nsConnectionEntry *ent)
nsresult
nsHttpConnectionMgr::ProcessNewTransaction(nsHttpTransaction *trans)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// since "adds" and "cancels" are processed asynchronously and because
// various events might trigger an "add" directly on the socket thread,
@ -1852,7 +1852,7 @@ nsHttpConnectionMgr::CreateTransport(nsConnectionEntry *ent,
bool allow1918,
PendingTransactionInfo *pendingTransInfo)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT((speculative && !pendingTransInfo) ||
(!speculative && pendingTransInfo));
@ -1962,7 +1962,7 @@ nsHttpConnectionMgr::ProcessSpdyPendingQ(nsConnectionEntry *ent)
void
nsHttpConnectionMgr::OnMsgProcessAllSpdyPendingQ(int32_t, ARefBase *)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::OnMsgProcessAllSpdyPendingQ\n"));
for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
ProcessSpdyPendingQ(iter.Data());
@ -1974,7 +1974,7 @@ nsHttpConnectionMgr::OnMsgProcessAllSpdyPendingQ(int32_t, ARefBase *)
nsHttpConnection *
nsHttpConnectionMgr::GetSpdyActiveConn(nsConnectionEntry *ent)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(ent);
nsHttpConnection *experienced = nullptr;
@ -2038,7 +2038,7 @@ nsHttpConnectionMgr::GetSpdyActiveConn(nsConnectionEntry *ent)
void
nsHttpConnectionMgr::OnMsgShutdown(int32_t, ARefBase *param)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::OnMsgShutdown\n"));
gHttpHandler->StopRequestTokenBucket();
@ -2145,7 +2145,7 @@ nsHttpConnectionMgr::OnMsgNewTransaction(int32_t priority, ARefBase *param)
void
nsHttpConnectionMgr::OnMsgReschedTransaction(int32_t priority, ARefBase *param)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::OnMsgReschedTransaction [trans=%p]\n", param));
RefPtr<nsHttpTransaction> trans = static_cast<nsHttpTransaction *>(param);
@ -2180,7 +2180,7 @@ nsHttpConnectionMgr::OnMsgReschedTransaction(int32_t priority, ARefBase *param)
void nsHttpConnectionMgr::OnMsgThrottleTransaction(int32_t arg, ARefBase *param)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::OnMsgThrottleTransaction [trans=%p]\n", param));
bool throttle = static_cast<bool>(arg);
@ -2192,7 +2192,7 @@ void nsHttpConnectionMgr::OnMsgThrottleTransaction(int32_t arg, ARefBase *param)
void
nsHttpConnectionMgr::OnMsgCancelTransaction(int32_t reason, ARefBase *param)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::OnMsgCancelTransaction [trans=%p]\n", param));
nsresult closeCode = static_cast<nsresult>(reason);
@ -2276,7 +2276,7 @@ nsHttpConnectionMgr::OnMsgCancelTransaction(int32_t reason, ARefBase *param)
void
nsHttpConnectionMgr::OnMsgProcessPendingQ(int32_t, ARefBase *param)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsHttpConnectionInfo *ci = static_cast<nsHttpConnectionInfo *>(param);
if (!ci) {
@ -2353,7 +2353,7 @@ nsHttpConnectionMgr::OnMsgCancelTransactions(int32_t code, ARefBase *param)
void
nsHttpConnectionMgr::OnMsgPruneDeadConnections(int32_t, ARefBase *)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::OnMsgPruneDeadConnections\n"));
// Reset mTimeOfNextWakeUp so that we can find a new shortest value.
@ -2450,7 +2450,7 @@ nsHttpConnectionMgr::OnMsgPruneDeadConnections(int32_t, ARefBase *)
void
nsHttpConnectionMgr::OnMsgPruneNoTraffic(int32_t, ARefBase *)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::OnMsgPruneNoTraffic\n"));
// Prune connections without traffic
@ -2484,7 +2484,7 @@ nsHttpConnectionMgr::OnMsgPruneNoTraffic(int32_t, ARefBase *)
void
nsHttpConnectionMgr::OnMsgVerifyTraffic(int32_t, ARefBase *)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::OnMsgVerifyTraffic\n"));
if (mPruningNoTraffic) {
@ -2528,7 +2528,7 @@ void
nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup(int32_t, ARefBase *param)
{
LOG(("nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup\n"));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsHttpConnectionInfo *ci = static_cast<nsHttpConnectionInfo *>(param);
@ -2543,7 +2543,7 @@ nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup(int32_t, ARefBase *para
void
nsHttpConnectionMgr::OnMsgReclaimConnection(int32_t, ARefBase *param)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::OnMsgReclaimConnection [conn=%p]\n", param));
nsHttpConnection *conn = static_cast<nsHttpConnection *>(param);
@ -2634,7 +2634,7 @@ nsHttpConnectionMgr::OnMsgReclaimConnection(int32_t, ARefBase *param)
void
nsHttpConnectionMgr::OnMsgCompleteUpgrade(int32_t, ARefBase *param)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsCompleteUpgradeData *data = static_cast<nsCompleteUpgradeData *>(param);
LOG(("nsHttpConnectionMgr::OnMsgCompleteUpgrade "
"this=%p conn=%p listener=%p\n", this, data->mConn.get(),
@ -2700,7 +2700,7 @@ nsHttpConnectionMgr::nsConnectionEntry::~nsConnectionEntry()
void
nsHttpConnectionMgr::ActivateTimeoutTick()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::ActivateTimeoutTick() "
"this=%p mTimeoutTick=%p\n", this, mTimeoutTick.get()));
@ -2761,7 +2761,7 @@ void
nsHttpConnectionMgr::OnMsgUpdateCurrentTopLevelOuterContentWindowId(
int32_t, ARefBase *param)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mCurrentTopLevelOuterContentWindowId =
static_cast<UINT64Wrapper*>(param)->GetValue();
LOG(("nsHttpConnectionMgr::OnMsgUpdateCurrentTopLevelOuterContentWindowId"
@ -2772,7 +2772,7 @@ nsHttpConnectionMgr::OnMsgUpdateCurrentTopLevelOuterContentWindowId(
void
nsHttpConnectionMgr::TimeoutTick()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mTimeoutTick, "no readtimeout tick");
LOG(("nsHttpConnectionMgr::TimeoutTick active=%d\n", mNumActiveConns));
@ -2909,7 +2909,7 @@ ConnectionHandle::TakeTransport(nsISocketTransport **aTransport,
void
nsHttpConnectionMgr::OnMsgSpeculativeConnect(int32_t, ARefBase *param)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
SpeculativeConnectArgs *args = static_cast<SpeculativeConnectArgs *>(param);
@ -3044,7 +3044,7 @@ nsHalfOpenSocket::SetupStreams(nsISocketTransport **transport,
nsIAsyncOutputStream **outstream,
bool isBackup)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsresult rv;
const char *socketTypes[1];
@ -3175,7 +3175,7 @@ nsHalfOpenSocket::SetupStreams(nsISocketTransport **transport,
nsresult
nsHttpConnectionMgr::nsHalfOpenSocket::SetupPrimaryStreams()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsresult rv;
@ -3263,7 +3263,7 @@ nsHttpConnectionMgr::nsHalfOpenSocket::Abandon()
mSocketTransport.get(), mBackupTransport.get(),
mStreamOut.get(), mBackupStreamOut.get()));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
RefPtr<nsHalfOpenSocket> deleteProtector(this);
@ -3316,7 +3316,7 @@ nsHttpConnectionMgr::nsHalfOpenSocket::Duration(TimeStamp epoch)
NS_IMETHODIMP // method for nsITimerCallback
nsHttpConnectionMgr::nsHalfOpenSocket::Notify(nsITimer *timer)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(timer == mSynTimer, "wrong timer");
DebugOnly<nsresult> rv = SetupBackupStreams();
@ -3359,7 +3359,7 @@ NS_IMETHODIMP
nsHttpConnectionMgr::
nsHalfOpenSocket::OnOutputStreamReady(nsIAsyncOutputStream *out)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(out == mStreamOut || out == mBackupStreamOut,
"stream mismatch");
LOG(("nsHalfOpenSocket::OnOutputStreamReady [this=%p ent=%s %s]\n",
@ -3525,7 +3525,7 @@ nsHttpConnectionMgr::RegisterOriginCoalescingKey(nsHttpConnection *conn,
const nsACString &host,
int32_t port)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsHttpConnectionInfo *ci = conn ? conn->ConnectionInfo() : nullptr;
if (!ci || !conn->CanDirectlyActivate()) {
return;
@ -3552,7 +3552,7 @@ nsHttpConnectionMgr::nsHalfOpenSocket::OnTransportStatus(nsITransport *trans,
int64_t progress,
int64_t progressMax)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mTransaction) {
RefPtr<PendingTransactionInfo> info = FindTransactionHelper(false);
@ -3804,7 +3804,7 @@ nsHttpConnectionMgr::GetConnectionData(nsTArray<HttpRetParams> *aArg)
void
nsHttpConnectionMgr::ResetIPFamilyPreference(nsHttpConnectionInfo *ci)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsConnectionEntry *ent = mCT.Get(ci->HashKey());
if (ent) {
ent->ResetIPFamilyPreference();
@ -3992,7 +3992,7 @@ nsHttpConnectionMgr::MoveToWildCardConnEntry(nsHttpConnectionInfo *specificCI,
nsHttpConnectionInfo *wildCardCI,
nsHttpConnection *proxyConn)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(specificCI->UsingHttpsProxy());
LOG(("nsHttpConnectionMgr::MakeConnEntryWildCard conn %p has requested to "

Просмотреть файл

@ -616,7 +616,7 @@ uint32_t
nsHttpHandler::Get32BitsOfPseudoRandom()
{
// only confirm rand seeding on socket thread
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// rand() provides different amounts of PRNG on different platforms.
// 15 or 31 bits are common amounts.

Просмотреть файл

@ -33,7 +33,7 @@ class nsIThrottlingService;
namespace mozilla {
namespace net {
extern Atomic<PRThread*, Relaxed> gSocketThread;
bool OnSocketThread();
class ATokenBucketEvent;
class EventTokenBucket;
@ -593,7 +593,7 @@ public:
MOZ_MUST_USE nsresult SubmitPacedRequest(ATokenBucketEvent *event,
nsICancelable **cancel)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (!mRequestTokenBucket) {
return NS_ERROR_NOT_AVAILABLE;
}
@ -603,13 +603,13 @@ public:
// Socket thread only
void SetRequestTokenBucket(EventTokenBucket *aTokenBucket)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mRequestTokenBucket = aTokenBucket;
}
void StopRequestTokenBucket()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mRequestTokenBucket) {
mRequestTokenBucket->Stop();
mRequestTokenBucket = nullptr;

Просмотреть файл

@ -156,7 +156,7 @@ nsHttpTransaction::nsHttpTransaction()
void nsHttpTransaction::ThrottleResponse(bool aThrottle)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// Just in case we suspend, get a connection, release a connection, get another connection.
mThrottleResponse = aThrottle;
@ -405,7 +405,7 @@ nsHttpTransaction::Init(uint32_t caps,
nsAHttpConnection *
nsHttpTransaction::Connection()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
return mConnection.get();
}
@ -552,7 +552,7 @@ nsHttpTransaction::OnTransportStatus(nsITransport* transport,
if (!mTransportSink)
return;
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// Need to do this before the STATUS_RECEIVING_FROM check below, to make
// sure that the activity distributor gets told about all status events.
@ -691,7 +691,7 @@ nsresult
nsHttpTransaction::ReadSegments(nsAHttpSegmentReader *reader,
uint32_t count, uint32_t *countRead)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mTransactionDone) {
*countRead = 0;
@ -808,7 +808,7 @@ nsHttpTransaction::WriteSegments(nsAHttpSegmentWriter *writer,
this, reentrantFlag));
MOZ_DIAGNOSTIC_ASSERT(!reentrantFlag);
reentrantFlag = true;
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mTransactionDone) {
reentrantFlag = false;
@ -866,7 +866,7 @@ nsHttpTransaction::Close(nsresult reason)
LOG(("nsHttpTransaction::Close [this=%p reason=%" PRIx32 "]\n",
this, static_cast<uint32_t>(reason)));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (reason == NS_BINDING_RETARGETED) {
LOG((" close %p skipped due to ERETARGETED\n", this));
return;
@ -1114,7 +1114,7 @@ nsHttpTransaction::ResponseTimeoutEnabled() const
nsresult
nsHttpTransaction::Restart()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
// limit the number of restart attempts - bug 92224
if (++mRestartCount >= gHttpHandler->MaxRequestAttempts()) {
@ -1433,7 +1433,7 @@ nsresult
nsHttpTransaction::HandleContentStart()
{
LOG(("nsHttpTransaction::HandleContentStart [this=%p]\n", this));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mResponseHead) {
if (mEarlyDataDisposition == EARLY_ACCEPTED) {
@ -1816,7 +1816,7 @@ nsHttpTransaction::CheckForStickyAuthScheme()
MOZ_ASSERT(mHaveAllHeaders);
MOZ_ASSERT(mResponseHead);
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mClosed) {
LOG((" closed, not checking"));
@ -2104,7 +2104,7 @@ NS_IMPL_QUERY_INTERFACE(nsHttpTransaction,
NS_IMETHODIMP
nsHttpTransaction::OnInputStreamReady(nsIAsyncInputStream *out)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mConnection) {
mConnection->TransactionHasDataToWrite(this);
nsresult rv = mConnection->ResumeSend();
@ -2122,7 +2122,7 @@ nsHttpTransaction::OnInputStreamReady(nsIAsyncInputStream *out)
NS_IMETHODIMP
nsHttpTransaction::OnOutputStreamReady(nsIAsyncOutputStream *out)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mWaitingOnPipeOut = false;
if (mConnection) {
mConnection->TransactionHasDataToRecv(this);

Просмотреть файл

@ -1299,7 +1299,7 @@ WebSocketChannel::OnNetworkChanged()
NS_DISPATCH_NORMAL);
}
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "not socket thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("WebSocketChannel::OnNetworkChanged() - on socket thread %p", this));
@ -1500,7 +1500,7 @@ nsresult
WebSocketChannel::ProcessInput(uint8_t *buffer, uint32_t count)
{
LOG(("WebSocketChannel::ProcessInput %p [%d %d]\n", this, count, mBuffered));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "not socket thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsresult rv;
@ -2005,7 +2005,7 @@ void
WebSocketChannel::EnqueueOutgoingMessage(nsDeque &aQueue,
OutboundMessage *aMsg)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "not socket thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("WebSocketChannel::EnqueueOutgoingMessage %p "
"queueing msg %p [type=%s len=%d]\n",
@ -2039,7 +2039,7 @@ void
WebSocketChannel::PrimeNewOutgoingMessage()
{
LOG(("WebSocketChannel::PrimeNewOutgoingMessage() %p\n", this));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "not socket thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!mCurrentOut, "Current message in progress");
nsresult rv = NS_OK;
@ -2505,7 +2505,7 @@ WebSocketChannel::ReleaseSession()
{
LOG(("WebSocketChannel::ReleaseSession() %p stopped = %d\n",
this, !!mStopped));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "not socket thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mStopped)
return;
@ -2994,7 +2994,7 @@ nsresult
WebSocketChannel::StartPinging()
{
LOG(("WebSocketChannel::StartPinging() %p", this));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "not socket thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mPingInterval);
MOZ_ASSERT(!mPingTimer);
@ -3243,8 +3243,7 @@ WebSocketChannel::Notify(nsITimer *timer)
if (timer == mCloseTimer) {
MOZ_ASSERT(mClientClosed, "Close Timeout without local close");
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread,
"not socket thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mCloseTimer = nullptr;
if (mStopped || mServerClosed) /* no longer relevant */
@ -3272,8 +3271,7 @@ WebSocketChannel::Notify(nsITimer *timer)
LOG(("WebSocketChannel: connecting [this=%p] after reconnect delay", this));
BeginOpen(false);
} else if (timer == mPingTimer) {
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread,
"not socket thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mClientClosed || mServerClosed || mRequestedClose) {
// no point in worrying about ping now
@ -3944,7 +3942,7 @@ NS_IMETHODIMP
WebSocketChannel::OnInputStreamReady(nsIAsyncInputStream *aStream)
{
LOG(("WebSocketChannel::OnInputStreamReady() %p\n", this));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "not socket thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (!mSocketIn) // did we we clean up the socket after scheduling InputReady?
return NS_OK;
@ -3997,7 +3995,7 @@ NS_IMETHODIMP
WebSocketChannel::OnOutputStreamReady(nsIAsyncOutputStream *aStream)
{
LOG(("WebSocketChannel::OnOutputStreamReady() %p\n", this));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "not socket thread");
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsresult rv;
if (!mCurrentOut)

Просмотреть файл

@ -32,7 +32,7 @@ WebSocketFrame::WebSocketFrame(bool aFinBit, bool aRsvBit1, bool aRsvBit2,
: mData(PR_Now(), aFinBit, aRsvBit1, aRsvBit2, aRsvBit3, aOpCode, aMaskBit,
aMask, aPayload)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mData.mTimeStamp = PR_Now();
}

Просмотреть файл

@ -240,7 +240,7 @@ NamedPipeInfo::OnError(uint32_t aError,
nsresult
NamedPipeInfo::Connect(const nsACString& aPath)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
HANDLE pipe;
nsAutoCString path(aPath);
@ -295,7 +295,7 @@ NamedPipeInfo::Connect(const nsACString& aPath)
nsresult
NamedPipeInfo::Disconnect()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
nsresult rv = mNamedPipeService->RemoveDataObserver(mPipe, this);
NS_WARN_IF(NS_FAILED(rv));
@ -319,7 +319,7 @@ NamedPipeInfo::Disconnect()
int32_t
NamedPipeInfo::Read(void* aBuffer, int32_t aSize)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
int32_t bytesRead = Peek(aBuffer, aSize);
@ -333,7 +333,7 @@ NamedPipeInfo::Read(void* aBuffer, int32_t aSize)
int32_t
NamedPipeInfo::Write(const void* aBuffer, int32_t aSize)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mWriteBegin <= mWriteEnd);
if (!IsConnected()) {
@ -374,7 +374,7 @@ NamedPipeInfo::Write(const void* aBuffer, int32_t aSize)
uint32_t
NamedPipeInfo::Peek(void* aBuffer, int32_t aSize)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mReadBegin <= mReadEnd);
if (!IsConnected()) {
@ -412,7 +412,7 @@ NamedPipeInfo::Peek(void* aBuffer, int32_t aSize)
int32_t
NamedPipeInfo::Available() const
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mReadBegin <= mReadEnd);
MOZ_ASSERT(mReadEnd - mReadBegin <= 0x7FFFFFFF); // no more than int32_max
return mReadEnd - mReadBegin;
@ -421,7 +421,7 @@ NamedPipeInfo::Available() const
bool
NamedPipeInfo::Sync(uint32_t aTimeout)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (!mHasPendingWrite) {
return true;
}
@ -431,28 +431,28 @@ NamedPipeInfo::Sync(uint32_t aTimeout)
void
NamedPipeInfo::SetNonblocking(bool nonblocking)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
mNonblocking = nonblocking;
}
bool
NamedPipeInfo::IsConnected() const
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
return mPipe && mPipe != INVALID_HANDLE_VALUE;
}
bool
NamedPipeInfo::IsNonblocking() const
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
return mNonblocking;
}
HANDLE
NamedPipeInfo::GetHandle() const
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
return mPipe;
}
@ -460,7 +460,7 @@ NamedPipeInfo::GetHandle() const
int16_t
NamedPipeInfo::GetPollFlags(int16_t aInFlags, int16_t* aOutFlags)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
*aOutFlags = 0;
@ -507,7 +507,7 @@ NamedPipeInfo::GetPollFlags(int16_t aInFlags, int16_t* aOutFlags)
int32_t
NamedPipeInfo::DoRead()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!mHasPendingRead);
MOZ_ASSERT(mReadBegin == mReadEnd); // the buffer should be empty
@ -547,7 +547,7 @@ NamedPipeInfo::DoRead()
int32_t
NamedPipeInfo::DoReadContinue()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mHasPendingRead);
MOZ_ASSERT(mReadBegin == 0 && mReadEnd == 0);
@ -590,7 +590,7 @@ NamedPipeInfo::DoReadContinue()
int32_t
NamedPipeInfo::DoWrite()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(!mHasPendingWrite);
MOZ_ASSERT(mWriteBegin < mWriteEnd);
@ -622,7 +622,7 @@ NamedPipeInfo::DoWrite()
int32_t
NamedPipeInfo::DoWriteContinue()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(mHasPendingWrite);
DWORD bytesWritten = 0;
@ -654,7 +654,7 @@ NamedPipeInfo::DoWriteContinue()
static inline NamedPipeInfo*
GetNamedPipeInfo(PRFileDesc* aFd)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_DIAGNOSTIC_ASSERT(aFd);
MOZ_DIAGNOSTIC_ASSERT(aFd->secret);
MOZ_DIAGNOSTIC_ASSERT(PR_GetLayersIdentity(aFd) == nsNamedPipeLayerIdentity);
@ -674,7 +674,7 @@ nsNamedPipeConnect(PRFileDesc* aFd,
const PRNetAddr* aAddr,
PRIntervalTime aTimeout)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
NamedPipeInfo* info = GetNamedPipeInfo(aFd);
if (!info) {
@ -693,7 +693,7 @@ nsNamedPipeConnect(PRFileDesc* aFd,
static PRStatus
nsNamedPipeConnectContinue(PRFileDesc* aFd, PRInt16 aOutFlags)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
return PR_SUCCESS;
}
@ -701,7 +701,7 @@ nsNamedPipeConnectContinue(PRFileDesc* aFd, PRInt16 aOutFlags)
static PRStatus
nsNamedPipeClose(PRFileDesc* aFd)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (aFd->secret && PR_GetLayersIdentity(aFd) == nsNamedPipeLayerIdentity) {
RefPtr<NamedPipeInfo> info = dont_AddRef(GetNamedPipeInfo(aFd));
@ -723,7 +723,7 @@ nsNamedPipeSend(PRFileDesc* aFd,
PRIntn aFlags,
PRIntervalTime aTimeout)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
Unused << aFlags;
Unused << aTimeout;
@ -743,7 +743,7 @@ nsNamedPipeRecv(PRFileDesc* aFd,
PRIntn aFlags,
PRIntervalTime aTimeout)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
Unused << aTimeout;
@ -767,7 +767,7 @@ nsNamedPipeRecv(PRFileDesc* aFd,
static inline PRInt32
nsNamedPipeRead(PRFileDesc* aFd, void* aBuffer, PRInt32 aAmount)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
NamedPipeInfo* info = GetNamedPipeInfo(aFd);
if (!info) {
@ -780,7 +780,7 @@ nsNamedPipeRead(PRFileDesc* aFd, void* aBuffer, PRInt32 aAmount)
static inline PRInt32
nsNamedPipeWrite(PRFileDesc* aFd, const void* aBuffer, PRInt32 aAmount)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
NamedPipeInfo* info = GetNamedPipeInfo(aFd);
if (!info) {
@ -793,7 +793,7 @@ nsNamedPipeWrite(PRFileDesc* aFd, const void* aBuffer, PRInt32 aAmount)
static PRInt32
nsNamedPipeAvailable(PRFileDesc* aFd)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
NamedPipeInfo* info = GetNamedPipeInfo(aFd);
if (!info) {
@ -806,7 +806,7 @@ nsNamedPipeAvailable(PRFileDesc* aFd)
static PRInt64
nsNamedPipeAvailable64(PRFileDesc* aFd)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
NamedPipeInfo* info = GetNamedPipeInfo(aFd);
if (!info) {
@ -819,7 +819,7 @@ nsNamedPipeAvailable64(PRFileDesc* aFd)
static PRStatus
nsNamedPipeSync(PRFileDesc* aFd)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
NamedPipeInfo* info = GetNamedPipeInfo(aFd);
if (!info) {
@ -832,7 +832,7 @@ nsNamedPipeSync(PRFileDesc* aFd)
static PRInt16
nsNamedPipePoll(PRFileDesc* aFd, PRInt16 aInFlags, PRInt16* aOutFlags)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
NamedPipeInfo* info = GetNamedPipeInfo(aFd);
if (!info) {
@ -846,7 +846,7 @@ nsNamedPipePoll(PRFileDesc* aFd, PRInt16 aInFlags, PRInt16* aOutFlags)
static PRStatus
nsNamedPipeGetSocketOption(PRFileDesc* aFd, PRSocketOptionData* aData)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(aFd);
MOZ_ASSERT(aData);
@ -874,7 +874,7 @@ nsNamedPipeGetSocketOption(PRFileDesc* aFd, PRSocketOptionData* aData)
static PRStatus
nsNamedPipeSetSocketOption(PRFileDesc* aFd, const PRSocketOptionData* aData)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
MOZ_ASSERT(aFd);
MOZ_ASSERT(aData);
@ -897,7 +897,7 @@ nsNamedPipeSetSocketOption(PRFileDesc* aFd, const PRSocketOptionData* aData)
static void
Initialize()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
static bool initialized = false;
if (initialized) {
@ -932,7 +932,7 @@ IsNamedPipePath(const nsACString& aPath)
PRFileDesc*
CreateNamedPipeLayer()
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
Initialize();
PRFileDesc* layer = PR_CreateIOLayerStub(nsNamedPipeLayerIdentity,