diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-11 12:28:34 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-11 12:28:34 +0200 |
commit | c07081da8f8faa400e28c3febcfb38430ec5d0ad (patch) | |
tree | 1d586a42fc9e10c342fd55b304b1dcd95573f28d | |
parent | 5bb6e86e0747ce57ab2033d1b878c49d0035dc00 (diff) |
Make sure idle closes the fd once it's done
-rw-r--r-- | idle.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -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; } |