public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] y2038: nscd: Modify nscd_helper to use __clock_gettime64
Date: Tue,  5 May 2020 22:57:53 +0000 (GMT)	[thread overview]
Message-ID: <20200505225753.34FA33891056@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=481d01fa2b07d3c6f9e6ef9ae239bc616b1ac757

commit 481d01fa2b07d3c6f9e6ef9ae239bc616b1ac757
Author: Lukasz Majewski <lukma@denx.de>
Date:   Mon Mar 16 13:50:23 2020 +0100

    y2038: nscd: Modify nscd_helper to use __clock_gettime64
    
    The nscd/nscd_helper.c uses __clock_gettime to get current time and on this
    basis calculate the relative timeout for poll.
    By using __clock_gettime64 on systems with __WORDSIZE == 32 && __TIMESIZE != 64
    the timeout is correctly calculated after time_t overflow.

Diff:
---
 nscd/nscd_helper.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c
index d2d7d15f26..a4f3312f90 100644
--- a/nscd/nscd_helper.c
+++ b/nscd/nscd_helper.c
@@ -37,6 +37,7 @@
 #include <not-cancel.h>
 #include <kernel-features.h>
 #include <nss.h>
+#include <struct___timespec64.h>
 
 #include "nscd-client.h"
 
@@ -59,10 +60,10 @@ wait_on_socket (int sock, long int usectmo)
       /* Handle the case where the poll() call is interrupted by a
 	 signal.  We cannot just use TEMP_FAILURE_RETRY since it might
 	 lead to infinite loops.  */
-      struct timespec now;
-      __clock_gettime (CLOCK_REALTIME, &now);
-      long int end = (now.tv_sec * 1000 + usectmo
-                      + (now.tv_nsec + 500000) / 1000000);
+      struct __timespec64 now;
+      __clock_gettime64 (CLOCK_REALTIME, &now);
+      int64_t end = (now.tv_sec * 1000 + usectmo
+                     + (now.tv_nsec + 500000) / 1000000);
       long int timeout = usectmo;
       while (1)
 	{
@@ -71,7 +72,7 @@ wait_on_socket (int sock, long int usectmo)
 	    break;
 
 	  /* Recompute the timeout time.  */
-          __clock_gettime (CLOCK_REALTIME, &now);
+          __clock_gettime64 (CLOCK_REALTIME, &now);
 	  timeout = end - ((now.tv_sec * 1000
                             + (now.tv_nsec + 500000) / 1000000));
 	}
@@ -193,7 +194,7 @@ open_socket (request_type type, const char *key, size_t keylen)
   memcpy (reqdata->key, key, keylen);
 
   bool first_try = true;
-  struct timespec tvend = { 0, 0 };
+  struct __timespec64 tvend = { 0, 0 };
   while (1)
     {
 #ifndef MSG_NOSIGNAL
@@ -212,8 +213,8 @@ open_socket (request_type type, const char *key, size_t keylen)
 
       /* The daemon is busy wait for it.  */
       int to;
-      struct timespec now;
-      __clock_gettime (CLOCK_REALTIME, &now);
+      struct __timespec64 now;
+      __clock_gettime64 (CLOCK_REALTIME, &now);
       if (first_try)
 	{
 	  tvend.tv_nsec = now.tv_nsec;


                 reply	other threads:[~2020-05-05 22:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200505225753.34FA33891056@sourceware.org \
    --to=lukma@sourceware.org \
    --cc=glibc-cvs@sourceware.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).