conga luci/conga_ssl/conga_ssl_lib.cpp ricci/c ...
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-03-21 20:12:58
Modified files:
luci/conga_ssl : conga_ssl_lib.cpp
ricci/common : ClientSocket.cpp Socket.cpp Time.cpp
ricci/include : Socket.h
ricci/ricci : Ricci.cpp
Log message:
- Make the socket connection in the python SSL bindings non-blocking
- This fixes a bug that could hang the luci server for around 5 minutes at a time
- Use gethostbyname_r instead of gethostbyname
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/conga_ssl/conga_ssl_lib.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/ClientSocket.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Socket.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Time.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/Socket.h.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Ricci.cpp.diff?cvsroot=cluster&r1=1.22&r2=1.23
luci/conga_ssl/conga_ssl_lib.cpp +1 -1
@@ -133,7 +133,7 @@ counting_auto_ptr<SSLClient> ss; { PythonThreadsAllower all; - ClientSocket sock(hostname, port); + ClientSocket sock(hostname, port, timeout * 1000); ss = counting_auto_ptr<SSLClient>(new SSLClient(sock)); ss->connect(timeout * 1000); }
ricci/common/ClientSocket.cpp +62 -3
87 lines not on this page · raw message
ricci/common/Socket.cpp +11 -2
@@ -1,5 +1,5 @@ /* - Copyright Red Hat, Inc. 2005 + Copyright Red Hat, Inc. 2005-2007 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
@@ -189,7 +189,16 @@ { char buff[INET_ADDRSTRLEN+1]; std::vector<String> addrs; - struct hostent* ent = gethostbyname2(hostname.c_str(), AF_INET); + char hostbuf[2048]; + struct hostent hostent_result; + struct hostent *ent; + int ret; + + if (gethostbyname2_r(hostname.c_str(), AF_INET, &hostent_result, + hostbuf, sizeof(hostbuf), + &ent, &ret)) + return addrs; + if (!ent) return addrs; char** addrs_b = ent->h_addr_list;
ricci/common/Time.cpp +3 -5
@@ -1,5 +1,5 @@ /* - Copyright Red Hat, Inc. 2005 + Copyright Red Hat, Inc. 2005-2007 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
@@ -31,8 +31,7 @@ time_sec() { struct timeval t; - struct timezone z; - gettimeofday(&t, &z); + gettimeofday(&t, NULL); return t.tv_sec; }
@@ -40,8 +39,7 @@ time_mil() { struct timeval t; - struct timezone z; - gettimeofday(&t, &z); + gettimeofday(&t, NULL); return t.tv_sec*1000 + t.tv_usec/1000; }
ricci/include/Socket.h +1 -0
@@ -74,6 +74,7 @@ClientSocket (); ClientSocket(const String& sock_path); // UNIX socket ClientSocket(const String& hostname, unsigned short port); // TCP socket + ClientSocket(const String& hostname, unsigned short port, unsigned int to_ms); ClientSocket(const ClientSocket&); ClientSocket& operator= (const ClientSocket&); virtual ~ClientSocket();
ricci/ricci/Ricci.cpp +11 -4
@@ -466,11 +466,18 @@ char name[1024]; if (gethostname(name, sizeof(name))) return ""; - struct hostent *ent = gethostbyname(name); - if (ent) - return String(ent->h_name); - else + + char hostbuf[2048]; + struct hostent hostent_result; + struct hostent *ent = NULL; + int ret = 0; + + if (gethostbyname_r(name, &hostent_result, + hostbuf, sizeof(hostbuf), + &ent, &ret) || !ent) return name; + + return String(ent->h_name); } pair<String, String>