diff mbox series

[4/5] hurd: Simplify _S_catch_exception_raise

Message ID 20230414193700.542116-4-bugaevc@gmail.com
State New
Headers show
Series [1/5] hurd: Fix restoring reply port in sigreturn | expand

Commit Message

Sergey Bugaev April 14, 2023, 7:36 p.m. UTC
_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(-)

Comments

Samuel Thibault April 17, 2023, 11:24 p.m. UTC | #1
Applied, thanks!

Sergey Bugaev, le ven. 14 avril 2023 22:36:59 +0300, a ecrit:
> _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
>
diff mbox series

Patch

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))
     {