diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-05-24 18:02:49 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-05-24 18:02:49 +0200 |
commit | a8416237f30f77c5e78b06a58298442245911fb5 (patch) | |
tree | 41cf60471ebdc9d0fc07c324384b83748847d16b | |
parent | d8a545695458635a45bf179413e8e3824f76cba0 (diff) |
POTD skeleton #79.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | src/pevent.c | 2 | ||||
-rw-r--r-- | src/redirector.c | 3 | ||||
-rw-r--r-- | src/socket.h | 2 | ||||
-rw-r--r-- | src/utils.c | 3 |
4 files changed, 8 insertions, 2 deletions
diff --git a/src/pevent.c b/src/pevent.c index 60a954d..ddb5a03 100644 --- a/src/pevent.c +++ b/src/pevent.c @@ -23,6 +23,8 @@ void event_init(event_ctx **ctx) void event_free(event_ctx **ctx) { + assert(ctx && *ctx); + close((*ctx)->epoll_fd); free((*ctx)); *ctx = NULL; diff --git a/src/redirector.c b/src/redirector.c index 7e589f7..d4d8d41 100644 --- a/src/redirector.c +++ b/src/redirector.c @@ -175,9 +175,10 @@ pid_t redirector_daemonize(event_ctx *ev_ctx, redirector_ctx *rdr_ctx[], size_t } N("%s", "Server daemon mainloop"); redirector_mainloop(ev_ctx, rdr_ctx, siz); - break; } D2("Server daemon pid: %d", p); + + event_free(&ev_ctx); for (i = 0; i < siz; ++i) redirector_free_ctx(&rdr_ctx[i]); diff --git a/src/socket.h b/src/socket.h index ebd78d8..2698ee2 100644 --- a/src/socket.h +++ b/src/socket.h @@ -3,7 +3,7 @@ #include <netdb.h> -#define POTD_BACKLOG 8 +#define POTD_BACKLOG 1 typedef struct psocket { int fd; diff --git a/src/utils.c b/src/utils.c index 9abdff4..6c9873b 100644 --- a/src/utils.c +++ b/src/utils.c @@ -52,6 +52,8 @@ int set_fd_nonblock(int fd) static void sighandler_child(int signo) { switch (signo) { + case SIGABRT: + exit(EXIT_FAILURE); case SIGHUP: if (getppid() == 1) { N("Master process %d died, exiting", getpgrp()); @@ -70,6 +72,7 @@ int set_child_sighandler(void) return 1; assert( signal(SIGCHLD, SIG_IGN) != SIG_ERR ); assert( signal(SIGPIPE, SIG_IGN) != SIG_ERR ); + assert( signal(SIGABRT, sighandler_child) != SIG_ERR ); assert( signal(SIGSEGV, sighandler_child) != SIG_ERR ); return signal(SIGHUP, sighandler_child) == SIG_ERR; |