]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
write_redis plugin: Set the default timeout to one second.
authorFlorian Forster <octo@collectd.org>
Mon, 29 Jan 2024 07:24:18 +0000 (08:24 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 29 Jan 2024 07:51:02 +0000 (08:51 +0100)
This changes the behavior back to collectd 5 behavior.

src/collectd.conf.in
src/collectd.conf.pod
src/write_redis.c

index e59c7b3177664ddb86f2391598c5f54337125351..628c6370277ef0c5d1c7053638158b0107db0c6f 100644 (file)
 #              Host "localhost"
 #              Port 6379
 #              Database 0
-#              Timeout 0
+#              Timeout 1.0
 #              Retention 0 # infinite
 #              StoreRates true
 #              Prefix ""
index c9dd932e80bf09949e14764d28c46f9635a8e0d4..c4587b2e98651a1899e9c3c4623adef010812ec3 100644 (file)
@@ -11609,7 +11609,7 @@ Synopsis:
         Host "localhost"
         Port 6379
         Database 0
-        Timeout 0
+        Timeout 1.0
         Retention 0
         StoreRates true
         Prefix ""
@@ -11681,9 +11681,10 @@ to C<0>.
 
 =item B<Timeout> I<Seconds>
 
-The B<Timeout> option sets the socket connection timeout in seconds. Use
-fractional numbers to specify timeouts shorter than one second, e.g. C<0.5> for
-500 ms.
+The B<Timeout> option sets the socket connection timeout in seconds. Use zero
+to disable to connect without a timeout. Use fractional numbers to specify
+timeouts shorter than one second, e.g. C<0.5> for 500 ms. Defaults to one
+second.
 
 =item B<Retention> I<Seconds>
 
index 1b6606e7851d8fd05ce00f72f201805e99f3982f..2540792343dd777d20c3352c32db578689d20bf6 100644 (file)
@@ -34,9 +34,8 @@
 #include <hiredis/hiredis.h>
 #include <sys/time.h>
 
-#ifndef REDIS_DEFAULT_PORT
-#define REDIS_DEFAULT_PORT 6379
-#endif
+static int const default_port = 6379;
+static cdtime_t const default_timeout = TIME_T_TO_CDTIME_T(1);
 
 struct wr_node_s;
 typedef struct wr_node_s wr_node_t;
@@ -82,14 +81,13 @@ static int reconnect(wr_node_t *node) {
     ERROR("write_redis plugin: Connecting to host \"%s\" (port %i) failed: "
           "Unknown reason",
           (node->host != NULL) ? node->host : "localhost",
-          (node->port != 0) ? node->port : REDIS_DEFAULT_PORT);
+          (node->port != 0) ? node->port : default_port);
     return ENOTCONN;
   }
   if (node->conn->err) {
     ERROR("write_redis plugin: Connecting to host \"%s\" (port %i) failed: %s",
           (node->host != NULL) ? node->host : "localhost",
-          (node->port != 0) ? node->port : REDIS_DEFAULT_PORT,
-          node->conn->errstr);
+          (node->port != 0) ? node->port : default_port, node->conn->errstr);
     disconnect(node);
     return ENOTCONN;
   }
@@ -351,7 +349,8 @@ static int wr_config_node(oconfig_item_t *ci) /* {{{ */
 
   *node = (wr_node_t){
       .store_rates = true,
-      .port = REDIS_DEFAULT_PORT,
+      .port = default_port,
+      .timeout = default_timeout,
 
       .reconnect = reconnect,
       .disconnect = disconnect,