From: sairoop-elear Date: Fri, 6 Sep 2019 10:36:16 +0000 (+0530) Subject: Fix deadlock during discovery failure X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=93a7614d2aa368a9799d6e39c73542a3998e70bf;p=meshlink Fix deadlock during discovery failure --- diff --git a/src/discovery.c b/src/discovery.c index 9064523c..481b2f28 100644 --- a/src/discovery.c +++ b/src/discovery.c @@ -341,6 +341,7 @@ static void discovery_log_cb(CattaLogLevel level, const char *txt) { } static void *discovery_loop(void *userdata) { + bool status = false; meshlink_handle_t *mesh = userdata; assert(mesh != NULL); @@ -397,13 +398,17 @@ static void *discovery_loop(void *userdata) { goto fail; } + status = true; + +fail: + pthread_mutex_lock(&mesh->discovery_mutex); pthread_cond_broadcast(&mesh->discovery_cond); pthread_mutex_unlock(&mesh->discovery_mutex); - catta_simple_poll_loop(mesh->catta_poll); - -fail: + if(status) { + catta_simple_poll_loop(mesh->catta_poll); + } if(mesh->catta_browser != NULL) { catta_s_service_browser_free(mesh->catta_browser);