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 2b68e88..63e8918 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) {