Do not try to signal NetworkManager before suspend if it isn't running

Sending dbus calls to a service which isn't running _and is blocked to
not be started_ would result in timeout, which would delay the whole
system suspend.

Fixes QubesOS/qubes-issues#1419
This commit is contained in:
Marek Marczykowski-Górecki 2016-01-11 19:40:32 +01:00
parent d4c238c45e
commit cb5c457fba
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -12,11 +12,13 @@ if [ -r /rw/config/suspend-module-blacklist ]; then
fi
if [ x"$action" = x"suspend" ]; then
dbus-send --system --print-reply \
--dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager \
org.freedesktop.NetworkManager.Sleep boolean:true || \
service NetworkManager stop
if [ -f /var/run/qubes-service/network-manager ]; then
dbus-send --system --print-reply \
--dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager \
org.freedesktop.NetworkManager.Sleep boolean:true || \
service NetworkManager stop
fi
# Force interfaces down, just in case when NM didn't done it
for if in `ls /sys/class/net|grep -v "lo\|vif"`; do
if [ "`cat /sys/class/net/$if/device/devtype 2>/dev/null`" = "vif" ]; then
@ -36,9 +38,11 @@ else
for mod in `cat /var/run/qubes/suspend-modules-loaded`; do
modprobe $mod
done
dbus-send --system --print-reply \
--dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager \
org.freedesktop.NetworkManager.Sleep boolean:false || \
{ [ -x /bin/systemctl ] && systemctl start NetworkManager.service; } || service qubes-core-netvm start
if [ -f /var/run/qubes-service/network-manager ]; then
dbus-send --system --print-reply \
--dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager \
org.freedesktop.NetworkManager.Sleep boolean:false || \
{ [ -x /bin/systemctl ] && systemctl start NetworkManager.service; } || service qubes-core-netvm start
fi
fi