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
This commit is contained in:
Roger Meier 2011-06-04 08:57:43 +00:00
parent 5309bd0229
commit 18f1050e71
2 changed files with 11 additions and 5 deletions

View File

@ -202,7 +202,7 @@ void TServerSocket::listen() {
#endif // #ifdef TCP_DEFER_ACCEPT
#ifdef IPV6_V6ONLY
if (res->ai_family == AF_INET6) {
if (res->ai_family == AF_INET6 && path_.empty()) {
int zero = 0;
if (-1 == setsockopt(serverSocket_, IPPROTO_IPV6, IPV6_V6ONLY,
&zero, sizeof(zero))) {

View File

@ -277,7 +277,9 @@ void TSocket::openConnection(struct addrinfo *res) {
// 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::setLinger(bool on, int linger) {
void TSocket::setNoDelay(bool noDelay) {
noDelay_ = noDelay;
if (socket_ < 0) {
if (socket_ < 0 || !path_.empty()) {
return;
}
@ -641,7 +643,7 @@ string TSocket::getSocketInfo() {
}
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::getPeerHost() {
}
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 @@ int TSocket::getPeerPort() {
}
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)) {