Code

write_riemann: avoid deadlock on connection failures
authorPierre-Yves Ritschard <pyr@spootnik.org>
Wed, 13 Apr 2016 20:17:57 +0000 (22:17 +0200)
committerPierre-Yves Ritschard <pyr@spootnik.org>
Wed, 13 Apr 2016 20:17:57 +0000 (22:17 +0200)
src/write_riemann.c

index 2b68e883b400ddf4d9c5cb19002dde60c89a9e83..63e89186cb3eb45a7a741304d0745851b0886317 100644 (file)
@@ -135,8 +135,10 @@ static int wrr_send(struct riemann_host *host, riemann_message_t *msg) /* {{{ */
        pthread_mutex_lock (&host->lock);
 
        status = wrr_connect(host);
-       if (status != 0)
+       if (status != 0) {
+        pthread_mutex_unlock(&host->lock);
                return status;
+    }
 
        status = riemann_client_send_message(host->client, msg);
        if (status != 0) {