diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-04-14 10:20:24 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-04-14 10:20:24 +0000 |
commit | 699c31e686ca3e1ecea93252d589f9a0e56c6a54 (patch) | |
tree | f2e3316835923f6a570b45146ae413304e69a285 | |
parent | 71b73eca6ae6e2b9480e65ee50ee4ff51981fa89 (diff) |
Don't create daemon if failed to make daemon control pipe non-blocking
-rw-r--r-- | src/microhttpd/daemon.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index bcbe6b50..fcbf445a 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c @@ -3782,7 +3782,18 @@ MHD_start_daemon_va (unsigned int flags, free (daemon); return NULL; } - make_nonblocking (daemon, daemon->wpipe[0]); + if (MHD_NO == make_nonblocking (daemon, daemon->wpipe[0])) + { +#ifdef HAVE_MESSAGES + MHD_DLOG (daemon, + "Failed to make control pipe non-blocking: %s\n", + MHD_strerror_ (errno)); +#endif + MHD_pipe_close_ (daemon->wpipe[0]); + MHD_pipe_close_ (daemon->wpipe[1]); + free (daemon); + return NULL; + } make_nonblocking (daemon, daemon->wpipe[1]); } #ifndef MHD_WINSOCK_SOCKETS |