From: Arran Cudbard-Bell Date: Sat, 16 Mar 2024 20:02:16 +0000 (-0400) Subject: Allow command timeout to be set X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7c045d27ba4f98710bd09b5bf6f0ffc40f50676;p=thirdparty%2Ffreeradius-server.git Allow command timeout to be set --- diff --git a/src/lib/redis/base.h b/src/lib/redis/base.h index ea3061098c4..63bf5b53d5f 100644 --- a/src/lib/redis/base.h +++ b/src/lib/redis/base.h @@ -28,6 +28,8 @@ */ RCSIDH(redis_h, "$Id$") +#include + #include #include #include @@ -121,6 +123,9 @@ typedef struct { uint32_t max_retries; //!< Maximum number of times we attempt a command //!< when receiving successive -TRYAGAIN messages. uint32_t max_alt; //!< Maximum alternative nodes to try. + + fr_time_delta_t command_timeout; //!< How long to wait for commands to return. + fr_time_delta_t retry_delay; //!< How long to wait when we received a -TRYAGAIN //!< message. fr_time_delta_t connection_timeout; @@ -140,7 +145,8 @@ typedef struct { { FR_CONF_OFFSET_FLAGS("password", CONF_FLAG_SECRET, fr_redis_conf_t, password) }, \ { FR_CONF_OFFSET("max_nodes", fr_redis_conf_t, max_nodes), .dflt = "20" }, \ { FR_CONF_OFFSET("max_alt", fr_redis_conf_t, max_alt), .dflt = "3" }, \ - { FR_CONF_OFFSET("max_redirects", fr_redis_conf_t, max_redirects), .dflt = "2" } + { FR_CONF_OFFSET("max_redirects", fr_redis_conf_t, max_redirects), .dflt = "2" }, \ + { FR_CONF_OFFSET("command_timeout", fr_redis_conf_t, reconnection_delay), .dflt = "0" } void fr_redis_version_print(void); diff --git a/src/lib/redis/cluster.c b/src/lib/redis/cluster.c index 0f86002214f..9f99c401b06 100644 --- a/src/lib/redis/cluster.c +++ b/src/lib/redis/cluster.c @@ -1481,6 +1481,13 @@ void *fr_redis_cluster_conn_create(TALLOC_CTX *ctx, void *instance, fr_time_delt return NULL; } + /* + * Sets a timeout for synchronous command evaluation + */ + if (fr_time_delta_cmp(node->cluster->conf->command_timeout, fr_time_delta_from_sec(0)) != 0) { + redisSetTimeout(handle, fr_time_delta_to_timeval(node->cluster->conf->command_timeout)); + } + conn = talloc_zero(ctx, fr_redis_conn_t); conn->handle = handle; conn->node = node;