From: Steinar H. Gunderson Date: Sat, 13 Aug 2016 14:16:44 +0000 (+0200) Subject: Deal better with the HTTP port being busy. X-Git-Tag: 1.4.0~146 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;ds=sidebyside;h=2e46944df68ecd4910a96b2ff4ee55936d606ef7;p=nageru Deal better with the HTTP port being busy. --- diff --git a/httpd.cpp b/httpd.cpp index 6f94409..3fbab5d 100644 --- a/httpd.cpp +++ b/httpd.cpp @@ -26,11 +26,13 @@ HTTPD::HTTPD() HTTPD::~HTTPD() { - MHD_quiesce_daemon(mhd); - for (Stream *stream : streams) { - stream->stop(); + if (mhd) { + MHD_quiesce_daemon(mhd); + for (Stream *stream : streams) { + stream->stop(); + } + MHD_stop_daemon(mhd); } - MHD_stop_daemon(mhd); } void HTTPD::start(int port) @@ -41,6 +43,9 @@ void HTTPD::start(int port) &answer_to_connection_thunk, this, MHD_OPTION_NOTIFY_COMPLETED, nullptr, this, MHD_OPTION_END); + if (mhd == nullptr) { + fprintf(stderr, "Warning: Could not open HTTP server. (Port already in use?)\n"); + } } void HTTPD::add_data(const char *buf, size_t size, bool keyframe)