From patchwork Sat Sep 25 23:05:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 45438 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 4177F3857C67 for ; Sat, 25 Sep 2021 23:06:10 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1]) by sourceware.org (Postfix) with ESMTPS id A18ED3858404 for ; Sat, 25 Sep 2021 23:05:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A18ED3858404 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 6E62A4F8; Sun, 26 Sep 2021 01:05:56 +0200 (CEST) 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 ADQlE08wWjap; Sun, 26 Sep 2021 01:05:55 +0200 (CEST) Received: from begin.home (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 94D20E0; Sun, 26 Sep 2021 01:05:55 +0200 (CEST) Received: from samy by begin.home with local (Exim 4.95-RC2) (envelope-from ) id 1mUGjs-00AVlo-O2; Sun, 26 Sep 2021 01:05:48 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd, commited] htl: make pthread_sigstate read/write set/oset outside sigstate section Date: Sun, 26 Sep 2021 01:05:48 +0200 Message-Id: <20210925230548.2505397-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Spamd-Bar: ++ X-Rspamd-Server: hera Authentication-Results: hera.aquilenet.fr X-Rspamd-Queue-Id: 6E62A4F8 X-Spamd-Result: default: False [2.49 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; MID_CONTAINS_FROM(1.00)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; BAYES_HAM(-2.51)[97.78%] X-Spam-Status: No, score=-11.8 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" so that if a segfault occurs, the handler can run fine. --- sysdeps/mach/hurd/htl/pt-sigstate.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sysdeps/mach/hurd/htl/pt-sigstate.c b/sysdeps/mach/hurd/htl/pt-sigstate.c index 85abf81dec..7bc9fb7b77 100644 --- a/sysdeps/mach/hurd/htl/pt-sigstate.c +++ b/sysdeps/mach/hurd/htl/pt-sigstate.c @@ -30,30 +30,33 @@ __pthread_sigstate (struct __pthread *thread, int how, { error_t err = 0; struct hurd_sigstate *ss; + sigset_t old, new; sigset_t pending; + if (set != NULL) + new = *set; + ss = _hurd_thread_sigstate (thread->kernel_thread); assert (ss); _hurd_sigstate_lock (ss); - if (oset != NULL) - *oset = ss->blocked; + old = ss->blocked; if (set != NULL) { switch (how) { case SIG_BLOCK: - ss->blocked |= *set; + ss->blocked |= new; break; case SIG_SETMASK: - ss->blocked = *set; + ss->blocked = new; break; case SIG_UNBLOCK: - ss->blocked &= ~*set; + ss->blocked &= ~new; break; default: @@ -69,6 +72,9 @@ __pthread_sigstate (struct __pthread *thread, int how, pending = _hurd_sigstate_pending (ss) & ~ss->blocked; _hurd_sigstate_unlock (ss); + if (!err && oset != NULL) + *oset = old; + if (!err && pending) /* Send a message to the signal thread so it will wake up and check for pending signals. */