From 55cbe043e23dc2e8ed8b398034cd16b0156bba70 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Tue, 4 Aug 2020 01:43:55 +0200 Subject: server: Gracefully shut down on error --- seatd/server.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/seatd/server.c b/seatd/server.c index 354d6a5..799fda0 100644 --- a/seatd/server.c +++ b/seatd/server.c @@ -120,9 +120,10 @@ static int set_nonblock(int fd) { static int server_handle_connection(int fd, uint32_t mask, void *data) { struct server *server = data; if (mask & (EVENT_ERROR | EVENT_HANGUP)) { - close(fd); + shutdown(fd, SHUT_RDWR); + server->running = false; log_errorf("server socket recieved an error: %s", strerror(errno)); - exit(1); + return -1; } if (mask & EVENT_READABLE) { -- cgit v1.2.3