X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fmeshlink.c;h=a5d8d43121b025cf1c7b5993c93b4f464d31e675;hb=8635449a060aae62af80dad139dc06fbb9a346d9;hp=922466944cbc9391802502abedf44b05f5f02e6d;hpb=6558e508cc80ec97ec9c5bbcf7df922e13ed5b2e;p=meshlink diff --git a/src/meshlink.c b/src/meshlink.c index 92246694..a5d8d431 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -268,6 +268,11 @@ char *meshlink_get_external_address_for_family(meshlink_handle_t *mesh, int fami int s = socket_in_netns(aip->ai_family, aip->ai_socktype, aip->ai_protocol, mesh->netns); +#ifdef SO_NOSIGPIPE + int nosigpipe = 1; + setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe)); +#endif + if(s >= 0) { set_timeout(s, 5000); @@ -1461,6 +1466,7 @@ meshlink_handle_t *meshlink_open_ex(const meshlink_open_params_t *params) { assert(pthread_mutexattr_init(&attr) == 0); assert(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) == 0); assert(pthread_mutex_init(&mesh->mutex, &attr) == 0); + assert(pthread_cond_init(&mesh->cond, NULL) == 0); assert(pthread_mutex_init(&mesh->discovery_mutex, NULL) == 0); assert(pthread_cond_init(&mesh->discovery_cond, NULL) == 0); @@ -2904,6 +2910,11 @@ bool meshlink_join(meshlink_handle_t *mesh, const char *invitation) { continue; } +#ifdef SO_NOSIGPIPE + int nosigpipe = 1; + setsockopt(state.sock, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe)); +#endif + set_timeout(state.sock, 5000); if(connect(state.sock, aip->ai_addr, aip->ai_addrlen)) {