Bug 1516325 - Don't poll for POLLPRI on Necko self-pipe on Unix. r=dragana
☠☠ backed out by 007f59cfee3b ☠ ☠
authorJed Davis <jld@mozilla.com>
Mon, 04 Mar 2019 15:39:15 +0000
changeset 520510 28eb88277ffc9e46be47920ceed45bde884b5854
parent 520509 3df57792885326a678ce60ae59d20b395f17cc35
child 520511 7f9508dc59e1de519714e91cbc105be5eae4f402
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana
bugs1516325
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1516325 - Don't poll for POLLPRI on Necko self-pipe on Unix. r=dragana Necko uses a pipe-to-self pattern in its event loop, except that on Windows the pipe is a socket, and we're checking for PR_POLL_EXCEPT for Windows-specific reasons and treating it as an error. On Unix this isn't necessary, and it causes interoperability problems with MacOS, which asserts POLLPRI (which is what PR_POLL_EXCEPT maps to) as well as POLLIN on pipes whenever normal data can be read. (This may be a standards violation by MacOS, but it's simple enough to work around.) Differential Revision: https://phabricator.services.mozilla.com/D21321
netwerk/base/PollableEvent.cpp
netwerk/base/PollableEvent.h
netwerk/base/nsSocketTransportService2.cpp
--- a/netwerk/base/PollableEvent.cpp
+++ b/netwerk/base/PollableEvent.cpp
@@ -392,10 +392,17 @@ bool PollableEvent::IsSignallingAlive(Ti
 
   TimeDuration delay = (TimeStamp::NowLoRes() - mFirstSignalAfterClear);
   bool timedOut = delay > timeout;
 
   return !timedOut;
 #endif  // DEBUG
 }
 
+#ifdef USEPIPE
+/* static */ const PRInt16 PollableEvent::sPollFlags = PR_POLL_READ;
+#else
+/* static */ const PRInt16 PollableEvent::sPollFlags =
+    PR_POLL_READ | PR_POLL_EXCEPT;
+#endif
+
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/base/PollableEvent.h
+++ b/netwerk/base/PollableEvent.h
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef PollableEvent_h__
 #define PollableEvent_h__
 
 #include "mozilla/Mutex.h"
 #include "mozilla/TimeStamp.h"
+#include "prio.h"
 
 namespace mozilla {
 namespace net {
 
 // class must be called locked
 class PollableEvent {
  public:
   PollableEvent();
@@ -38,16 +39,18 @@ class PollableEvent {
   // This returns false on following conditions:
   // - PR_Write has failed
   // - no out_flags were signalled on the socket pair for too long after
   //   the earliest Signal()
   bool IsSignallingAlive(TimeDuration const &timeout);
 
   PRFileDesc *PollableFD() { return mReadFD; }
 
+  static const PRInt16 sPollFlags;
+
  private:
   PRFileDesc *mWriteFD;
   PRFileDesc *mReadFD;
   bool mSignaled;
   // true when PR_Write to the socket pair has failed (status < 1)
   bool mWriteFailed;
   // Set true after AdjustFirstSignalTimestamp() was called
   // Set false after Clear() was called
--- a/netwerk/base/nsSocketTransportService2.cpp
+++ b/netwerk/base/nsSocketTransportService2.cpp
@@ -915,17 +915,17 @@ nsSocketTransportService::Run() {
     //
     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].in_flags = PollableEvent::sPollFlags;
     mPollList[0].out_flags = 0;
   }
 
   mRawThread = NS_GetCurrentThread();
 
   // hook ourselves up to observe event processing for this thread
   nsCOMPtr<nsIThreadInternal> threadInt = do_QueryInterface(mRawThread);
   threadInt->SetObserver(this);
@@ -1696,14 +1696,14 @@ void nsSocketTransportService::TryRepair
   if (!mPollableEvent->Valid()) {
     mPollableEvent = nullptr;
   }
   SOCKET_LOG(
       ("running socket transport thread without "
        "a pollable event now valid=%d",
        !!mPollableEvent));
   mPollList[0].fd = mPollableEvent ? mPollableEvent->PollableFD() : nullptr;
-  mPollList[0].in_flags = PR_POLL_READ | PR_POLL_EXCEPT;
+  mPollList[0].in_flags = PollableEvent::sPollFlags;
   mPollList[0].out_flags = 0;
 }
 
 }  // namespace net
 }  // namespace mozilla