]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/worker: improved server-side error handling
authorGrigorii Demidov <grigorii.demidov@nic.cz>
Fri, 27 Apr 2018 11:54:21 +0000 (13:54 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Wed, 9 May 2018 12:58:02 +0000 (14:58 +0200)
daemon/worker.c

index fd9c6c0b0fe52a8ce5ab222711ef15d3f706c434..adf4c4f64f378628a0a7c56b0f014a4bd7ee4de0 100644 (file)
@@ -1520,6 +1520,18 @@ static int qr_task_finalize(struct qr_task *task, int state)
                                ctx->req.answer);
        if (res != kr_ok()) {
                (void) qr_task_on_send(task, NULL, kr_error(EIO));
+               /* Since source session is erroneous detach all tasks. */
+               while (source_session->tasks.len > 0) {
+                       struct qr_task *t = source_session->tasks.at[0];
+                       struct request_ctx *c = t->ctx;
+                       assert(c->source.session == source_session);
+                       c->source.session = NULL;
+                       /* Don't finalize them as there can be other tasks
+                        * waiting for answer to this particular task.
+                        * (ie. task->leading is true) */
+                       session_del_tasks(source_session, t);
+               }
+               session_close(source_session);
        } else if (handle->type == UV_TCP) {
                /* Don't try to close source session at least
                 * retry_interval_for_timeout_timer milliseconds */