From 7cf04dba6b4e3fba8bf05cb2ae3afadefd60fc93 Mon Sep 17 00:00:00 2001 From: Patrick McManus Date: Wed, 30 Mar 2016 11:16:03 -0400 Subject: [PATCH] Bug 1260764 - Creation of PollableEvent needs a lock r=dragana a=kwierso MozReview-Commit-ID: 2R0ydTeLPqr --HG-- extra : histedit_source : f4a189f30dff540442eb94468bb62ab0e654ca74 --- netwerk/base/nsSocketTransportService2.cpp | 41 ++++++++++++---------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/netwerk/base/nsSocketTransportService2.cpp b/netwerk/base/nsSocketTransportService2.cpp index 9ff8349f9398..88fa0b8add57 100644 --- a/netwerk/base/nsSocketTransportService2.cpp +++ b/netwerk/base/nsSocketTransportService2.cpp @@ -833,26 +833,29 @@ nsSocketTransportService::Run() gSocketThread = PR_GetCurrentThread(); - mPollableEvent.reset(new PollableEvent()); - // - // NOTE: per bug 190000, this failure could be caused by Zone-Alarm - // or similar software. - // - // NOTE: per bug 191739, this failure could also be caused by lack - // of a loopback device on Windows and OS/2 platforms (it creates - // a loopback socket pair on these platforms to implement a pollable - // event object). if we can't create a pollable event, then we'll - // have to "busy wait" to implement the socket event queue :-( - // - if (!mPollableEvent->Valid()) { - mPollableEvent = nullptr; - NS_WARNING("running socket transport thread without a pollable event"); - SOCKET_LOG(("running socket transport thread without a pollable event")); - } + { + DebugMutexAutoLock lock(mLock); + mPollableEvent.reset(new PollableEvent()); + // + // NOTE: per bug 190000, this failure could be caused by Zone-Alarm + // or similar software. + // + // NOTE: per bug 191739, this failure could also be caused by lack + // of a loopback device on Windows and OS/2 platforms (it creates + // a loopback socket pair on these platforms to implement a pollable + // event object). if we can't create a pollable event, then we'll + // have to "busy wait" to implement the socket event queue :-( + // + if (!mPollableEvent->Valid()) { + mPollableEvent = nullptr; + NS_WARNING("running socket transport thread without a pollable event"); + SOCKET_LOG(("running socket transport thread without a pollable event")); + } - mPollList[0].fd = mPollableEvent ? mPollableEvent->PollableFD() : nullptr; - mPollList[0].in_flags = PR_POLL_READ | PR_POLL_EXCEPT; - mPollList[0].out_flags = 0; + mPollList[0].fd = mPollableEvent ? mPollableEvent->PollableFD() : nullptr; + mPollList[0].in_flags = PR_POLL_READ | PR_POLL_EXCEPT; + mPollList[0].out_flags = 0; + } mRawThread = NS_GetCurrentThread();