hurd: Make _hurd_libc_proc_init idempotent

For the cases where _init is getting called several times during startup. Better
clean pointers anyway.
This commit is contained in:
Samuel Thibault 2020-11-13 00:21:47 +00:00
parent 7beee7b39a
commit 946dcc6fde
1 changed files with 18 additions and 10 deletions

View File

@ -114,6 +114,8 @@ libc_hidden_def (_hurd_init)
void void
_hurd_libc_proc_init (char **argv) _hurd_libc_proc_init (char **argv)
{ {
if (_hurd_portarray)
{
/* Tell the proc server we exist, if it does. */ /* Tell the proc server we exist, if it does. */
if (_hurd_portarray[INIT_PORT_PROC] != MACH_PORT_NULL) if (_hurd_portarray[INIT_PORT_PROC] != MACH_PORT_NULL)
_hurd_new_proc_init (argv, _hurd_intarray, _hurd_intarraysize); _hurd_new_proc_init (argv, _hurd_intarray, _hurd_intarraysize);
@ -122,9 +124,15 @@ _hurd_libc_proc_init (char **argv)
__vm_deallocate (__mach_task_self (), __vm_deallocate (__mach_task_self (),
(vm_address_t) _hurd_intarray, (vm_address_t) _hurd_intarray,
_hurd_intarraysize * sizeof (int)); _hurd_intarraysize * sizeof (int));
_hurd_intarray = NULL;
_hurd_intarraysize = 0;
__vm_deallocate (__mach_task_self (), __vm_deallocate (__mach_task_self (),
(vm_address_t) _hurd_portarray, (vm_address_t) _hurd_portarray,
_hurd_portarraysize * sizeof (mach_port_t)); _hurd_portarraysize * sizeof (mach_port_t));
_hurd_portarray = NULL;
_hurd_portarraysize = 0;
}
} }
libc_hidden_def (_hurd_libc_proc_init) libc_hidden_def (_hurd_libc_proc_init)