Commit 5b72329d authored by Simon McVittie's avatar Simon McVittie Committed by Ralf

dbus-spawn-win: Move _dbus_spawn_program() to main thread

We would like to stop taking ownership of envp, but we can't do that
without a deep copy if a different thread might still be using it
(asynchronously) after the main thread has returned from
_dbus_spawn_async_with_babysitter().

Originally part of a larger commit by Ralf Habacker.
Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
parent fb748412
...@@ -600,26 +600,7 @@ babysitter (void *parameter) ...@@ -600,26 +600,7 @@ babysitter (void *parameter)
{ {
int ret = 0; int ret = 0;
DBusBabysitter *sitter = (DBusBabysitter *) parameter; DBusBabysitter *sitter = (DBusBabysitter *) parameter;
HANDLE handle;
PING();
_dbus_verbose ("babysitter: spawning %s\n", sitter->log_name);
PING();
handle = _dbus_spawn_program (sitter->log_name, sitter->argv, sitter->envp);
PING();
if (handle != INVALID_HANDLE_VALUE)
{
sitter->child_handle = handle;
}
else
{
sitter->child_handle = NULL;
sitter->have_spawn_errno = TRUE;
sitter->spawn_errno = GetLastError();
}
PING(); PING();
SetEvent (sitter->start_sync_event); SetEvent (sitter->start_sync_event);
...@@ -663,7 +644,8 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, ...@@ -663,7 +644,8 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p,
{ {
DBusBabysitter *sitter; DBusBabysitter *sitter;
DWORD sitter_thread_id; DWORD sitter_thread_id;
HANDLE handle;
_DBUS_ASSERT_ERROR_IS_CLEAR (error); _DBUS_ASSERT_ERROR_IS_CLEAR (error);
_dbus_assert (argv[0] != NULL); _dbus_assert (argv[0] != NULL);
...@@ -731,6 +713,24 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, ...@@ -731,6 +713,24 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p,
} }
sitter->envp = envp; sitter->envp = envp;
PING();
_dbus_verbose ("babysitter: spawn child '%s'\n", sitter->argv[0]);
PING();
handle = _dbus_spawn_program (sitter->log_name, sitter->argv, sitter->envp);
PING();
if (handle != INVALID_HANDLE_VALUE)
{
sitter->child_handle = handle;
}
else
{
sitter->child_handle = NULL;
sitter->have_spawn_errno = TRUE;
sitter->spawn_errno = GetLastError();
}
PING(); PING();
sitter->thread_handle = (HANDLE) CreateThread (NULL, 0, babysitter, sitter->thread_handle = (HANDLE) CreateThread (NULL, 0, babysitter,
_dbus_babysitter_ref (sitter), 0, &sitter_thread_id); _dbus_babysitter_ref (sitter), 0, &sitter_thread_id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment