THRIFT-1196 Unix Domain Socket Support is broken


git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1131352 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/transport/TSocket.cpp b/lib/cpp/src/transport/TSocket.cpp
index 73cb56d..7b1d356 100644
--- a/lib/cpp/src/transport/TSocket.cpp
+++ b/lib/cpp/src/transport/TSocket.cpp
@@ -277,7 +277,9 @@
   // Set socket back to normal mode (blocking)
   fcntl(socket_, F_SETFL, flags);
 
-  setCachedAddress(res->ai_addr, res->ai_addrlen);
+  if (path_.empty()) {
+    setCachedAddress(res->ai_addr, res->ai_addrlen);
+  }
 }
 
 void TSocket::open() {
@@ -561,7 +563,7 @@
 
 void TSocket::setNoDelay(bool noDelay) {
   noDelay_ = noDelay;
-  if (socket_ < 0) {
+  if (socket_ < 0 || !path_.empty()) {
     return;
   }
 
@@ -641,7 +643,7 @@
 }
 
 std::string TSocket::getPeerHost() {
-  if (peerHost_.empty()) {
+  if (peerHost_.empty() && path_.empty()) {
     struct sockaddr_storage addr;
     struct sockaddr* addrPtr;
     socklen_t addrLen;
@@ -675,7 +677,7 @@
 }
 
 std::string TSocket::getPeerAddress() {
-  if (peerAddress_.empty()) {
+  if (peerAddress_.empty() && path_.empty()) {
     struct sockaddr_storage addr;
     struct sockaddr* addrPtr;
     socklen_t addrLen;
@@ -716,6 +718,10 @@
 }
 
 void TSocket::setCachedAddress(const sockaddr* addr, socklen_t len) {
+  if (!path_.empty()) {
+    return;
+  }
+
   switch (addr->sa_family) {
   case AF_INET:
     if (len == sizeof(sockaddr_in)) {