clean up oneshot_fd resource upon startup error

personal/stbuehler/mod-csrf-old
Glenn Strauss 7 years ago
parent c6edb24803
commit ccb1f02b83

@ -78,6 +78,7 @@ static int l_issetugid(void) {
# endif
#endif
static int oneshot_fd = 0;
static volatile sig_atomic_t srv_shutdown = 0;
static volatile sig_atomic_t graceful_shutdown = 0;
static volatile sig_atomic_t handle_sig_alarm = 1;
@ -293,6 +294,10 @@ static void server_free(server *srv) {
buffer_free(srv->mtime_cache[i].str);
}
if (oneshot_fd > 0) {
close(oneshot_fd);
}
#define CLEAN(x) \
buffer_free(srv->x);
@ -738,7 +743,6 @@ int main (int argc, char **argv) {
#ifdef HAVE_FORK
int parent_pipe_fd = -1;
#endif
int oneshot_fd = 0;
#ifdef USE_ALARM
struct itimerval interval;
@ -1476,8 +1480,8 @@ int main (int argc, char **argv) {
}
}
if (oneshot_fd && !server_oneshot_init(srv, oneshot_fd)) {
close(oneshot_fd);
if (oneshot_fd && server_oneshot_init(srv, oneshot_fd)) {
oneshot_fd = -1;
}
/* main-loop */

Loading…
Cancel
Save