public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Sergey Bugaev <bugaevc@gmail.com>
To: libc-alpha@sourceware.org, bug-hurd@gnu.org
Cc: Samuel Thibault <samuel.thibault@gnu.org>,
	Sergey Bugaev <bugaevc@gmail.com>
Subject: [PATCH 4/5] hurd: Simplify _S_catch_exception_raise
Date: Fri, 14 Apr 2023 22:36:59 +0300	[thread overview]
Message-ID: <20230414193700.542116-4-bugaevc@gmail.com> (raw)
In-Reply-To: <20230414193700.542116-1-bugaevc@gmail.com>

_hurd_thread_sigstate () already handles finding an existing sigstate
before allocating a new one, so just use that. Bonus: this will only
lock the _hurd_siglock once.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
 hurd/catch-exc.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/hurd/catch-exc.c b/hurd/catch-exc.c
index 5ee2233a..d375bf67 100644
--- a/hurd/catch-exc.c
+++ b/hurd/catch-exc.c
@@ -58,13 +58,7 @@ _S_catch_exception_raise (mach_port_t port,
   _hurd_exception2signal (&d, &signo);
 
   /* Find the sigstate structure for the faulting thread.  */
-  __mutex_lock (&_hurd_siglock);
-  for (ss = _hurd_sigstates; ss != NULL; ss = ss->next)
-    if (ss->thread == thread)
-      break;
-  __mutex_unlock (&_hurd_siglock);
-  if (ss == NULL)
-    ss = _hurd_thread_sigstate (thread); /* Allocate a fresh one.  */
+  ss = _hurd_thread_sigstate (thread);
 
   if (__spin_lock_locked (&ss->lock))
     {
-- 
2.39.2


  parent reply	other threads:[~2023-04-14 19:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14 19:36 [PATCH 1/5] hurd: Fix restoring reply port in sigreturn Sergey Bugaev
2023-04-14 19:36 ` [PATCH 2/5] hurd: Microoptimize sigreturn Sergey Bugaev
2023-04-17 23:23   ` Samuel Thibault
2023-04-18  9:34     ` Sergey Bugaev
2023-04-18 10:21     ` [PATCH 2/5] hurd: Microoptimize sigreturn Sergey Bugaev
2023-04-18 14:21       ` Samuel Thibault
2023-04-14 19:36 ` [PATCH 3/5] hurd: Implement sigreturn for x86_64 Sergey Bugaev
2023-04-14 19:36 ` Sergey Bugaev [this message]
2023-04-17 23:24   ` [PATCH 4/5] hurd: Simplify _S_catch_exception_raise Samuel Thibault
2023-04-14 19:37 ` [PATCH 5/5] hurd: Avoid leaking task & thread ports Sergey Bugaev
2023-04-17 23:24   ` Samuel Thibault
2023-04-17 19:00 ` [PATCH 1/5] hurd: Fix restoring reply port in sigreturn Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230414193700.542116-4-bugaevc@gmail.com \
    --to=bugaevc@gmail.com \
    --cc=bug-hurd@gnu.org \
    --cc=libc-alpha@sourceware.org \
    --cc=samuel.thibault@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).