Bug 1348841 - Switch on blocking mode for named-pipe only on windows. r=bagder, r=mayhemer, a=lizzard
authorLiang-Heng Chen <xeonchen@gmail.com>
Wed, 22 Mar 2017 14:58:03 +0800
changeset 379497 b2ebbc981c90372f01a7d198a07c964eac6f657c
parent 379496 ac4dedf088848948275073e0ee6bbce13c8b73b5
child 379498 b4c7f4163f3e9d8a3652d80615037434c04682c1
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbagder, mayhemer, lizzard
bugs1348841
milestone53.0
Bug 1348841 - Switch on blocking mode for named-pipe only on windows. r=bagder, r=mayhemer, a=lizzard MozReview-Commit-ID: Gvm88q26VHK
netwerk/socket/nsSOCKSIOLayer.cpp
--- a/netwerk/socket/nsSOCKSIOLayer.cpp
+++ b/netwerk/socket/nsSOCKSIOLayer.cpp
@@ -420,24 +420,26 @@ nsSOCKSSocketInfo::SetInternalProxyAddr(
 // is refusing connections when a SOCKS request is rejected by the proxy.
 // When a SOCKS handshake failure occurs, the PR error is set to
 // PR_UNKNOWN_ERROR, and the real error code is returned via the OS error.
 void
 nsSOCKSSocketInfo::HandshakeFinished(PRErrorCode err)
 {
     if (err == 0) {
         mState = SOCKS_CONNECTED;
+#if defined(XP_WIN)
         // Switch back to nonblocking mode after finishing handshaking.
-        if (mFD) {
+        if (IsLocalProxy() && mFD) {
             PRSocketOptionData opt_nonblock;
             opt_nonblock.option = PR_SockOpt_Nonblocking;
             opt_nonblock.value.non_blocking = PR_TRUE;
             PR_SetSocketOption(mFD, &opt_nonblock);
             mFD = nullptr;
         }
+#endif
     } else {
         mState = SOCKS_FAILED;
         PR_SetError(PR_UNKNOWN_ERROR, err);
     }
 
     // We don't need the buffer any longer, so free it.
     delete [] mData;
     mData = nullptr;
@@ -568,23 +570,25 @@ nsSOCKSSocketInfo::ConnectToProxy(PRFile
                 LOGERROR(("socks: connect to domain socket failed (%d)", c));
                 PR_SetError(PR_CONNECT_REFUSED_ERROR, 0);
                 mState = SOCKS_FAILED;
                 return status;
             }
         }
     } while (status != PR_SUCCESS);
 
+#if defined(XP_WIN)
     // Switch to blocking mode during handshaking
-    if (mFD) {
+    if (IsLocalProxy() && mFD) {
         PRSocketOptionData opt_nonblock;
         opt_nonblock.option = PR_SockOpt_Nonblocking;
         opt_nonblock.value.non_blocking = PR_FALSE;
         PR_SetSocketOption(mFD, &opt_nonblock);
     }
+#endif
 
     // Connected now, start SOCKS
     if (mVersion == 4)
         return WriteV4ConnectRequest();
     return WriteV5AuthRequest();
 }
 
 void