public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] Fix clock_nanosleep when interrupted by a signal
@ 2019-11-11 19:47 Adhemerval Zanella
  0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2019-11-11 19:47 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=42b926d303e571d5f9a4e97ffdb8e05d1eabae66

commit 42b926d303e571d5f9a4e97ffdb8e05d1eabae66
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Nov 11 13:28:37 2019 -0300

    Fix clock_nanosleep when interrupted by a signal
    
    This patch fixes the time64 support (added by 2e44b10b42d) where it
    misses the remaining argument updated if __NR_clock_nanosleep
    returns EINTR.
    
    Checked on i686-linux-gnu on 4.15 kernel (no time64 support) and
    on 5.3 kernel (with time64 support).
    
    Reviewed-by: Alistair Francis <alistair23@gmail.com>

Diff:
---
 sysdeps/unix/sysv/linux/clock_nanosleep.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c
index 60c61ee..fc47c58 100644
--- a/sysdeps/unix/sysv/linux/clock_nanosleep.c
+++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c
@@ -52,13 +52,10 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec
   r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, err, clock_id,
                                flags, req, rem);
 
-  if (r == 0 || errno != ENOSYS)
-    {
-      return (INTERNAL_SYSCALL_ERROR_P (r, err)
-              ? INTERNAL_SYSCALL_ERRNO (r, err) : 0);
-    }
+  if (r != -ENOSYS)
+    return (INTERNAL_SYSCALL_ERROR_P (r, err)
+            ? INTERNAL_SYSCALL_ERRNO (r, err) : 0);
 # endif /* __NR_clock_nanosleep_time64 */
-  struct timespec ts32, tr32;
 
   if (! in_time_t_range (req->tv_sec))
     {
@@ -66,11 +63,12 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec
       return -1;
     }
 
-  ts32 = valid_timespec64_to_timespec (*req);
+  struct timespec tr32;
+  struct timespec ts32 = valid_timespec64_to_timespec (*req);
   r =  INTERNAL_SYSCALL_CANCEL (clock_nanosleep, err, clock_id, flags,
                                 &ts32, &tr32);
 
-  if (r == 0 && rem != NULL)
+  if (r == -EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0)
     *rem = valid_timespec_to_timespec64 (tr32);
 #endif /* __ASSUME_TIME64_SYSCALLS */
 
@@ -89,7 +87,7 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
   treq64 = valid_timespec_to_timespec64 (*req);
   r = __clock_nanosleep_time64 (clock_id, flags, &treq64, &trem64);
 
-  if (r == 0 && rem != NULL)
+  if (r == EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0)
     *rem = valid_timespec64_to_timespec (trem64);
 
   return r;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-11 19:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 19:47 [glibc] Fix clock_nanosleep when interrupted by a signal Adhemerval Zanella

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