THRIFT-2539:TSocket.cpp AI_ADDRCONFIG problems on Windows
authorRandy Abernethy <ra@apache.org>
Tue, 17 Jun 2014 04:15:23 +0000 (21:15 -0700)
committerRandy Abernethy <ra@apache.org>
Tue, 17 Jun 2014 04:15:23 +0000 (21:15 -0700)
Client: C++ Lib
Patch: Michal Gazda

AI_ADDRCONFIG keeps Windows from making local connections
when no NICs are present.

lib/cpp/src/thrift/transport/TSocket.cpp

index dbd29c3..8595506 100755 (executable)
@@ -378,6 +378,13 @@ void TSocket::local_open(){
 
   error = getaddrinfo(host_.c_str(), port, &hints, &res0);
 
+#ifdef _WIN32\r
+  if (error == WSANO_DATA) {\r
+    hints.ai_flags &= ~AI_ADDRCONFIG;\r
+    error = getaddrinfo(host_.c_str(), port, &hints, &res0);\r
+  }\r
+#endif\r
+\r
   if (error) {
     string errStr = "TSocket::open() getaddrinfo() " + getSocketInfo() + string(THRIFT_GAI_STRERROR(error));
     GlobalOutput(errStr.c_str());