X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_redis.c;h=cdea3060023b462df6b7bdb0d40d0a64fad02b78;hb=dd09c9364998ad6ef681b70f45f7a9734808cf96;hp=da5b7bbe8ba1ffa84ddae9ab8e2fc5325c7a69ad;hpb=dab48f284f9d4bb6ae98244310c5cdb6c5d91bf3;p=collectd.git diff --git a/src/write_redis.c b/src/write_redis.c index da5b7bbe..cdea3060 100644 --- a/src/write_redis.c +++ b/src/write_redis.c @@ -73,16 +73,17 @@ static int wr_write (const data_set_t *ds, /* {{{ */ value_size = sizeof (value); value_ptr = &value[0]; status = format_values (value_ptr, value_size, ds, vl, /* store rates = */ 0); - pthread_mutex_lock (&node->lock); if (status != 0) return (status); + pthread_mutex_lock (&node->lock); + if (node->conn == NULL) { node->conn = redisConnectWithTimeout ((char *)node->host, node->port, node->timeout); if (node->conn == NULL) { - ERROR ("write_redis plugin: Connecting to host \"%s\" (port %i) failed: Unkown reason", + ERROR ("write_redis plugin: Connecting to host \"%s\" (port %i) failed: Unknown reason", (node->host != NULL) ? node->host : "localhost", (node->port != 0) ? node->port : 6379); pthread_mutex_unlock (&node->lock);