From: Vladimír Čunát Date: Fri, 12 Feb 2021 12:22:18 +0000 (+0100) Subject: daemon: pass handle when calling qr_task_on_send() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=014ae4f824d6063a40ff05c5fc8019508e21398c;p=thirdparty%2Fknot-resolver.git daemon: pass handle when calling qr_task_on_send() ... in all cases where it makes sense, on a quick look. It can be useful for error handling/logging ;-) --- diff --git a/daemon/udp_queue.c b/daemon/udp_queue.c index 0050fbaac..d2caec965 100644 --- a/daemon/udp_queue.c +++ b/daemon/udp_queue.c @@ -72,7 +72,13 @@ struct { static void udp_queue_send(int fd) { udp_queue_t *const q = state.udp_queues[fd]; - const uv_handle_t * const uv_h = NULL; // TODO: get a real value? + if (!q->len) return; + // whole queue shares `fd`, so the UV handle is the same as well + struct request_ctx *ctx = worker_task_get_request(q->items[0].task); + const uv_handle_t * const uv_h = + session_get_handle(worker_request_get_source_session(ctx)); + assert(uv_h); + for (int i = 0; i < q->len;) { // send from `i` onwards int len_done = sendmmsg(fd, q->msgvec + i, q->len - i, 0); (void)likely(len_done == q->len - i); diff --git a/daemon/worker.c b/daemon/worker.c index b13bb3911..fbcda1295 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -1283,12 +1283,13 @@ static int qr_task_finalize(struct qr_task *task, int state) task->finished = true; if (source_session == NULL) { - (void) qr_task_on_send(task, NULL, kr_error(EIO)); + (void)qr_task_on_send(task, NULL/*src_handle*/, kr_error(EIO)); return state == KR_STATE_DONE ? kr_ok() : kr_error(EIO); } + const uv_handle_t *src_handle = session_get_handle(source_session); if (unlikely(ctx->req.answer == NULL)) { /* meant to be dropped */ - (void) qr_task_on_send(task, NULL, kr_ok()); + (void)qr_task_on_send(task, src_handle, kr_ok()); return kr_ok(); } @@ -1301,7 +1302,6 @@ static int qr_task_finalize(struct qr_task *task, int state) /* Send back answer */ int ret; - const uv_handle_t *src_handle = session_get_handle(source_session); if (src_handle->type != UV_UDP && src_handle->type != UV_TCP && src_handle->type != UV_POLL) { assert(false); @@ -1322,7 +1322,7 @@ static int qr_task_finalize(struct qr_task *task, int state) } if (ret != kr_ok()) { - (void) qr_task_on_send(task, NULL, kr_error(EIO)); + (void)qr_task_on_send(task, src_handle, kr_error(EIO)); /* Since source session is erroneous detach all tasks. */ while (!session_tasklist_is_empty(source_session)) { struct qr_task *t = session_tasklist_del_first(source_session, false);