Found cause of OSX network resets / lost connections: inet_ntoa is not thread-safe.

* Added thread-safe rs_inet_ntoa function (util/rsnet.cc)
 * Switched all calls to this function (most of the changes)
 * Modified getLocalInterfaces() and getPreferredInterface() to avoid string conversions.
   - NB: Modified windows functions too, but unable to test (hope it compiles!)

Also:
 * Added  EVP_CIPHER_CTX_rand_key() replacement function for old versions of SSL (pre 0.9.8)  (for OSX 10.5)
   - NB: This code should be reworked to remove these calls anyway.
 * Updated tests/pqi to handle above changes.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3281 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2010-07-10 20:34:03 +00:00
parent 0b298f6ca1
commit 648e15bcf7
34 changed files with 360 additions and 235 deletions

View file

@ -30,7 +30,7 @@ std::ostream &operator<<(std::ostream &out, dhtentry &ent)
{
out << "DHTENTRY(" << ent.id << "): Status: " << ent.status;
out << std::endl;
out << "\taddr: " << inet_ntoa(ent.addr.sin_addr) << ":" << ntohs(ent.addr.sin_port);
out << "\taddr: " << rs_inet_ntoa(ent.addr.sin_addr) << ":" << ntohs(ent.addr.sin_port);
out << std::endl;
out << "\tlastTS: " << time(NULL) - ent.lastTs << " secs ago";
out << "\tFlags: " << ent.flags;
@ -522,8 +522,9 @@ int dhthandler::publishOwnId()
/* to store the ip address and flags */
char metalist[1024];
std::string addr = rs_inet_ntoa(ownId.addr.sin_addr),
sprintf(metalist, "rsid=%s:%d;flags=%04X;",
inet_ntoa(ownId.addr.sin_addr),
addr.c_str(),
ntohs(ownId.addr.sin_port),
ownId.flags);

View file

@ -573,7 +573,7 @@ bool OpenDHTClient::openDHT_sendMessage(std::string msg, std::string &response)
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_sendMessage()";
std::cerr << " Connecting to:" << host << ":" << port;
std::cerr << " (" << inet_ntoa(addr.sin_addr) << ":" << ntohs(addr.sin_port) << ")";
std::cerr << " (" << rs_inet_ntoa(addr.sin_addr) << ":" << ntohs(addr.sin_port) << ")";
std::cerr << std::endl;
#endif
@ -724,7 +724,7 @@ bool OpenDHTClient::openDHT_getDHTList(std::string &response)
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_getDHTList()";
std::cerr << " Connecting to:" << host << ":" << port;
std::cerr << " (" << inet_ntoa(addr.sin_addr) << ":" << ntohs(addr.sin_port) << ")";
std::cerr << " (" << rs_inet_ntoa(addr.sin_addr) << ":" << ntohs(addr.sin_port) << ")";
std::cerr << std::endl;
#endif