Merge lp:~gerboland/unity-mir/shutdown-crash-fix3 into lp:unity-mir

Proposed by Gerry Boland
Status: Superseded
Proposed branch: lp:~gerboland/unity-mir/shutdown-crash-fix3
Merge into: lp:unity-mir
Diff against target: 50 lines (+20/-3)
1 file modified
src/unity-mir/qmirserver.cpp (+20/-3)
To merge this branch: bzr merge lp:~gerboland/unity-mir/shutdown-crash-fix3
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+218393@code.launchpad.net

Description of the change

Fix crash on Mir-initiated shutdown, where stop() was being called on an already shutting-down server

To post a comment you must log in.
221. By Gerry Boland

bump

222. By Gerry Boland

Missing csignal header

223. By Gerry Boland

Add Mir main_loop.h header

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-mir/qmirserver.cpp'
2--- src/unity-mir/qmirserver.cpp 2014-04-09 15:47:05 +0000
3+++ src/unity-mir/qmirserver.cpp 2014-05-06 11:31:45 +0000
4@@ -33,6 +33,7 @@
5 #include <thread>
6
7 // local
8+#include "logging.h"
9 #include "qmirserver.h"
10
11 QMirServer::QMirServer(int argc, const char* argv[], QObject *parent)
12@@ -53,19 +54,35 @@
13 auto argv = m_argv;
14 auto config = new ShellServerConfiguration(m_argc, m_argv);
15 std::thread *t;
16+ bool mirServerShutDown = false;
17
18- mir::run_mir(*config, [config, &client, &argc, &argv, &t](mir::DisplayServer& server) {
19+ mir::run_mir(*config, [&](mir::DisplayServer &server) {
20 ua_ui_mirserver_init(*config);
21
22+ // Mir initiates shutdown on SIGINT & SIGTERM, need to distinguish that shutdown from a
23+ // client-initiated shutdown. Do this by installing a custom signal handler that is run
24+ // after Mir's initiate-shutdown handler is called.
25+ config->the_main_loop()->register_signal_handler(
26+ {SIGINT, SIGTERM},
27+ [&](int)
28+ {
29+ DLOG("Mir-initiated shut down in progress");
30+ mirServerShutDown = true;
31+ });
32+
33 try {
34 t = new std::thread([&]() {
35 client (argc, argv, config);
36- server.stop();
37+ if (!mirServerShutDown) {
38+ DLOG("Qt-initiated shut down in progress");
39+ server.stop();
40+ }
41 });
42 } catch (...) {
43- qDebug() << "Exception caught, quitting";
44+ LOG("Exception caught, quitting");
45 }
46 });
47+
48 if (QCoreApplication::instance()) {
49 bool aboutToQuitSignaled = false;
50 QObject::connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, [&]() {

Subscribers

People subscribed via source and target branches