Merge lp:~mterry/deja-dup/quit-on-dbus-exit into lp:deja-dup/24

Proposed by Michael Terry on 2012-09-17
Status: Merged
Merged at revision: 1381
Proposed branch: lp:~mterry/deja-dup/quit-on-dbus-exit
Merge into: lp:deja-dup/24
Diff against target: 67 lines (+30/-19)
1 file modified
monitor/monitor.vala (+30/-19)
To merge this branch: bzr merge lp:~mterry/deja-dup/quit-on-dbus-exit
Reviewer Review Type Date Requested Status
Robert Bruce Park (community) 2012-09-17 Approve on 2012-09-18
Review via email: mp+124606@code.launchpad.net

Description of the change

Have deja-dup-monitor try to own a bus name on startup and quit if it can't own it or loses the name for any reason.

This fixes two issues:
1) A user somehow tries to run two monitors in the same session. This is almost always due to the user doing something goofy, but whatever, we should help the user there. (Bug 891797)

2) Quantal seems to have a new bug where logging out does not make old deja-dup-monitor processes quit. By owning a bus name, it makes it easy to notice when a dbus session dies, so that we can exit with the session. (Bug 1051811)

To post a comment you must log in.
Robert Bruce Park (robru) wrote :

Code looks good, test suite passes, and I confirmed interactively that I was unable to launch two instances of deja-dup-monitor from the source tree (second instance exits immediately).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'monitor/monitor.vala'
2--- monitor/monitor.vala 2012-08-06 22:41:13 +0000
3+++ monitor/monitor.vala 2012-09-17 06:17:21 +0000
4@@ -294,6 +294,27 @@
5 settings.changed.connect(prepare_if_necessary);
6 }
7
8+static void begin_monitoring()
9+{
10+ DejaDup.Network.ensure_status.begin();
11+ DejaDup.Network.get().notify["connected"].connect(network_changed);
12+
13+ Bus.watch_name(BusType.SESSION, "org.gnome.DejaDup.Operation",
14+ BusNameWatcherFlags.NONE, op_started, op_ended);
15+
16+ var mon = VolumeMonitor.get();
17+ mon.ref(); // bug 569418; bad things happen when VM goes away
18+ mon.volume_added.connect(volume_added);
19+
20+ watch_settings();
21+
22+ // Delay first check to give the network and desktop environment a chance to start up.
23+ if (DejaDup.in_testing_mode())
24+ make_first_check();
25+ else
26+ Timeout.add_seconds(120, () => {make_first_check(); return false;});
27+}
28+
29 static int main(string[] args)
30 {
31 DejaDup.i18n_setup();
32@@ -319,27 +340,17 @@
33 if (!DejaDup.initialize(null, null))
34 return 1;
35
36- DejaDup.Network.ensure_status.begin();
37- DejaDup.Network.get().notify["connected"].connect(network_changed);
38-
39- Bus.watch_name(BusType.SESSION, "org.gnome.DejaDup.Operation",
40- BusNameWatcherFlags.NONE, op_started, op_ended);
41-
42- var mon = VolumeMonitor.get();
43- mon.ref(); // bug 569418; bad things happen when VM goes away
44- mon.volume_added.connect(volume_added);
45-
46 var loop = new MainLoop(null, false);
47-
48- // Delay first check to give the network and desktop environment a chance to start up.
49- if (DejaDup.in_testing_mode())
50- make_first_check();
51- else
52- Timeout.add_seconds(120, () => {make_first_check(); return false;});
53-
54- watch_settings();
55+ Idle.add(() => {
56+ // quit if we can't get the bus name or become disconnected
57+ Bus.own_name(BusType.SESSION, "org.gnome.DejaDup.Monitor",
58+ BusNameOwnerFlags.NONE, ()=>{},
59+ ()=>{begin_monitoring();},
60+ ()=>{loop.quit();});
61+ return false;
62+ });
63 loop.run();
64-
65+
66 return 0;
67 }
68

Subscribers

People subscribed via source and target branches