From c07081da8f8faa400e28c3febcfb38430ec5d0ad Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Thu, 11 Jun 2020 12:28:34 +0200 Subject: Make sure idle closes the fd once it's done --- idle.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'idle.c') diff --git a/idle.c b/idle.c index 46be539..3fddf79 100644 --- a/idle.c +++ b/idle.c @@ -199,7 +199,7 @@ idle_check_handshake_reply(struct cfg *cfg, struct uring_task *task, int res) fprintf(stderr, "%s: received %i bytes\n", __func__, res); if (res < 0) - goto error; + goto out; /* fprintf(stderr, "Received MC message (%i bytes):\n", res); @@ -215,7 +215,7 @@ idle_check_handshake_reply(struct cfg *cfg, struct uring_task *task, int res) if (r <= 0 || mclen < 2 || mclen < remain) { /* Should not happen since the msg has been checked already */ fprintf(stderr, "Invalid message\n"); - goto error; + goto out; } fprintf(stderr, "%s: MC message len: %" PRIi32 "\n", __func__, mclen); @@ -223,7 +223,7 @@ idle_check_handshake_reply(struct cfg *cfg, struct uring_task *task, int res) if (*pos != MC_STATUS_REPLY) { fprintf(stderr, "Unknown server reply\n"); - goto error; + goto out; } pos++; @@ -232,7 +232,7 @@ idle_check_handshake_reply(struct cfg *cfg, struct uring_task *task, int res) r = read_varint(&pos, &remain, &jsonlen); if (r <= 0) { fprintf(stderr, "Could not read JSON length\n"); - goto error; + goto out; } fprintf(stderr, "MC json len: %" PRIi32 "\n", jsonlen); @@ -240,7 +240,7 @@ idle_check_handshake_reply(struct cfg *cfg, struct uring_task *task, int res) if (jsonlen < remain) { fprintf(stderr, "Invalid JSON length\n"); - goto error; + goto out; } fprintf(stderr, "JSON: "); @@ -252,7 +252,7 @@ idle_check_handshake_reply(struct cfg *cfg, struct uring_task *task, int res) fprintf(stderr, "We have %i players\n", player_count); if (player_count < 0) - goto error; + goto out; else if (player_count > 0) idle->server->idle_count = 0; else { @@ -263,9 +263,7 @@ idle_check_handshake_reply(struct cfg *cfg, struct uring_task *task, int res) } } - return; - -error: +out: uring_task_close_fd(cfg, task); return; } -- cgit v1.2.3