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
=== modified file 'src/core/trust/daemon.cpp'
--- src/core/trust/daemon.cpp 2015-08-20 17:46:04 +0000
+++ src/core/trust/daemon.cpp 2015-08-27 14:08:17 +0000
@@ -16,6 +16,8 @@
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */17 */
1818
19#include <glog/logging.h>
20
19#include <core/trust/daemon.h>21#include <core/trust/daemon.h>
2022
21#include <core/trust/app_id_formatting_trust_agent.h>23#include <core/trust/app_id_formatting_trust_agent.h>
@@ -101,12 +103,46 @@
101 // We immediate execute the io_service instance103 // We immediate execute the io_service instance
102 std::thread worker1104 std::thread worker1
103 {105 {
104 std::thread{[this]() { io_service.run(); }}106 std::thread{[this]() {
107 while(true)
108 {
109 try
110 {
111 io_service.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 } // while
123 }} // thread
105 };124 };
106125
107 std::thread worker2126 std::thread worker2
108 {127 {
109 std::thread{[this]() { io_service.run(); }}128 std::thread{[this]() {
129 while(true)
130 {
131 try
132 {
133 io_service.run();
134 break; // run() exited normally
135 }
136 catch (const std::exception& e)
137 {
138 LOG(WARNING) << e.what();
139 }
140 catch (...)
141 {
142 LOG(WARNING) << "Unexpected exception was raised by the bus executor";
143 }
144 } // while
145 }} // thread
110 };146 };
111 };147 };
112148
@@ -397,7 +433,25 @@
397433
398 std::thread worker434 std::thread worker
399 {435 {
400 [configuration]() { configuration.bus->run(); }436 [configuration]()
437 {
438 while(true)
439 {
440 try
441 {
442 configuration.bus->run();
443 break; // run() exited normally
444 }
445 catch (const std::exception& e)
446 {
447 LOG(WARNING) << e.what();
448 }
449 catch (...)
450 {
451 LOG(WARNING) << "Unexpected exception was raised by the bus executor";
452 }
453 }
454 }
401 };455 };
402456
403 // Expose the local store to the bus, keeping it exposed for the457 // Expose the local store to the bus, keeping it exposed for the
404458
=== modified file 'src/core/trust/expose.cpp'
--- src/core/trust/expose.cpp 2014-08-04 07:57:05 +0000
+++ src/core/trust/expose.cpp 2015-08-27 14:08:17 +0000
@@ -16,6 +16,7 @@
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */17 */
1818
19#include <glog/logging.h>
19#include <core/trust/expose.h>20#include <core/trust/expose.h>
2021
21#include <core/trust/store.h>22#include <core/trust/store.h>
@@ -99,7 +100,24 @@
99 handle_remove_query(msg);100 handle_remove_query(msg);
100 });101 });
101102
102 worker = std::move(std::thread([this](){Token::bus->run();}));103 worker = std::move(std::thread([this](){
104 while(true)
105 {
106 try
107 {
108 Token::bus->run();
109 break; // run() exited normally
110 }
111 catch (const std::exception& e)
112 {
113 LOG(WARNING) << e.what();
114 }
115 catch (...)
116 {
117 LOG(WARNING) << "Unexpected exception was raised by the bus executor";
118 }
119 }
120 }));
103 }121 }
104122
105 ~Token()123 ~Token()
106124
=== modified file 'src/core/trust/resolve.cpp'
--- src/core/trust/resolve.cpp 2014-07-29 17:00:35 +0000
+++ src/core/trust/resolve.cpp 2015-08-27 14:08:17 +0000
@@ -16,6 +16,8 @@
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */17 */
1818
19#include <glog/logging.h>
20
19#include <core/trust/resolve.h>21#include <core/trust/resolve.h>
2022
21#include <core/trust/request.h>23#include <core/trust/request.h>
@@ -52,7 +54,24 @@
52 Store(const std::shared_ptr<dbus::Service>& service,54 Store(const std::shared_ptr<dbus::Service>& service,
53 const std::shared_ptr<core::dbus::Bus>& bus)55 const std::shared_ptr<core::dbus::Bus>& bus)
54 : bus(bus),56 : bus(bus),
55 worker{[this]() { Store::bus->run(); }},57 worker{[this]() {
58 while(true)
59 {
60 try
61 {
62 Store::bus->run();
63 break; // run() exited normally
64 }
65 catch (const std::exception& e)
66 {
67 LOG(WARNING) << e.what();
68 }
69 catch (...)
70 {
71 LOG(WARNING) << "Unexpected exception was raised by the bus executor";
72 }
73 }
74 }},
56 service(service),75 service(service),
57 proxy(service->object_for_path(dbus::types::ObjectPath::root()))76 proxy(service->object_for_path(dbus::types::ObjectPath::root()))
58 {77 {

Subscribers

People subscribed via source and target branches