X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=httpd.cpp;h=3fbab5d6d6630e97e6133a2df44b890b8484cf50;hb=7188db27a931607ed0388b10b351164c37cf04ee;hp=6f94409f3a55fea4244dd441d1fd466f8250d92f;hpb=b1b7b5477664b3871f25e4e990fa8835952303d6;p=nageru 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)