mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
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:
parent
0b298f6ca1
commit
648e15bcf7
34 changed files with 360 additions and 235 deletions
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "util/rsnet.h"
|
||||
#include "util/rsthreads.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
|
@ -148,3 +149,16 @@ std::ostream &operator<<(std::ostream &out, const struct sockaddr_in &addr)
|
|||
return out;
|
||||
}
|
||||
|
||||
|
||||
/* thread-safe version of inet_ntoa */
|
||||
|
||||
static RsMutex inetMtx;
|
||||
|
||||
std::string rs_inet_ntoa(struct in_addr in)
|
||||
{
|
||||
RsStackMutex stack(inetMtx);
|
||||
|
||||
std::string addr(inet_ntoa(in));
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,4 +76,8 @@ bool getIPAddressFromString (const char *addr_str, struct in_addr *addr);
|
|||
|
||||
std::ostream& operator<<(std::ostream& o,const struct sockaddr_in&) ;
|
||||
|
||||
/* thread-safe version of inet_ntoa */
|
||||
std::string rs_inet_ntoa(struct in_addr in);
|
||||
|
||||
|
||||
#endif /* RS_UNIVERSAL_NETWORK_HEADER */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue