aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-07-07 15:44:52 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-07-07 15:53:37 +0200
commit6fb2fd3dac7316f7155437d350ab372ed248b866 (patch)
tree40f4e7cbdfb03e2357e782e4f551c5f93ad54751 /src
parentsqlite: minor refactoring (diff)
downloadcimple-6fb2fd3dac7316f7155437d350ab372ed248b866.tar.gz
cimple-6fb2fd3dac7316f7155437d350ab372ed248b866.zip
server: fix a possible leak
Diffstat (limited to '')
-rw-r--r--src/server.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/server.c b/src/server.c
index 2fbb13c..da9cfc3 100644
--- a/src/server.c
+++ b/src/server.c
@@ -13,6 +13,7 @@
#include "file.h"
#include "log.h"
#include "msg.h"
+#include "net.h"
#include "process.h"
#include "protocol.h"
#include "run_queue.h"
@@ -235,11 +236,12 @@ static int server_handle_cmd_new_worker(UNUSED const struct msg *request,
if (ret < 0)
return ret;
+ const int fd = ret;
struct worker *worker = NULL;
- ret = worker_create(&worker, ret);
+ ret = worker_create(&worker, fd);
if (ret < 0)
- return ret;
+ goto close;
ret = server_enqueue_worker(server, worker);
if (ret < 0)
@@ -250,6 +252,9 @@ static int server_handle_cmd_new_worker(UNUSED const struct msg *request,
destroy_worker:
worker_destroy(worker);
+close:
+ net_close(fd);
+
return ret;
}