aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2014-04-20 16:16:51 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2014-04-20 16:16:58 +0100
commit6799335fe963065080cee343cfecb32b58af4651 (patch)
treebb4a7007b50db612ccc34208eb30e4fa5aad6f7e
parentb20013e387047ba016cbee9014093dd76225c7d1 (diff)
downloadpaludis-6799335fe963065080cee343cfecb32b58af4651.tar.gz
paludis-6799335fe963065080cee343cfecb32b58af4651.tar.xz
Look for exceptions inside threads
-rw-r--r--paludis/util/executor.cc20
-rw-r--r--src/clients/cave/resolve_common.cc17
2 files changed, 28 insertions, 9 deletions
diff --git a/paludis/util/executor.cc b/paludis/util/executor.cc
index b6338a2..136de2e 100644
--- a/paludis/util/executor.cc
+++ b/paludis/util/executor.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013 Ciaran McCreesh
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -26,6 +26,7 @@
#include <thread>
#include <mutex>
#include <condition_variable>
+#include <iostream>
using namespace paludis;
@@ -74,11 +75,20 @@ Executor::~Executor()
void
Executor::_one(const std::shared_ptr<Executive> executive)
{
- executive->execute_threaded();
+ try
+ {
+ executive->execute_threaded();
- std::unique_lock<std::mutex> lock(_imp->mutex);
- _imp->ready_for_post.push_back(executive);
- _imp->condition.notify_all();
+ std::unique_lock<std::mutex> lock(_imp->mutex);
+ _imp->ready_for_post.push_back(executive);
+ _imp->condition.notify_all();
+ }
+ catch (const std::exception & e)
+ {
+ std::cerr << "Things are about go to horribly wrong. Got an exception inside executor: "
+ << e.what() << std::endl;
+ throw;
+ }
}
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 45a779f..835e767 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013 Ciaran McCreesh
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -231,9 +231,18 @@ namespace
void serialise_resolved(StringListStream & ser_stream, const Resolved & resolved)
{
- Serialiser ser(ser_stream);
- resolved.serialise(ser);
- ser_stream.nothing_more_to_write();
+ try
+ {
+ Serialiser ser(ser_stream);
+ resolved.serialise(ser);
+ ser_stream.nothing_more_to_write();
+ }
+ catch (const std::exception & e)
+ {
+ std::cerr << "Things are about go to horribly wrong. Got an exception whilst serialising: "
+ << e.what() << std::endl;
+ throw;
+ }
}
int display_resolution(