Comment.
[dcpomatic.git] / src / lib / server.cc
index 2fc9404669724c41ada2cd80391d121e57609b12..f0b2d9816eedf581178853c72b873c8622649476 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include "server.h"
+#include "util.h"
 #include "dcpomatic_socket.h"
 #include "image.h"
 #include "dcp_video.h"
 #include "safe_stringstream.h"
 #include "raw_convert.h"
 #include "compose.hpp"
+#include "log.h"
 #include <libcxml/cxml.h>
+#include <libxml++/libxml++.h>
 #include <boost/algorithm/string.hpp>
 #include <boost/scoped_array.hpp>
+#include <boost/foreach.hpp>
 #include <string>
 #include <vector>
 #include <iostream>
@@ -75,17 +79,22 @@ Server::~Server ()
                boost::mutex::scoped_lock lm (_worker_mutex);
                _terminate = true;
                _empty_condition.notify_all ();
+               _full_condition.notify_all ();
        }
 
-       for (vector<boost::thread*>::iterator i = _worker_threads.begin(); i != _worker_threads.end(); ++i) {
-               (*i)->join ();
-               delete *i;
+       BOOST_FOREACH (boost::thread* i, _worker_threads) {
+               DCPOMATIC_ASSERT (i->joinable ());
+               i->join ();
+               delete i;
        }
 
        _io_service.stop ();
 
        _broadcast.io_service.stop ();
-       _broadcast.thread->join ();
+       if (_broadcast.thread) {
+               DCPOMATIC_ASSERT (_broadcast.thread->joinable ());
+               _broadcast.thread->join ();
+       }
 }
 
 /** @param after_read Filled in with gettimeofday() after reading the input from the network.