Skip to content

Commit

Permalink
Flush the bus before exit
Browse files Browse the repository at this point in the history
This fixes a theoretical race condition that became less theoretical
with time.

When coupled with the inactivity timeout, it means that the process had
10 seconds to send the replies to method calls from the D-Bus worker
thread before the process would exit and the reply would be lost.  10
seconds is enough for anybody, right?

Unfortunately, the timeout was scheduled from the time each job was
started -- not ended.  Some jobs take longer than 10 seconds and
therefore systemd-shim was quitting immediately upon return to the
mainloop -- immediately after sending the reply to the worker.
  • Loading branch information
allisonkarlitskaya committed Nov 11, 2013
1 parent 6c65a11 commit 136ed11
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/systemd-shim.c
Expand Up @@ -32,7 +32,15 @@ exit_on_inactivity (gpointer user_data)
extern gboolean in_shutdown;

if (!in_shutdown)
exit (0);
{
GDBusConnection *session_bus;

session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
g_dbus_connection_flush_sync (session_bus, NULL, NULL);
g_object_unref (session_bus);

exit (0);
}

return FALSE;
}
Expand Down

0 comments on commit 136ed11

Please sign in to comment.