diff options
Diffstat (limited to 'rcon.c')
-rw-r--r-- | rcon.c | 29 |
1 files changed, 12 insertions, 17 deletions
@@ -8,6 +8,7 @@ #include <arpa/inet.h> #include <stdint.h> #include <inttypes.h> +#include <errno.h> #include "main.h" #include "uring.h" @@ -123,7 +124,8 @@ enum rcon_packet_type { }; static void -create_packet(struct cfg *cfg, struct rcon *rcon, int32_t reqid, enum rcon_packet_type type, const char *msg) +create_packet(struct cfg *cfg, struct rcon *rcon, int32_t reqid, + enum rcon_packet_type type, const char *msg) { char *pos = &rcon->tbuf.buf[4]; @@ -150,6 +152,8 @@ packet_complete(struct cfg *cfg, struct uring_task *task, int res) size_t len = task->tbuf->len; int32_t plen; + assert_task_alive_or(DBG_RCON, task, return -EINTR); + if (task->tbuf->len < 14) return 0; @@ -212,10 +216,7 @@ rcon_stop_reply(struct cfg *cfg, struct uring_task *task, int res) int32_t type; char *msg; - if (task->dead) { - debug(DBG_RCON, "task dead\n"); - return; - } + assert_task_alive(DBG_RCON, task); if (res < 0) { debug(DBG_RCON, "res: %i\n", res); @@ -244,10 +245,7 @@ rcon_stop_sent(struct cfg *cfg, struct uring_task *task, int res) { struct rcon *rcon = container_of(task, struct rcon, task); - if (task->dead) { - debug(DBG_RCON, "task dead\n"); - return; - } + assert_task_alive(DBG_RCON, task); if (res < 0) { debug(DBG_RCON, "res: %i\n", res); @@ -267,10 +265,7 @@ rcon_login_reply(struct cfg *cfg, struct uring_task *task, int res) int32_t type; char *msg; - if (task->dead) { - debug(DBG_RCON, "task dead\n"); - return; - } + assert_task_alive(DBG_RCON, task); if (res < 0) { debug(DBG_RCON, "res: %i\n", res); @@ -305,10 +300,7 @@ rcon_login_sent(struct cfg *cfg, struct uring_task *task, int res) { struct rcon *rcon = container_of(task, struct rcon, task); - if (task->dead) { - debug(DBG_RCON, "task dead\n"); - return; - } + assert_task_alive(DBG_RCON, task); if (res < 0) { debug(DBG_RCON, "res: %i\n", res); @@ -325,9 +317,12 @@ rcon_connected_cb(struct cfg *cfg, struct connection *conn, bool connected) { struct rcon *rcon = container_of(conn, struct rcon, conn); + assert_task_alive(DBG_RCON, &rcon->task); + if (!connected) { error("rcon connection to remote server (%s) failed\n", rcon->server->name); + uring_task_put(cfg, &rcon->task); return; } |