X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fmeshlink.c;h=d0b8bef5d7c6ee46533069baf865939610070887;hb=a5df8a6eac570fc0f3b10cfcdeb9ccccc8dd1ac1;hp=922466944cbc9391802502abedf44b05f5f02e6d;hpb=6558e508cc80ec97ec9c5bbcf7df922e13ed5b2e;p=meshlink diff --git a/src/meshlink.c b/src/meshlink.c index 92246694..d0b8bef5 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)) { @@ -4294,6 +4305,7 @@ void handle_network_change(meshlink_handle_t *mesh, bool online) { } retry(mesh); + signal_trigger(&mesh->loop, &mesh->datafromapp); } void call_error_cb(meshlink_handle_t *mesh, meshlink_errno_t cb_errno) {