]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
redis: fix timeout conflict with TLS resulting in NULL reply
authorDaniel Salzman <daniel.salzman@nic.cz>
Sun, 9 Nov 2025 19:33:20 +0000 (20:33 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Wed, 26 Nov 2025 14:49:47 +0000 (15:49 +0100)
src/knot/server/server.c

index 7c0503c11d3e8cc5eeb86d28b1c6ddc0a49aee65..2a53074761973e14ed108221c3c003530d1f609f 100644 (file)
@@ -942,7 +942,7 @@ static int rdb_listener_run(struct dthread *thread)
                if (s->rdb_ctx == NULL) {
                        s->rdb_ctx = rdb_connect(conf(), false);
                        if (s->rdb_ctx == NULL) {
-                               log_error("rdb, failed to connect");
+                               log_error("rdb, failed to connect to read events");
                                sleep(2);
                                continue;
                        } else if (!rdb_compatible(s->rdb_ctx)) {
@@ -951,8 +951,9 @@ static int rdb_listener_run(struct dthread *thread)
                        }
                }
 
+               // Note the timeout should be lower than the TLS timeout (see hiredis_attach_gnutls())
                redisReply *reply = redisCommand(s->rdb_ctx, "XREAD BLOCK %d STREAMS %b %s",
-                                                10000, RDB_EVENT_KEY, strlen(RDB_EVENT_KEY), since);
+                                                4000, RDB_EVENT_KEY, strlen(RDB_EVENT_KEY), since);
                if (reply == NULL) {
                        if (thread->state & ThreadDead) {
                                break;
@@ -960,6 +961,8 @@ static int rdb_listener_run(struct dthread *thread)
                        if (s->rdb_ctx->err != REDIS_OK) {
                                log_error("rdb, failed to read events (%s)", s->rdb_ctx->errstr);
                        }
+                       rdb_disconnect(s->rdb_ctx, false);
+                       s->rdb_ctx = NULL;
                        sleep(2);
                        continue;
                }