]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
worker: fixed infinite loop on send failure
authorMarek Vavruša <mvavrusa@cloudflare.com>
Sat, 14 Apr 2018 04:18:42 +0000 (21:18 -0700)
committerMarek Vavruša <mvavrusa@cloudflare.com>
Sat, 14 Apr 2018 04:22:25 +0000 (21:22 -0700)
The problem here is when qr_task_send() returns an error, the
following error handler will attempt to cancel all tasks that were
started on the same connection, but that will only work for the first
task (which is finished), the qr_task_on_send() will have no effect
on tasks in progress as the passed handle is NULL, and the task->finished
is false, thus looping infinitely.

The solution here is to let the rest of the tasks complete, even though
sending answer back will fail (which is fine).

daemon/worker.c

index 5ee02fa082de30f6eea8e844891936b8ce567470..4392dbd001dd72527d3cebb3b038eedce31f5604 100644 (file)
@@ -1528,11 +1528,7 @@ static int qr_task_finalize(struct qr_task *task, int state)
                               (struct sockaddr *)&ctx->source.addr,
                                ctx->req.answer);
        if (res != kr_ok()) {
-               while (source_session->tasks.len > 0) {
-                       struct qr_task *t = source_session->tasks.at[0];
-                       (void) qr_task_on_send(t, NULL, kr_error(EIO));
-               }
-               session_close(source_session);
+               (void) qr_task_on_send(task, NULL, kr_error(EIO));
        } else if (handle->type == UV_TCP) {
                /* Don't try to close source session at least
                 * retry_interval_for_timeout_timer milliseconds */