summaryrefslogtreecommitdiff
path: root/idle.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-20 12:53:25 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-20 12:53:25 +0200
commite11014c0443ea687ad65a14b9124aa366da7984a (patch)
tree8c6642ed187dc71cc672cec9f3459aa75134eaa5 /idle.c
parentfc25e880dfb1f804742006bcdd15ac70d18b4144 (diff)
Introduce helper for checking if a task is dead
Diffstat (limited to 'idle.c')
-rw-r--r--idle.c13
1 files changed, 9 insertions, 4 deletions
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);