Merge lp:~thomas-voss/trust-store/fix-1356468 into lp:trust-store

Proposed by Thomas Voß
Status: Needs review
Proposed branch: lp:~thomas-voss/trust-store/fix-1356468
Merge into: lp:trust-store
Diff against target: 93 lines (+35/-31)
1 file modified
src/core/trust/daemon.cpp (+35/-31)
To merge this branch: bzr merge lp:~thomas-voss/trust-store/fix-1356468
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+234431@code.launchpad.net

Commit message

Define an explicit ctor to avoid any sort of potential races.

Description of the change

Define an explicit ctor to avoid any sort of potential races.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

41. By Thomas Voß

Define an explicit ctor to avoid any sort of potential races.

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 2014-08-26 14:50:22 +0000
3+++ src/core/trust/daemon.cpp 2014-09-12 07:57:53 +0000
4@@ -48,8 +48,7 @@
5 {
6 struct Runtime
7 {
8- // Do not execute in parallel, serialize
9- // accesses.
10+ // We allow for parallel execution
11 static constexpr std::size_t concurrency_hint{2};
12
13 // Our evil singleton pattern. Not bad though, we control the
14@@ -61,6 +60,34 @@
15 return runtime;
16 }
17
18+ Runtime()
19+ : signal_trap
20+ {
21+ core::posix::trap_signals_for_all_subsequent_threads(
22+ {
23+ core::posix::Signal::sig_term,
24+ core::posix::Signal::sig_int
25+ })
26+ },
27+ io_service
28+ {
29+ concurrency_hint
30+ },
31+ keep_alive
32+ {
33+ io_service
34+ },
35+ worker1
36+ {
37+ [this]() { io_service.run(); }
38+ },
39+ worker2
40+ {
41+ [this]() { io_service.run(); }
42+ }
43+ {
44+ }
45+
46 ~Runtime()
47 {
48 io_service.stop();
49@@ -73,38 +100,15 @@
50 }
51
52 // We trap sig term to ensure a clean shutdown.
53- std::shared_ptr<core::posix::SignalTrap> signal_trap
54- {
55- core::posix::trap_signals_for_all_subsequent_threads(
56- {
57- core::posix::Signal::sig_term,
58- core::posix::Signal::sig_int
59- })
60- };
61-
62+ std::shared_ptr<core::posix::SignalTrap> signal_trap;
63 // Our io_service instance exposed to remote agents.
64- boost::asio::io_service io_service
65- {
66- concurrency_hint
67- };
68-
69+ boost::asio::io_service io_service;
70 // We keep the io_service alive and introduce some artificial
71 // work.
72- boost::asio::io_service::work keep_alive
73- {
74- io_service
75- };
76-
77- // We immediate execute the io_service instance
78- std::thread worker1
79- {
80- std::thread{[this]() { io_service.run(); }}
81- };
82-
83- std::thread worker2
84- {
85- std::thread{[this]() { io_service.run(); }}
86- };
87+ boost::asio::io_service::work keep_alive;
88+ // We provider two workers to the io_service instance.
89+ std::thread worker1;
90+ std::thread worker2;
91 };
92
93 core::trust::Daemon::Dictionary fill_dictionary_from_unrecognized_options(const Options::parsed_options& parsed_options)

Subscribers

People subscribed via source and target branches