Bug 1259089 - Set TCP socket to non-blocking in sts again, just to be sure. r=mcmanus
authorDragana Damjanovic <dd.mozilla@gmail.com>
Thu, 24 Mar 2016 10:10:00 -0400
changeset 290548 1fc001760e73deabb9c2114bd88876be3699a0b8
parent 290547 3d31cc25fd3b28b928a7f4b90f481fb66976363f
child 290549 3a90ca63a3f04c0b84200e9d3b0a806dd93453fa
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1259089
milestone48.0a1
Bug 1259089 - Set TCP socket to non-blocking in sts again, just to be sure. r=mcmanus
netwerk/base/nsSocketTransport2.cpp
--- a/netwerk/base/nsSocketTransport2.cpp
+++ b/netwerk/base/nsSocketTransport2.cpp
@@ -1416,16 +1416,30 @@ nsSocketTransport::InitiateSocket()
                 return NS_ERROR_FAILURE;
             }
             mBindAddr = nullptr;
         }
     }
 
     NetAddrToPRNetAddr(&mNetAddr, &prAddr);
 
+#ifdef XP_WIN
+    // Find the real tcp socket and set non-blocking once again!
+    // Bug 1158189.
+    PRFileDesc *bottom = PR_GetIdentitiesLayer(fd, PR_NSPR_IO_LAYER);
+    if (bottom) {
+      PROsfd osfd = PR_FileDesc2NativeHandle(bottom);
+      u_long nonblocking = 1;
+      if (ioctlsocket(osfd, FIONBIO, &nonblocking) != 0) {
+        NS_WARNING("Socket could not be set non-blocking!");
+        return NS_ERROR_FAILURE;
+      }
+    }
+#endif
+
     // We use PRIntervalTime here because we need
     // nsIOService::LastOfflineStateChange time and
     // nsIOService::LastConectivityChange time to be atomic.
     PRIntervalTime connectStarted = 0;
     if (gSocketTransportService->IsTelemetryEnabledAndNotSleepPhase()) {
         connectStarted = PR_IntervalNow();
     }