From f87a0f16f8cee026ee33c3a46b93b43d4b3cf5ff Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 30 Dec 2013 23:01:54 +0000 Subject: Catch exceptions from Encoder threads. --- src/lib/encoder.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/lib/encoder.cc') diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index ca75e4ca1..b78bcaeea 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -96,7 +96,6 @@ Encoder::process_begin () ServerFinder::instance()->connect (boost::bind (&Encoder::server_found, this, _1)); } - void Encoder::process_end () { @@ -200,6 +199,11 @@ Encoder::process_video (shared_ptr image, Eyes eyes, ColourConversi } _writer->rethrow (); + /* Re-throw any exception raised by one of our threads. If more + than one has thrown an exception, only one will be rethrown, I think; + but then, if that happens something has gone badly wrong. + */ + rethrow (); if (_writer->can_fake_write (_video_frames_out)) { _writer->fake_write (_video_frames_out, eyes); @@ -255,6 +259,7 @@ Encoder::terminate_threads () void Encoder::encoder_thread (optional server) +try { /* Number of seconds that we currently wait between attempts to connect to the server; not relevant for localhost @@ -336,6 +341,10 @@ Encoder::encoder_thread (optional server) _condition.notify_all (); } } +catch (...) +{ + store_current (); +} void Encoder::server_found (ServerDescription s) -- cgit v1.2.3