public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: Joseph Myers <joseph@codesourcery.com>,
	Alistair Francis <alistair23@gmail.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	GNU C Library <libc-alpha@sourceware.org>,
	Florian Weimer <fweimer@redhat.com>,
	Andreas Schwab <schwab@suse.de>
Subject: Re: [PATCH v2 4/5] y2038: nscd: Modify nscd_helper to use __clock_gettime64
Date: Fri, 1 May 2020 13:30:05 +0200	[thread overview]
Message-ID: <20200501133005.0338ac76@jawa> (raw)
In-Reply-To: <75a07d68-e303-b675-2230-5fc32637d9a6@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 3239 bytes --]

Hi Adhemerval,

> On 26/03/2020 05:06, Lukasz Majewski wrote:
> > 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.  
> 
> LGTM, thanks.
> 
> > ---
> >  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)
> >  	{  
> 
> Ok. Maybe we could use ppoll instead here to simplify the timeout
> calculation?
> 

I wanted to change as little as possible (to not introduce any extra
bugs) to only replace __clock_gettime with __clock_gettime64. 

> > @@ -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));
> >  	}  
> 
> Ok.
> 
> > @@ -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)
> >      {  
> 
> Ok.
> 
> >  #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;
> >   
> 
> Ok.




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-05-01 11:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26  8:06 [PATCH v2 0/5] y2038: Replace __clock_gettime with __clock_gettime64 Lukasz Majewski
2020-03-26  8:06 ` [PATCH v2 1/5] y2038: Export __clock_gettime64 to be usable in other libraries Lukasz Majewski
2020-03-26  8:06 ` [PATCH v2 2/5] y2038: hurd: Provide __clock_gettime64 function Lukasz Majewski
2020-03-26  8:06 ` [PATCH v2 3/5] y2038: inet: Convert inet deadline to support 64 bit time Lukasz Majewski
2020-04-30 20:51   ` Adhemerval Zanella
2020-03-26  8:06 ` [PATCH v2 4/5] y2038: nscd: Modify nscd_helper to use __clock_gettime64 Lukasz Majewski
2020-04-30 20:54   ` Adhemerval Zanella
2020-05-01 11:30     ` Lukasz Majewski [this message]
2020-05-04 12:27       ` Adhemerval Zanella
2020-05-04 15:26         ` Lukasz Majewski
2020-05-04 16:36           ` Adhemerval Zanella
2020-03-26  8:06 ` [PATCH v2 5/5] y2038: Replace __clock_gettime with __clock_gettime64 Lukasz Majewski
2020-04-06 16:07   ` Florian Weimer
2020-04-06 21:03     ` Lukasz Majewski
2020-04-14 12:14       ` Lukasz Majewski
2020-04-21 13:48         ` Lukasz Majewski
2020-04-29 21:48           ` Lukasz Majewski
2020-04-30 21:03   ` Adhemerval Zanella
2020-05-01 11:56     ` Lukasz Majewski
2020-05-04 14:04       ` Adhemerval Zanella
2020-05-04 15:32         ` Lukasz Majewski
2020-05-04 16:37           ` Adhemerval Zanella
2020-05-05 18:31         ` Lukasz Majewski
2020-04-06 15:16 ` [PATCH v2 0/5] " Lukasz Majewski

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=20200501133005.0338ac76@jawa \
    --to=lukma@denx.de \
    --cc=adhemerval.zanella@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.de \
    /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).