From e11014c0443ea687ad65a14b9124aa366da7984a Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Sat, 20 Jun 2020 12:53:25 +0200 Subject: Introduce helper for checking if a task is dead --- idle.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'idle.c') diff --git a/idle.c b/idle.c index 5f7ed17..3be8974 100644 --- a/idle.c +++ b/idle.c @@ -121,6 +121,8 @@ idle_check_handshake_complete(struct cfg *cfg, struct uring_task *task, int res) int32_t mclen; int r; + assert_task_alive_or(DBG_IDLE, task, return -EINTR); + remain = task->tbuf->len; pos = task->tbuf->buf; @@ -195,6 +197,8 @@ idle_check_handshake_reply(struct cfg *cfg, struct uring_task *task, int res) int player_count; int r; + assert_task_alive(DBG_IDLE, task); + debug(DBG_IDLE, "res: %i\n", res); if (res < 0) goto out; @@ -277,6 +281,8 @@ idle_check_handshake_sent(struct cfg *cfg, struct uring_task *task, int res) { struct idle *idle = container_of(task, struct idle, idlecheck); + assert_task_alive(DBG_IDLE, task); + debug(DBG_IDLE, "sent %i bytes\n", res); if (res < 0) { uring_task_close_fd(cfg, task); @@ -298,6 +304,8 @@ idle_check_connected_cb(struct cfg *cfg, struct connection *conn, bool connected uint16_t port; char hostname[INET6_ADDRSTRLEN]; + assert_task_alive(DBG_IDLE, &idle->idlecheck); + if (!connected) { debug(DBG_IDLE, "idle check connection to remote server (%s) failed\n", @@ -337,10 +345,7 @@ idle_cb(struct cfg *cfg, struct uring_task *task, int res) { struct idle *idle = container_of(task, struct idle, task); - if (task->dead) { - debug(DBG_IDLE, "task is dead\n"); - return; - } + assert_task_alive(DBG_IDLE, task); if (res != sizeof(idle->value)) { error("timerfd_read returned %i\n", res); -- cgit v1.2.3