diff options
author | Simon McVittie <smcv@collabora.com> | 2018-12-20 15:17:13 +0000 |
---|---|---|
committer | Ralf <ralf@linux1.fritz.box> | 2019-01-05 11:41:58 +0100 |
commit | 5b72329d7d5947e0613a69a4b2d69975bd4a5b46 (patch) | |
tree | d99964590c7281785c489dca784d28598c960bc4 /dbus | |
parent | fb7484121affa61715dfff8086c9147a4509f8c5 (diff) | |
download | dbus-5b72329d7d5947e0613a69a4b2d69975bd4a5b46.tar.gz |
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 <smcv@collabora.com>
Diffstat (limited to 'dbus')
-rw-r--r-- | dbus/dbus-spawn-win.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index 5ad561c2..c4b356c5 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -600,27 +600,8 @@ babysitter (void *parameter) { int ret = 0; 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(); SetEvent (sitter->start_sync_event); if (sitter->child_handle != NULL) @@ -663,7 +644,8 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, { DBusBabysitter *sitter; DWORD sitter_thread_id; - + HANDLE handle; + _DBUS_ASSERT_ERROR_IS_CLEAR (error); _dbus_assert (argv[0] != NULL); @@ -732,6 +714,24 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, 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(); sitter->thread_handle = (HANDLE) CreateThread (NULL, 0, babysitter, _dbus_babysitter_ref (sitter), 0, &sitter_thread_id); |