]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts: fts_indexer_input_args() - Fix client-side timeout
authorMarco Bettini <marco.bettini@open-xchange.com>
Wed, 1 Mar 2023 14:18:34 +0000 (14:18 +0000)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 22 May 2023 09:21:43 +0000 (09:21 +0000)
Client side timeout now just triggers if there is period long enough
where the server doesn't send updates. This works just because the
server is not pushing the updates properly.

The client must timeout BOTH if the server is unresponsive AND if
the server sends updates but the overall elapsed time exceedes.

src/plugins/fts/fts-indexer.c

index 79d4a4d7af543bc827fc1803c1cb137f7d78e660..4372ab8108e734044404c2946846d5a1097cc300 100644 (file)
@@ -34,6 +34,8 @@ struct fts_indexer_context {
        bool completed:1;
 };
 
+static void fts_indexer_idle_timeout(struct connection *conn);
+
 static void fts_indexer_notify(struct fts_indexer_context *ctx)
 {
        unsigned long long elapsed_msecs, est_total_msecs;
@@ -167,8 +169,14 @@ fts_indexer_input_args(struct connection *conn, const char *const *args)
                return -1;
        }
        ctx->percentage = percentage;
+       time_t elapsed = ioloop_time - ctx->search_start_time.tv_sec;
        if (ctx->percentage == 100)
                ctx->completed = TRUE;
+       else if (ctx->conn.input_idle_timeout_secs > 0 &&
+                elapsed > ctx->conn.input_idle_timeout_secs) {
+               fts_indexer_idle_timeout(&ctx->conn);
+               return -1;
+       }
        return 1;
 }