[hurd,commited] hurd: Take cancel_lock in critical section

Samuel Thibault <[email protected]>
Newsgroups gmane.os.hurd.cvs,gmane.comp.lib.glibc.alpha
Message-ID <[email protected]>
read/write etc. shall be signal-safe, and take cancel_lock, so we have to
defer signal delivery while holding cancel_lock.

Reported-by: Brent Baccala <[email protected]> 's Claude assistant
---
 sysdeps/htl/pt-cond-timedwait.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sysdeps/htl/pt-cond-timedwait.c b/sysdeps/htl/pt-cond-timedwait.c
index d350868c2b..7a5287ca9f 100644
--- a/sysdeps/htl/pt-cond-timedwait.c
+++ b/sysdeps/htl/pt-cond-timedwait.c
@@ -205,6 +205,7 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond,
 
   /* We're almost done.  Remove the unblock hook, restore the previous
      cancellation type, and check for a pending cancellation request.  */
+  HURD_CRITICAL_BEGIN;
   __pthread_mutex_lock (&self->cancel_lock);
   self->cancel_hook = NULL;
   self->cancel_hook_arg = NULL;
@@ -212,6 +213,7 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond,
   cancelled = (self->cancel_state == PTHREAD_CANCEL_ENABLE)
       && self->cancel_pending;
   __pthread_mutex_unlock (&self->cancel_lock);
+  HURD_CRITICAL_END;
 
   /* Reacquire MUTEX before returning/cancelling.  */
   __pthread_mutex_lock (mutex);
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.