about summary refs log tree commit diff
path: root/sysdeps/htl
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2020-06-23 22:41:18 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2020-06-24 01:19:48 +0200
commit3513d5af3d111f322cf2b64f2c7d415ea923bf25 (patch)
treefde72af3880def5877c8a91688cfb03e233ab156 /sysdeps/htl
parent9f6e508b4270093607676361e68dfd7a0bf91492 (diff)
downloadglibc-3513d5af3d111f322cf2b64f2c7d415ea923bf25.tar.gz
glibc-3513d5af3d111f322cf2b64f2c7d415ea923bf25.tar.xz
glibc-3513d5af3d111f322cf2b64f2c7d415ea923bf25.zip
htl: Simplify non-cancel path of __pthread_cond_timedwait_internal
Since __pthread_exit does not return, we do not need to indent the
noncancel path

* sysdeps/htl/pt-cond-timedwait.c (__pthread_cond_timedwait_internal):
Move cancelled path before non-cancelled path, to avoid "else"
indentation.
Diffstat (limited to 'sysdeps/htl')
-rw-r--r--sysdeps/htl/pt-cond-timedwait.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/sysdeps/htl/pt-cond-timedwait.c b/sysdeps/htl/pt-cond-timedwait.c
index c05944d16d..f7801b30ae 100644
--- a/sysdeps/htl/pt-cond-timedwait.c
+++ b/sysdeps/htl/pt-cond-timedwait.c
@@ -117,29 +117,30 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond,
   cancelled = (self->cancel_state == PTHREAD_CANCEL_ENABLE)
       && self->cancel_pending;
 
-  if (!cancelled)
+  if (cancelled)
     {
-      self->cancel_hook = cancel_hook;
-      self->cancel_hook_arg = &ctx;
-      oldtype = self->cancel_type;
-
-      if (oldtype != PTHREAD_CANCEL_DEFERRED)
-	self->cancel_type = PTHREAD_CANCEL_DEFERRED;
-
-      /* Add ourselves to the list of waiters.  This is done while setting
-         the cancellation hook to simplify the cancellation procedure, i.e.
-         if the thread is queued, it can be cancelled, otherwise it is
-         already unblocked, progressing on the return path.  */
-      __pthread_spin_wait (&cond->__lock);
-      __pthread_enqueue (&cond->__queue, self);
-      if (cond->__attr != NULL && clockid == -1)
-	clock_id = cond->__attr->__clock;
-      __pthread_spin_unlock (&cond->__lock);
+      __pthread_mutex_unlock (&self->cancel_lock);
+      __pthread_exit (PTHREAD_CANCELED);
     }
-  __pthread_mutex_unlock (&self->cancel_lock);
 
-  if (cancelled)
-    __pthread_exit (PTHREAD_CANCELED);
+  self->cancel_hook = cancel_hook;
+  self->cancel_hook_arg = &ctx;
+  oldtype = self->cancel_type;
+
+  if (oldtype != PTHREAD_CANCEL_DEFERRED)
+    self->cancel_type = PTHREAD_CANCEL_DEFERRED;
+
+  /* Add ourselves to the list of waiters.  This is done while setting
+     the cancellation hook to simplify the cancellation procedure, i.e.
+     if the thread is queued, it can be cancelled, otherwise it is
+     already unblocked, progressing on the return path.  */
+  __pthread_spin_wait (&cond->__lock);
+  __pthread_enqueue (&cond->__queue, self);
+  if (cond->__attr != NULL && clockid == -1)
+    clock_id = cond->__attr->__clock;
+  __pthread_spin_unlock (&cond->__lock);
+
+  __pthread_mutex_unlock (&self->cancel_lock);
 
   /* Release MUTEX before blocking.  */
   __pthread_mutex_unlock (mutex);