]> git.sesse.net Git - nageru/commitdiff
Fix a crash if somebody is trying to get metrics (or perhaps also tally) while we...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 26 Apr 2018 20:43:43 +0000 (22:43 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 26 Apr 2018 20:43:43 +0000 (22:43 +0200)
httpd.cpp
httpd.h
mixer.cpp

index 9782dca7ba7807ab45c0e1994cd6a25642623086..f6441768bbdde1df3d31e2b42a2cb13430019376 100644 (file)
--- a/httpd.cpp
+++ b/httpd.cpp
@@ -30,13 +30,7 @@ HTTPD::HTTPD()
 
 HTTPD::~HTTPD()
 {
-       if (mhd) {
-               MHD_quiesce_daemon(mhd);
-               for (Stream *stream : streams) {
-                       stream->stop();
-               }
-               MHD_stop_daemon(mhd);
-       }
+       stop();
 }
 
 void HTTPD::start(int port)
@@ -52,6 +46,18 @@ void HTTPD::start(int port)
        }
 }
 
+void HTTPD::stop()
+{
+       if (mhd) {
+               MHD_quiesce_daemon(mhd);
+               for (Stream *stream : streams) {
+                       stream->stop();
+               }
+               MHD_stop_daemon(mhd);
+               mhd = nullptr;
+       }
+}
+
 void HTTPD::add_data(const char *buf, size_t size, bool keyframe, int64_t time, AVRational timebase)
 {
        unique_lock<mutex> lock(streams_mutex);
diff --git a/httpd.h b/httpd.h
index 1c3c98ee3ba3e1d9bbe25f50e4831cc40e6e696e..57c649b61158c6f73b498aeca6556b97bc52f179 100644 (file)
--- a/httpd.h
+++ b/httpd.h
@@ -46,6 +46,7 @@ public:
        }
 
        void start(int port);
+       void stop();
        void add_data(const char *buf, size_t size, bool keyframe, int64_t time, AVRational timebase);
        int64_t get_num_connected_clients() const {
                return metric_num_connected_clients.load();
index a168b66bcdd41fbbf7e575edf761551fa717b33e..e66a3881975d1ef1ffd2119c0c23ddf3e6e7a375 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -499,6 +499,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
 
 Mixer::~Mixer()
 {
+       httpd.stop();
        BMUSBCapture::stop_bm_thread();
 
        for (unsigned card_index = 0; card_index < num_cards + num_video_inputs + num_html_inputs; ++card_index) {