Mir

Merge lp:~alan-griffiths/mir/raii-fix-1237710 into lp:mir

Proposed by Alan Griffiths
Status: Rejected
Rejected by: Daniel van Vugt
Proposed branch: lp:~alan-griffiths/mir/raii-fix-1237710
Merge into: lp:mir
Diff against target: 33 lines (+15/-2)
1 file modified
src/server/run_mir.cpp (+15/-2)
To merge this branch: bzr merge lp:~alan-griffiths/mir/raii-fix-1237710
Reviewer Review Type Date Requested Status
Daniel van Vugt Disapprove
Robert Carr (community) Approve
Alexandros Frantzis (community) Approve
Kevin DuBois (community) Abstain
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+191420@code.launchpad.net

Commit message

run_mir: restore signals handlers after the server exits (eve if by an exception).

Description of the change

run_mir: restore signals handlers after the server exits (eve if by an exception).

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

lgtm, i like fix-1237710 a bit more for the simplicity, but would be okay if this lands

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

I'll switch to abstain (would prefer lp:~alan-griffiths/mir/fix-1237710)

review: Abstain
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

I also like fix-1237710 for its simplicity, but I like uncoditional correctness more than simplicity :)

review: Approve
Revision history for this message
Robert Carr (robertcarr) wrote :

I feel like a contestant on a merge proposal game show.

Anyhow +1

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I appreciate the robustness you're aiming for here, but this approach is very difficult to read and maintain.

I'm going to approve the simplified version. And we can work on exception correctness after that. Maybe with a try/catch.

review: Disapprove

Unmerged revisions

1139. By Alan Griffiths

Restore previous signal handlers after run()

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/run_mir.cpp'
2--- src/server/run_mir.cpp 2013-10-14 06:33:42 +0000
3+++ src/server/run_mir.cpp 2013-10-16 14:08:02 +0000
4@@ -50,6 +50,16 @@
5 signal(sig, old_handler[sig]);
6 raise(sig);
7 }
8+
9+struct PairedOperations
10+{
11+ PairedOperations(void (*set_up)(), void (*tear_down)()) :
12+ tear_down(tear_down) { set_up(); }
13+
14+ ~PairedOperations() { tear_down(); }
15+
16+ void (* const tear_down)();
17+};
18 }
19
20 void mir::run_mir(ServerConfiguration& config, std::function<void(DisplayServer&)> init)
21@@ -71,8 +81,11 @@
22
23 weak_connector = config.the_connector();
24
25- for (auto sig : { SIGQUIT, SIGABRT, SIGFPE, SIGSEGV, SIGBUS })
26- old_handler[sig] = signal(sig, fatal_signal_cleanup);
27+ PairedOperations scoped(
28+ [] { for (auto sig : { SIGQUIT, SIGABRT, SIGFPE, SIGSEGV, SIGBUS })
29+ old_handler[sig] = signal(sig, fatal_signal_cleanup); },
30+ [] { for (auto sig : { SIGQUIT, SIGABRT, SIGFPE, SIGSEGV, SIGBUS })
31+ signal(sig, old_handler[sig]); });
32
33 std::atexit(&delete_endpoint);
34

Subscribers

People subscribed via source and target branches