diff options
author | Kenny Levinsen <kl@kl.wtf> | 2020-08-03 01:26:31 +0200 |
---|---|---|
committer | Kenny Levinsen <kl@kl.wtf> | 2020-08-03 02:13:47 +0200 |
commit | c35b2d2d8848957c1761fe107352fd989c3915f4 (patch) | |
tree | ba88bacd5c546a48ae4c67a8b76dd6ae39fc6905 /libseat | |
parent | d68c5feaee9b294d071c0825f5600e316c728708 (diff) |
server: Stack-allocate the server
Diffstat (limited to 'libseat')
-rw-r--r-- | libseat/backend/seatd.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/libseat/backend/seatd.c b/libseat/backend/seatd.c index 1b1523e..3edecfc 100644 --- a/libseat/backend/seatd.c +++ b/libseat/backend/seatd.c @@ -530,23 +530,28 @@ static struct libseat *builtin_open_seat(struct libseat_seat_listener *listener, return NULL; } else if (pid == 0) { int fd = fds[0]; - struct server *server = server_create(); - if (server == NULL) { - close(fd); - exit(1); + int res = 0; + struct server server = {0}; + if (server_init(&server) == -1) { + res = 1; + goto error; } - if (server_add_client(server, fd) == -1) { - exit(1); + if (server_add_client(&server, fd) == -1) { + res = 1; + goto server_error; } set_deathsig(SIGTERM); - while (server->running) { - if (poller_poll(server->poller) == -1) { - exit(1); + while (server.running) { + if (poller_poll(&server.poller) == -1) { + res = 1; + goto server_error; } } - server_destroy(server); + server_error: + server_finish(&server); + error: close(fd); - exit(0); + exit(res); } else { int fd = fds[1]; return _open_seat(listener, data, fd); |