on xenial help sign in
Fix race with upstart socket
commit6b5af8018bb5ab8e07955a35c2ca9671451f4661 authorMichael Terry <michael.terry@canonical.com> dateTue 19 Jul 2016, 12:40 (10 years ago) parent8df7740
1 file changed+7−5
data/unity8-greeter-wrapper+7−5
data/unity8-greeter-wrapper+7−5
@@ -41,7 +41,7 @@ set_greeter_var()
4141SUB_SOCKET=$XDG_RUNTIME_DIR/mir_socket
4242rm -f $SUB_SOCKET # clear socket in case we were hard shut down
4343
44−rm -f "$XDG_RUNTIME_DIR/dbus-session"
44+echo "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}" >"$XDG_RUNTIME_DIR/dbus-session"
4545
4646# If touch session script (which sets up grid units and mir variables) is available, use it
4747TOUCH_WRAPPER=
@@ -66,11 +66,13 @@ set_greeter_var PA_DISABLED 1
6666MIR_SOCKET=$SUB_SOCKET $TOUCH_WRAPPER /sbin/upstart --user --no-startup-event &
6767INIT_PID=$!
6868while [ ! -e "$XDG_RUNTIME_DIR/upstart/sessions/$INIT_PID.session" ]; do sleep 0.1; done
69−export UPSTART_SESSION=$(/sbin/initctl list-sessions | grep "^$INIT_PID " | cut -d' ' -f2)
69+. "$XDG_RUNTIME_DIR/upstart/sessions/$INIT_PID.session"
70+export UPSTART_SESSION
7071
71−# Connect upstart to system.
72−echo "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}" >"$XDG_RUNTIME_DIR/dbus-session"
73−/sbin/initctl notify-dbus-address "$DBUS_SESSION_BUS_ADDRESS"
72+# Connect upstart to system, but do first command in a loop to avoid any
73+# race condition between the session file above being written and upstart being
74+# ready to handle requests.
75+while ! /sbin/initctl notify-dbus-address "$DBUS_SESSION_BUS_ADDRESS"; do sleep 0.1; done
7476/sbin/initctl start notify-cgmanager
7577
7678# Start any pre-greeter tasks if needed (like wizard)