aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2020-10-23 14:31:25 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2020-10-23 14:34:54 +0300
commit3460db01ec7e2b042296d7f703dfa344c893f5ea (patch)
treed10d1abf3c8a90c8485c925138fc6bce8e3ce927
parent5a3340810fede2282e59850062fdf4cd0290c1cc (diff)
downloadlibmicrohttpd-3460db01ec7e2b042296d7f703dfa344c893f5ea.tar.gz
libmicrohttpd-3460db01ec7e2b042296d7f703dfa344c893f5ea.zip
daemon.c: fixed leak of resources if daemon is failed to start
-rw-r--r--src/microhttpd/daemon.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 10072078..7ffd93cd 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -6730,7 +6730,11 @@ MHD_start_daemon_va (unsigned int flags,
6730#ifdef EPOLL_SUPPORT 6730#ifdef EPOLL_SUPPORT
6731 if ( (0 != (*pflags & MHD_USE_EPOLL)) && 6731 if ( (0 != (*pflags & MHD_USE_EPOLL)) &&
6732 (MHD_NO == setup_epoll_to_listen (d)) ) 6732 (MHD_NO == setup_epoll_to_listen (d)) )
6733 {
6734 if (MHD_ITC_IS_VALID_ (d->itc))
6735 MHD_itc_destroy_chk_ (d->itc);
6733 goto thread_failed; 6736 goto thread_failed;
6737 }
6734#endif 6738#endif
6735 /* Must init cleanup connection mutex for each worker */ 6739 /* Must init cleanup connection mutex for each worker */
6736 if (! MHD_mutex_init_ (&d->cleanup_connection_mutex)) 6740 if (! MHD_mutex_init_ (&d->cleanup_connection_mutex))
@@ -6739,6 +6743,8 @@ MHD_start_daemon_va (unsigned int flags,
6739 MHD_DLOG (daemon, 6743 MHD_DLOG (daemon,
6740 _ ("MHD failed to initialize cleanup connection mutex.\n")); 6744 _ ("MHD failed to initialize cleanup connection mutex.\n"));
6741#endif 6745#endif
6746 if (MHD_ITC_IS_VALID_ (d->itc))
6747 MHD_itc_destroy_chk_ (d->itc);
6742 goto thread_failed; 6748 goto thread_failed;
6743 } 6749 }
6744 6750
@@ -6757,6 +6763,8 @@ MHD_start_daemon_va (unsigned int flags,
6757 /* Free memory for this worker; cleanup below handles 6763 /* Free memory for this worker; cleanup below handles
6758 * all previously-created workers. */ 6764 * all previously-created workers. */
6759 MHD_mutex_destroy_chk_ (&d->cleanup_connection_mutex); 6765 MHD_mutex_destroy_chk_ (&d->cleanup_connection_mutex);
6766 if (MHD_ITC_IS_VALID_ (d->itc))
6767 MHD_itc_destroy_chk_ (d->itc);
6760 goto thread_failed; 6768 goto thread_failed;
6761 } 6769 }
6762 } 6770 }