mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 10:48:51 +00:00
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
This commit is contained in:
parent
2323cf6422
commit
c37b4c5193
@ -23,7 +23,6 @@
|
|||||||
namespace facebook { namespace thrift { namespace transport {
|
namespace facebook { namespace thrift { namespace transport {
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace facebook::thrift::concurrency;
|
|
||||||
|
|
||||||
// Global var to track total socket sys calls
|
// Global var to track total socket sys calls
|
||||||
uint32_t g_socket_syscalls = 0;
|
uint32_t g_socket_syscalls = 0;
|
||||||
@ -34,9 +33,6 @@ uint32_t g_socket_syscalls = 0;
|
|||||||
* @author Mark Slee <mcslee@facebook.com>
|
* @author Mark Slee <mcslee@facebook.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Mutex to protect syscalls to netdb
|
|
||||||
static Monitor s_netdb_monitor;
|
|
||||||
|
|
||||||
TSocket::TSocket(string host, int port) :
|
TSocket::TSocket(string host, int port) :
|
||||||
host_(host),
|
host_(host),
|
||||||
port_(port),
|
port_(port),
|
||||||
@ -224,11 +220,8 @@ void TSocket::open() {
|
|||||||
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
|
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
|
||||||
sprintf(port, "%d", port_);
|
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) {
|
if (error) {
|
||||||
fprintf(stderr, "getaddrinfo %d: %s\n", error, gai_strerror(error));
|
fprintf(stderr, "getaddrinfo %d: %s\n", error, gai_strerror(error));
|
||||||
close();
|
close();
|
||||||
|
Loading…
Reference in New Issue
Block a user