From patchwork Fri Nov 13 00:24:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 41037 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4869F386F443; Fri, 13 Nov 2020 00:24:37 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [IPv6:2a0c:e300::1]) by sourceware.org (Postfix) with ESMTPS id 4DA363861035 for ; Fri, 13 Nov 2020 00:24:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4DA363861035 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=samuel.thibault@ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 53D59DD5; Fri, 13 Nov 2020 01:24:32 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2a3o0E8gkbsj; Fri, 13 Nov 2020 01:24:31 +0100 (CET) Received: from function.youpi.perso.aquilenet.fr (unknown [IPv6:2a01:cb19:956:1b00:9eb6:d0ff:fe88:c3c7]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 9FBB5D93; Fri, 13 Nov 2020 01:24:31 +0100 (CET) Received: from samy by function.youpi.perso.aquilenet.fr with local (Exim 4.94) (envelope-from ) id 1kdMtC-005h9f-1M; Fri, 13 Nov 2020 01:24:30 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd,commited] hurd: Make _hurd_libc_proc_init idempotent Date: Fri, 13 Nov 2020 01:24:27 +0100 Message-Id: <20201113002427.1357486-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" For the cases where _init is getting called several times during startup. Better clean pointers anyway. --- hurd/hurdinit.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/hurd/hurdinit.c b/hurd/hurdinit.c index e4ec005b48..06a2d3b7fd 100644 --- a/hurd/hurdinit.c +++ b/hurd/hurdinit.c @@ -114,17 +114,25 @@ libc_hidden_def (_hurd_init) void _hurd_libc_proc_init (char **argv) { - /* Tell the proc server we exist, if it does. */ - if (_hurd_portarray[INIT_PORT_PROC] != MACH_PORT_NULL) - _hurd_new_proc_init (argv, _hurd_intarray, _hurd_intarraysize); - - /* All done with init ints and ports. */ - __vm_deallocate (__mach_task_self (), - (vm_address_t) _hurd_intarray, - _hurd_intarraysize * sizeof (int)); - __vm_deallocate (__mach_task_self (), - (vm_address_t) _hurd_portarray, - _hurd_portarraysize * sizeof (mach_port_t)); + if (_hurd_portarray) + { + /* Tell the proc server we exist, if it does. */ + if (_hurd_portarray[INIT_PORT_PROC] != MACH_PORT_NULL) + _hurd_new_proc_init (argv, _hurd_intarray, _hurd_intarraysize); + + /* All done with init ints and ports. */ + __vm_deallocate (__mach_task_self (), + (vm_address_t) _hurd_intarray, + _hurd_intarraysize * sizeof (int)); + _hurd_intarray = NULL; + _hurd_intarraysize = 0; + + __vm_deallocate (__mach_task_self (), + (vm_address_t) _hurd_portarray, + _hurd_portarraysize * sizeof (mach_port_t)); + _hurd_portarray = NULL; + _hurd_portarraysize = 0; + } } libc_hidden_def (_hurd_libc_proc_init)