]> git.meshlink.io Git - meshlink/commitdiff
Fix deadlock during discovery failure
authorsairoop-elear <sairoop@elear.solutions>
Fri, 6 Sep 2019 10:36:16 +0000 (16:06 +0530)
committerGuus Sliepen <guus@meshlink.io>
Mon, 9 Sep 2019 19:25:23 +0000 (21:25 +0200)
src/discovery.c

index 9064523c9c603222cd2e55bd8736a56c1f712ec5..481b2f2872f22675d909924fea9b61d89f342189 100644 (file)
@@ -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);