diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-07-05 22:04:31 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-07-05 22:04:31 +0200 |
commit | b0cc8047b6179bf21e563e1bdd9218c4e970cf54 (patch) | |
tree | d71299d86395d081784a04a7d9f1970d82188456 /src | |
parent | tcp_server: close client connections (diff) | |
download | cimple-b0cc8047b6179bf21e563e1bdd9218c4e970cf54.tar.gz cimple-b0cc8047b6179bf21e563e1bdd9218c4e970cf54.zip |
tcp_server: minor refactoring
Diffstat (limited to '')
-rw-r--r-- | src/tcp_server.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/tcp_server.c b/src/tcp_server.c index ca85ff2..368e8fe 100644 --- a/src/tcp_server.c +++ b/src/tcp_server.c @@ -8,6 +8,7 @@ #include "tcp_server.h" #include "compiler.h" #include "event_loop.h" +#include "file.h" #include "log.h" #include "net.h" #include "signal.h" @@ -88,7 +89,7 @@ static void client_destroy(struct client *client) SIMPLEQ_REMOVE(&client->server->client_queue, client, client, entries); pthread_errno_if(pthread_join(client->thread, NULL), "pthread_join"); - net_close(client->cleanup_fd); + file_close(client->cleanup_fd); net_close(client->conn_fd); free(client); } @@ -117,7 +118,9 @@ static void *client_thread_func(void *_client) if (ret < 0) goto cleanup; - client->server->conn_handler(client->conn_fd, client->server->conn_handler_arg); + ret = client->server->conn_handler(client->conn_fd, client->server->conn_handler_arg); + if (ret < 0) + goto cleanup; cleanup: log_errno_if(eventfd_write(client->cleanup_fd, 1), "eventfd_write"); @@ -187,7 +190,7 @@ remove_from_client_queue: SIMPLEQ_REMOVE(&server->client_queue, client, client, entries); close_cleanup_fd: - net_close(client->cleanup_fd); + file_close(client->cleanup_fd); free: free(client); |