X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=httpd.cpp;fp=httpd.cpp;h=3fbab5d6d6630e97e6133a2df44b890b8484cf50;hb=2e46944df68ecd4910a96b2ff4ee55936d606ef7;hp=6f94409f3a55fea4244dd441d1fd466f8250d92f;hpb=c93d4d8a7e35f5e53868a938f1a216792c391598;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)