summaryrefslogtreecommitdiffstats
path: root/daemon/udp_queue.c
diff options
context:
space:
mode:
authorVladimír Čunát <vladimir.cunat@nic.cz>2019-11-15 13:22:11 +0100
committerVladimír Čunát <vladimir.cunat@nic.cz>2019-11-19 13:29:34 +0100
commitb98f0c095d921d0aae5263745db92b46b3b5788c (patch)
tree2a73a7887b287727672672c68807cdc3ee119778 /daemon/udp_queue.c
parentMerge branch 'ci-backtraces' into 'master' (diff)
downloadknot-resolver-b98f0c095d921d0aae5263745db92b46b3b5788c.tar.xz
knot-resolver-b98f0c095d921d0aae5263745db92b46b3b5788c.zip
daemon/udp_queue: add a ref-unref pair
I must admit I don't really understand why we had a rare case of use-after-free in the sendmmsg call, but this change should avoid that without affecting anything else.
Diffstat (limited to 'daemon/udp_queue.c')
-rw-r--r--daemon/udp_queue.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/daemon/udp_queue.c b/daemon/udp_queue.c
index 586f64d9..df8acc97 100644
--- a/daemon/udp_queue.c
+++ b/daemon/udp_queue.c
@@ -103,6 +103,7 @@ static void udp_queue_send(int fd)
}
for (int i = 0; i < q->len; ++i) {
qr_task_on_send(q->items[i].task, NULL, i < sent_len ? 0 : err);
+ worker_task_unref(q->items[i].task);
}
q->len = 0;
}
@@ -129,6 +130,7 @@ void udp_queue_push(int fd, struct kr_request *req, struct qr_task *task)
kr_log_error("ERROR: called udp_queue_push(fd = %d, ...)\n", fd);
abort();
}
+ worker_task_ref(task);
/* Get a valid correct queue. */
if (fd >= state.udp_queues_len) {
const int new_len = fd + 1;