Skip to content

Commit

Permalink
Reload, don't restart, dbus.service
Browse files Browse the repository at this point in the history
Many bus clients get hopelessly confused when dbus-daemon is
restarted. So let's not do that.

Of course, this is not ideal either, because we end up stuck with a
possibly outdated dbus-daemon. But that issue will become irrelevant
in the glorious kdbus-based future.

Hopefully this also gets rid of systemd getting stuck after
dbus-daemon is restarted:

Apr 01 15:37:50 mandark systemd[1]: Failed to register match for Disconnected message: Connection timed out
Apr 01 15:37:50 mandark systemd[1]: Looping too fast. Throttling execution a little.
Apr 01 15:37:51 mandark systemd[1]: Looping too fast. Throttling execution a little.
...
  • Loading branch information
edolstra committed Apr 1, 2015
1 parent b3e1021 commit 1c39a47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
3 changes: 3 additions & 0 deletions nixos/modules/services/system/dbus.nix
Expand Up @@ -130,6 +130,9 @@ in
config.system.path
];

# Don't restart dbus-daemon. Bad things tend to happen if we do.
systemd.services.dbus.reloadIfChanged = true;

environment.pathsToLink = [ "/etc/dbus-1" "/share/dbus-1" ];

};
Expand Down
18 changes: 7 additions & 11 deletions nixos/modules/system/activation/switch-to-configuration.pl
Expand Up @@ -384,9 +384,13 @@ sub filterUnits {
# Make systemd reload its units.
system("@systemd@/bin/systemctl", "daemon-reload") == 0 or $res = 3;

# Signal dbus to reload its configuration before starting other units.
# Other units may rely on newly installed policy files under /etc/dbus-1
system("@systemd@/bin/systemctl", "reload-or-restart", "dbus.service");
# Reload units that need it. This includes remounting changed mount
# units.
if (scalar(keys %unitsToReload) > 0) {
print STDERR "reloading the following units: ", join(", ", sort(keys %unitsToReload)), "\n";
system("@systemd@/bin/systemctl", "reload", "--", sort(keys %unitsToReload)) == 0 or $res = 4;
unlink($reloadListFile);
}

# Restart changed services (those that have to be restarted rather
# than stopped and started).
Expand All @@ -407,14 +411,6 @@ sub filterUnits {
system("@systemd@/bin/systemctl", "start", "--", sort(keys %unitsToStart)) == 0 or $res = 4;
unlink($startListFile);

# Reload units that need it. This includes remounting changed mount
# units.
if (scalar(keys %unitsToReload) > 0) {
print STDERR "reloading the following units: ", join(", ", sort(keys %unitsToReload)), "\n";
system("@systemd@/bin/systemctl", "reload", "--", sort(keys %unitsToReload)) == 0 or $res = 4;
unlink($reloadListFile);
}


# Print failed and new units.
my (@failed, @new, @restarting);
Expand Down

7 comments on commit 1c39a47

@lucabrunox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But dbus should be reloaded/restarted before others, otherwise changes to configuration may break other units. That's why I moved dbus reload/restart before other reloads.
So can we keep the reload-or-restart of dbus? It shouldn't bother that we reload it twice.

@edolstra
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is reloaded before other units are restarted.

@lucabrunox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But not before other units are reloaded.

@edolstra
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What units are affected by this? There are only two other units (firewall and u9fs) that use reloadIfChanged, and I don't think they use dbus.

@lucabrunox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so this is what just happened to me: enabled bluetooth, didn't work because it added files to dbus directory but dbus didn't reload. Now, can we please add back that reload-or-restart unconditionally to avoid any mistakes? It doesn't hurt anything.

@edolstra
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that fixed by 5a5a43e?

@lucabrunox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok think so, I'm using latest nixos unstable of 10 days old.

Please sign in to comment.