Merge pull request #265 from fsb4000/cherry-pick
author0xDEADFACE <masmfan@gmail.com>
Tue, 19 Jan 2016 07:32:09 +0000 (07:32 +0000)
committer0xDEADFACE <masmfan@gmail.com>
Tue, 19 Jan 2016 07:32:09 +0000 (07:32 +0000)
replace 3 separate calls to WSAGetLastError() with 1

src/netbase.cpp

index 1e7172e..00e4bfd 100644 (file)
@@ -359,8 +359,9 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
 
     if (connect(hSocket, (struct sockaddr*)&sockaddr, len) == SOCKET_ERROR)
     {
+        int nErr = WSAGetLastError();
         // WSAEINVAL is here because some legacy version of winsock uses it
-        if (WSAGetLastError() == WSAEINPROGRESS || WSAGetLastError() == WSAEWOULDBLOCK || WSAGetLastError() == WSAEINVAL)
+        if (nErr == WSAEINPROGRESS || nErr == WSAEWOULDBLOCK || nErr == WSAEINVAL)
         {
             struct timeval timeout;
             timeout.tv_sec  = nTimeout / 1000;