From 6c26fad24613c208cdc5d268dd96bcf7d91f312d Mon Sep 17 00:00:00 2001 From: Roger Meier Date: Thu, 8 Dec 2011 20:44:16 +0000 Subject: [PATCH] THRIFT-1433 TServerSocket fix for MSVC Patch: Peace C git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1212109 13f79535-47bb-0310-9956-ffa450edef68 --- lib/cpp/src/transport/TServerSocket.cpp | 14 ++++++-------- lib/cpp/src/windows/config.h | 5 +++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/cpp/src/transport/TServerSocket.cpp b/lib/cpp/src/transport/TServerSocket.cpp index c4a7f7c2..ec7a3824 100644 --- a/lib/cpp/src/transport/TServerSocket.cpp +++ b/lib/cpp/src/transport/TServerSocket.cpp @@ -310,14 +310,18 @@ void TServerSocket::listen() { len = sizeof(address); do { - if (0 == bind(serverSocket_, (struct sockaddr *) &address, len)) { + if (0 == ::bind(serverSocket_, (struct sockaddr *) &address, len)) { break; } // use short circuit evaluation here to only sleep if we need to } while ((retries++ < retryLimit_) && (sleep(retryDelay_) == 0)); +#else + GlobalOutput.perror("TSocket::open() Unix Domain socket path not supported on windows", -99); + throw TTransportException(TTransportException::NOT_OPEN, " Unix Domain socket path not supported"); +#endif } else { do { - if (0 == bind(serverSocket_, res->ai_addr, res->ai_addrlen)) { + if (0 == ::bind(serverSocket_, res->ai_addr, res->ai_addrlen)) { break; } // use short circuit evaluation here to only sleep if we need to @@ -325,12 +329,6 @@ void TServerSocket::listen() { // free addrinfo freeaddrinfo(res0); - -#else - GlobalOutput.perror("TSocket::open() Unix Domain socket path not supported on windows", -99); - throw TTransportException(TTransportException::NOT_OPEN, " Unix Domain socket path not supported"); -#endif - } // throw an error if we failed to bind properly diff --git a/lib/cpp/src/windows/config.h b/lib/cpp/src/windows/config.h index 272a070d..3af158ad 100644 --- a/lib/cpp/src/windows/config.h +++ b/lib/cpp/src/windows/config.h @@ -72,6 +72,11 @@ typedef ptrdiff_t ssize_t; // Missing functions. #define usleep(ms) Sleep(ms) +inline int sleep(DWORD ms) +{ + Sleep(ms); + return 0; +} #if WINVER <= 0x0502 #define poll(fds, nfds, timeout) \ -- 2.17.1