diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-20 12:53:25 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-20 12:53:25 +0200 |
commit | e11014c0443ea687ad65a14b9124aa366da7984a (patch) | |
tree | 8c6642ed187dc71cc672cec9f3459aa75134eaa5 /idle.c | |
parent | fc25e880dfb1f804742006bcdd15ac70d18b4144 (diff) |
Introduce helper for checking if a task is dead
Diffstat (limited to 'idle.c')
-rw-r--r-- | idle.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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); |