libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 699c31e686ca3e1ecea93252d589f9a0e56c6a54
parent 71b73eca6ae6e2b9480e65ee50ee4ff51981fa89
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu, 14 Apr 2016 10:20:24 +0000

Don't create daemon if failed to make daemon control pipe non-blocking

Diffstat:
Msrc/microhttpd/daemon.c | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git 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