You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2016/07/24 17:11:32 UTC
[2/2] thrift git commit: THRIFT-2156: fix errno handling in server
socket Client: C++ Patch: Jens Geyer
THRIFT-2156: fix errno handling in server socket
Client: C++
Patch: Jens Geyer
This closes #1055
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/bcad9177
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/bcad9177
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/bcad9177
Branch: refs/heads/master
Commit: bcad91771b7f0bff28a1cac1981d7ef2b9bcef3c
Parents: e517624
Author: Jens Geyer <je...@apache.org>
Authored: Sun Jul 24 12:11:25 2016 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Sun Jul 24 19:10:55 2016 +0200
----------------------------------------------------------------------
lib/cpp/src/thrift/transport/TServerSocket.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/bcad9177/lib/cpp/src/thrift/transport/TServerSocket.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp
index b3d8898..c233e69 100644
--- a/lib/cpp/src/thrift/transport/TServerSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp
@@ -276,15 +276,16 @@ void TServerSocket::listen() {
throw TTransportException(TTransportException::BAD_ARGS, "Specified port is invalid");
}
- struct addrinfo hints;
const struct addrinfo *res;
int error;
char port[sizeof("65535")];
+ snprintf(port, sizeof(port), "%d", port_);
+
+ struct addrinfo hints;
std::memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
- snprintf(port, sizeof("65535"), "%d", port_);
// If address is not specified use wildcard address (NULL)
TGetAddrInfoWrapper info(address_.empty() ? NULL : &address_[0], port, &hints);
@@ -523,9 +524,9 @@ void TServerSocket::listen() {
if (retries > retryLimit_) {
char errbuf[1024];
if (!path_.empty()) {
- snprintf(errbuf, 1024, "TServerSocket::listen() PATH %s", path_.c_str());
+ snprintf(errbuf, sizeof(errbuf), "TServerSocket::listen() PATH %s", path_.c_str());
} else {
- snprintf(errbuf, 1024, "TServerSocket::listen() BIND %d", port_);
+ snprintf(errbuf, sizeof(errbuf), "TServerSocket::listen() BIND %d", port_);
}
GlobalOutput(errbuf);
close();