X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fserver.cc;h=5d85d8800054ea83a4434385d5cced9016061fb5;hb=5b3e3df6c9352e31dd932a5af215eabbf2cf27c8;hp=e7e2a3c5715c7e17b684d5a9dd696b93c8123f6e;hpb=dbf43f9113d88245f27493fd5d6950ba142b7f1f;p=dcpomatic.git diff --git a/src/lib/server.cc b/src/lib/server.cc index e7e2a3c57..5d85d8800 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -23,6 +23,7 @@ */ #include "server.h" +#include "util.h" #include "dcpomatic_socket.h" #include "image.h" #include "dcp_video.h" @@ -34,19 +35,22 @@ #include "raw_convert.h" #include "compose.hpp" #include "log.h" +#include "encoded_log_entry.h" #include +#include #include #include +#include #include #include #include #include "i18n.h" -#define LOG_GENERAL(...) _log->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL); -#define LOG_GENERAL_NC(...) _log->log (__VA_ARGS__, Log::TYPE_GENERAL); -#define LOG_ERROR(...) _log->log (String::compose (__VA_ARGS__), Log::TYPE_ERROR); -#define LOG_ERROR_NC(...) _log->log (__VA_ARGS__, Log::TYPE_ERROR); +#define LOG_GENERAL(...) _log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); +#define LOG_GENERAL_NC(...) _log->log (__VA_ARGS__, LogEntry::TYPE_GENERAL); +#define LOG_ERROR(...) _log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_ERROR); +#define LOG_ERROR_NC(...) _log->log (__VA_ARGS__, LogEntry::TYPE_ERROR); using std::string; using std::vector; @@ -76,17 +80,22 @@ Server::~Server () boost::mutex::scoped_lock lm (_worker_mutex); _terminate = true; _empty_condition.notify_all (); + _full_condition.notify_all (); } - for (vector::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. @@ -179,19 +188,20 @@ Server::worker_thread () struct timeval end; gettimeofday (&end, 0); - SafeStringStream message; - message.precision (2); - message << fixed - << "Encoded frame " << frame << " from " << ip << ": " - << "receive " << (seconds(after_read) - seconds(start)) << "s " - << "encode " << (seconds(after_encode) - seconds(after_read)) << "s " - << "send " << (seconds(end) - seconds(after_encode)) << "s."; + shared_ptr e ( + new EncodedLogEntry ( + frame, ip, + seconds(after_read) - seconds(start), + seconds(after_encode) - seconds(after_read), + seconds(end) - seconds(after_encode) + ) + ); if (_verbose) { - cout << message.str() << "\n"; + cout << e->get() << "\n"; } - LOG_GENERAL_NC (message.str ()); + _log->log (e); } _full_condition.notify_all ();