dbus-spawn-win.c: Move out argv copy from DBusSitter struct

Since the child program is started in the main thread, there is no
need to pass a copy of argv to the thread waiting for the child's
termination.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
This commit is contained in:
Ralf Habacker 2018-12-21 16:38:02 +01:00 committed by Ralf
parent 88032367a9
commit 61c76cae02

View file

@ -66,9 +66,6 @@ struct DBusBabysitter
char *log_name;
int argc;
char **argv;
HANDLE thread_handle;
HANDLE child_handle;
DBusSocket socket_to_babysitter; /* Connection to the babysitter thread */
@ -124,9 +121,6 @@ _dbus_babysitter_new (void)
sitter->socket_to_babysitter = sitter->socket_to_main = _dbus_socket_get_invalid ();
sitter->argc = 0;
sitter->argv = NULL;
sitter->watches = _dbus_watch_list_new ();
if (sitter->watches == NULL)
{
@ -189,7 +183,6 @@ close_socket_to_babysitter (DBusBabysitter *sitter)
void
_dbus_babysitter_unref (DBusBabysitter *sitter)
{
int i;
dbus_int32_t old_refcount;
PING();
@ -209,19 +202,6 @@ _dbus_babysitter_unref (DBusBabysitter *sitter)
sitter->socket_to_main.sock = INVALID_SOCKET;
}
PING();
if (sitter->argv != NULL)
{
for (i = 0; i < sitter->argc; i++)
if (sitter->argv[i] != NULL)
{
dbus_free (sitter->argv[i]);
sitter->argv[i] = NULL;
}
dbus_free (sitter->argv);
sitter->argv = NULL;
}
if (sitter->child_handle != NULL)
{
CloseHandle (sitter->child_handle);
@ -633,6 +613,8 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p,
DBusBabysitter *sitter;
DWORD sitter_thread_id;
HANDLE handle;
int argc;
char **my_argv = NULL;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
_dbus_assert (argv[0] != NULL);
@ -693,19 +675,22 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p,
goto out0;
}
sitter->argc = protect_argv (argv, &sitter->argv);
if (sitter->argc == -1)
argc = protect_argv (argv, &my_argv);
if (argc == -1)
{
_DBUS_SET_OOM (error);
goto out0;
}
PING();
_dbus_verbose ("babysitter: spawn child '%s'\n", sitter->argv[0]);
_dbus_verbose ("babysitter: spawn child '%s'\n", my_argv[0]);
PING();
handle = _dbus_spawn_program (sitter->log_name, sitter->argv,
(char **) envp);
handle = _dbus_spawn_program (sitter->log_name, my_argv, (char **) envp);
if (my_argv != NULL)
{
dbus_free_string_array (my_argv);
}
PING();
if (handle != INVALID_HANDLE_VALUE)