Ensure that the babysitter thread already owns its one reference to the
babysitter when it starts up, and eliminates the race condition.
This patch requires that DBusBabysitter refcounting is thread-safe
and is based on an analysis and proposal of Simon Mc Vittie.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=95191
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
DBusBabysitter *sitter = (DBusBabysitter *) parameter;
PING();
- _dbus_babysitter_ref (sitter);
-
if (sitter->child_setup)
{
PING();
PING();
sitter_thread = (HANDLE) CreateThread (NULL, 0, babysitter,
- sitter, 0, &sitter_thread_id);
+ _dbus_babysitter_ref (sitter), 0, &sitter_thread_id);
if (sitter_thread == 0)
{