From c37b4c5193c344d6827a197bb86c718b42d74e47 Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Wed, 5 Dec 2007 23:03:37 +0000 Subject: [PATCH] Remove unnecessary mutex from C++ socket code Summary: This is a threadsafe syscall, as it turns out. Reviewed By: hzhao Test Plan: Thrift Client C++ sockets don't lock git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665384 13f79535-47bb-0310-9956-ffa450edef68 --- lib/cpp/src/transport/TSocket.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/cpp/src/transport/TSocket.cpp b/lib/cpp/src/transport/TSocket.cpp index 0114fdcf1..2171babaf 100644 --- a/lib/cpp/src/transport/TSocket.cpp +++ b/lib/cpp/src/transport/TSocket.cpp @@ -23,7 +23,6 @@ namespace facebook { namespace thrift { namespace transport { using namespace std; -using namespace facebook::thrift::concurrency; // Global var to track total socket sys calls uint32_t g_socket_syscalls = 0; @@ -34,9 +33,6 @@ uint32_t g_socket_syscalls = 0; * @author Mark Slee */ -// Mutex to protect syscalls to netdb -static Monitor s_netdb_monitor; - TSocket::TSocket(string host, int port) : host_(host), port_(port), @@ -224,11 +220,8 @@ void TSocket::open() { hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; sprintf(port, "%d", port_); - { - // Scope lock on host entry lookup - Synchronized s(s_netdb_monitor); - error = getaddrinfo(host_.c_str(), port, &hints, &res0); - } + error = getaddrinfo(host_.c_str(), port, &hints, &res0); + if (error) { fprintf(stderr, "getaddrinfo %d: %s\n", error, gai_strerror(error)); close();