Merge lp:~mandel/trust-store/handle-exceptions into lp:trust-store

Proposed by Manuel de la Peña
Status: Approved
Approved by: Ken VanDine
Approved revision: 104
Proposed branch: lp:~mandel/trust-store/handle-exceptions
Merge into: lp:trust-store
Diff against target: 165 lines (+96/-5)
3 files modified
src/core/trust/daemon.cpp (+57/-3)
src/core/trust/expose.cpp (+19/-1)
src/core/trust/resolve.cpp (+20/-1)
To merge this branch: bzr merge lp:~mandel/trust-store/handle-exceptions
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ken VanDine Approve
Review via email: mp+257690@code.launchpad.net

Commit message

Handle exceptions coming from the io_service.

Description of the change

Handle exceptions coming from the io_service.

To post a comment you must log in.
102. By Manuel de la Peña

Link bug.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
103. By Manuel de la Peña

Merge with trunk.

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks good, just fix the white space I commented on inline.

review: Needs Fixing
104. By Manuel de la Peña

Fix space issue.

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Great, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

104. By Manuel de la Peña

Fix space issue.

103. By Manuel de la Peña

Merge with trunk.

102. By Manuel de la Peña

Link bug.

101. By Manuel de la Peña

Ensure that we do not crash when exceptions are raised.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/core/trust/daemon.cpp'
2--- src/core/trust/daemon.cpp 2015-08-20 17:46:04 +0000
3+++ src/core/trust/daemon.cpp 2015-08-27 14:08:17 +0000
4@@ -16,6 +16,8 @@
5 * Authored by: Thomas Voß <thomas.voss@canonical.com>
6 */
7
8+#include <glog/logging.h>
9+
10 #include <core/trust/daemon.h>
11
12 #include <core/trust/app_id_formatting_trust_agent.h>
13@@ -101,12 +103,46 @@
14 // We immediate execute the io_service instance
15 std::thread worker1
16 {
17- std::thread{[this]() { io_service.run(); }}
18+ std::thread{[this]() {
19+ while(true)
20+ {
21+ try
22+ {
23+ io_service.run();
24+ break; // run() exited normally
25+ }
26+ catch (const std::exception& e)
27+ {
28+ LOG(WARNING) << e.what();
29+ }
30+ catch (...)
31+ {
32+ LOG(WARNING) << "Unexpected exception was raised by the bus executor";
33+ }
34+ } // while
35+ }} // thread
36 };
37
38 std::thread worker2
39 {
40- std::thread{[this]() { io_service.run(); }}
41+ std::thread{[this]() {
42+ while(true)
43+ {
44+ try
45+ {
46+ io_service.run();
47+ break; // run() exited normally
48+ }
49+ catch (const std::exception& e)
50+ {
51+ LOG(WARNING) << e.what();
52+ }
53+ catch (...)
54+ {
55+ LOG(WARNING) << "Unexpected exception was raised by the bus executor";
56+ }
57+ } // while
58+ }} // thread
59 };
60 };
61
62@@ -397,7 +433,25 @@
63
64 std::thread worker
65 {
66- [configuration]() { configuration.bus->run(); }
67+ [configuration]()
68+ {
69+ while(true)
70+ {
71+ try
72+ {
73+ configuration.bus->run();
74+ break; // run() exited normally
75+ }
76+ catch (const std::exception& e)
77+ {
78+ LOG(WARNING) << e.what();
79+ }
80+ catch (...)
81+ {
82+ LOG(WARNING) << "Unexpected exception was raised by the bus executor";
83+ }
84+ }
85+ }
86 };
87
88 // Expose the local store to the bus, keeping it exposed for the
89
90=== modified file 'src/core/trust/expose.cpp'
91--- src/core/trust/expose.cpp 2014-08-04 07:57:05 +0000
92+++ src/core/trust/expose.cpp 2015-08-27 14:08:17 +0000
93@@ -16,6 +16,7 @@
94 * Authored by: Thomas Voß <thomas.voss@canonical.com>
95 */
96
97+#include <glog/logging.h>
98 #include <core/trust/expose.h>
99
100 #include <core/trust/store.h>
101@@ -99,7 +100,24 @@
102 handle_remove_query(msg);
103 });
104
105- worker = std::move(std::thread([this](){Token::bus->run();}));
106+ worker = std::move(std::thread([this](){
107+ while(true)
108+ {
109+ try
110+ {
111+ Token::bus->run();
112+ break; // run() exited normally
113+ }
114+ catch (const std::exception& e)
115+ {
116+ LOG(WARNING) << e.what();
117+ }
118+ catch (...)
119+ {
120+ LOG(WARNING) << "Unexpected exception was raised by the bus executor";
121+ }
122+ }
123+ }));
124 }
125
126 ~Token()
127
128=== modified file 'src/core/trust/resolve.cpp'
129--- src/core/trust/resolve.cpp 2014-07-29 17:00:35 +0000
130+++ src/core/trust/resolve.cpp 2015-08-27 14:08:17 +0000
131@@ -16,6 +16,8 @@
132 * Authored by: Thomas Voß <thomas.voss@canonical.com>
133 */
134
135+#include <glog/logging.h>
136+
137 #include <core/trust/resolve.h>
138
139 #include <core/trust/request.h>
140@@ -52,7 +54,24 @@
141 Store(const std::shared_ptr<dbus::Service>& service,
142 const std::shared_ptr<core::dbus::Bus>& bus)
143 : bus(bus),
144- worker{[this]() { Store::bus->run(); }},
145+ worker{[this]() {
146+ while(true)
147+ {
148+ try
149+ {
150+ Store::bus->run();
151+ break; // run() exited normally
152+ }
153+ catch (const std::exception& e)
154+ {
155+ LOG(WARNING) << e.what();
156+ }
157+ catch (...)
158+ {
159+ LOG(WARNING) << "Unexpected exception was raised by the bus executor";
160+ }
161+ }
162+ }},
163 service(service),
164 proxy(service->object_for_path(dbus::types::ObjectPath::root()))
165 {

Subscribers

People subscribed via source and target branches