THRIFT-2539:TSocket.cpp AI_ADDRCONFIG problems on Windows
Client: C++ Lib
Patch: Michal Gazda
AI_ADDRCONFIG keeps Windows from making local connections
when no NICs are present.
diff --git a/lib/cpp/src/thrift/transport/TSocket.cpp b/lib/cpp/src/thrift/transport/TSocket.cpp
index dbd29c3..8595506 100755
--- a/lib/cpp/src/thrift/transport/TSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSocket.cpp
@@ -378,6 +378,13 @@
error = getaddrinfo(host_.c_str(), port, &hints, &res0);
+#ifdef _WIN32
+ if (error == WSANO_DATA) {
+ hints.ai_flags &= ~AI_ADDRCONFIG;
+ error = getaddrinfo(host_.c_str(), port, &hints, &res0);
+ }
+#endif
+
if (error) {
string errStr = "TSocket::open() getaddrinfo() " + getSocketInfo() + string(THRIFT_GAI_STRERROR(error));
GlobalOutput(errStr.c_str());