From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id 42A63383E838 for ; Mon, 4 May 2020 15:26:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 42A63383E838 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 49G6Bs5xBlz1s8NS; Mon, 4 May 2020 17:26:13 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 49G6Bs35G7z1qqlC; Mon, 4 May 2020 17:26:13 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id KKgwgqxEJntC; Mon, 4 May 2020 17:26:12 +0200 (CEST) X-Auth-Info: 9KXXyVq3+gPOcdKvjLwdusFVqkvMskcb7SVmMdSMOrE= Received: from jawa (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Mon, 4 May 2020 17:26:12 +0200 (CEST) Date: Mon, 4 May 2020 17:26:04 +0200 From: Lukasz Majewski To: Adhemerval Zanella Cc: Joseph Myers , Alistair Francis , Alistair Francis , GNU C Library , Florian Weimer , Andreas Schwab Subject: Re: [PATCH v2 4/5] y2038: nscd: Modify nscd_helper to use __clock_gettime64 Message-ID: <20200504172604.5e5c4d68@jawa> In-Reply-To: References: <20200326080641.10193-1-lukma@denx.de> <20200326080641.10193-5-lukma@denx.de> <75a07d68-e303-b675-2230-5fc32637d9a6@linaro.org> <20200501133005.0338ac76@jawa> Organization: denx.de X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/5D2QIwzzROaI.L5PSejrK=+"; protocol="application/pgp-signature" X-Spam-Status: No, score=-24.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2020 15:26:17 -0000 --Sig_/5D2QIwzzROaI.L5PSejrK=+ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Adhemerval, > On 01/05/2020 08:30, Lukasz Majewski wrote: > > Hi Adhemerval, > > =20 > >> On 26/03/2020 05:06, Lukasz Majewski wrote: =20 > >>> 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 =3D=3D 32 && > >>> __TIMESIZE !=3D 64 the timeout is correctly calculated after time_t > >>> overflow. =20 > >> > >> LGTM, thanks. > >> =20 > >>> --- > >>> 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 > >>> #include > >>> #include > >>> +#include > >>> =20 > >>> #include "nscd-client.h" > >>> =20 > >>> @@ -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 =3D (now.tv_sec * 1000 + usectmo > >>> - + (now.tv_nsec + 500000) / 1000000); > >>> + struct __timespec64 now; > >>> + __clock_gettime64 (CLOCK_REALTIME, &now); > >>> + int64_t end =3D (now.tv_sec * 1000 + usectmo > >>> + + (now.tv_nsec + 500000) / 1000000); > >>> long int timeout =3D usectmo; > >>> while (1) > >>> { =20 > >> > >> Ok. Maybe we could use ppoll instead here to simplify the timeout > >> calculation? > >> =20 > >=20 > > I wanted to change as little as possible (to not introduce any extra > > bugs) to only replace __clock_gettime with __clock_gettime64. =20 >=20 > I don't have a strong opinion here, it is just that it might > simplifies a bit the timeout handling. If you don't mind I would prefer to change as little as possible and stick to the approach (changes) proposed in this patch. Do you agree with such approach? >=20 > > =20 > >>> @@ -71,7 +72,7 @@ wait_on_socket (int sock, long int usectmo) > >>> break; > >>> =20 > >>> /* Recompute the timeout time. */ > >>> - __clock_gettime (CLOCK_REALTIME, &now); > >>> + __clock_gettime64 (CLOCK_REALTIME, &now); > >>> timeout =3D end - ((now.tv_sec * 1000 > >>> + (now.tv_nsec + 500000) / 1000000)); > >>> } =20 > >> > >> Ok. > >> =20 > >>> @@ -193,7 +194,7 @@ open_socket (request_type type, const char > >>> *key, size_t keylen) memcpy (reqdata->key, key, keylen); > >>> =20 > >>> bool first_try =3D true; > >>> - struct timespec tvend =3D { 0, 0 }; > >>> + struct __timespec64 tvend =3D { 0, 0 }; > >>> while (1) > >>> { =20 > >> > >> Ok. > >> =20 > >>> #ifndef MSG_NOSIGNAL > >>> @@ -212,8 +213,8 @@ open_socket (request_type type, const char > >>> *key, size_t keylen)=20 > >>> /* 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 =3D now.tv_nsec; > >>> =20 > >> > >> Ok. =20 > >=20 > >=20 > >=20 > >=20 > > Best regards, > >=20 > > Lukasz Majewski > >=20 > > -- > >=20 > > 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=20 >=20 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 --Sig_/5D2QIwzzROaI.L5PSejrK=+ Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAl6wNAwACgkQAR8vZIA0 zr3hOgf/SgG9XCbNsnqfFLYdFoVEQ9iB19sbqAQ8zfdv1WHtB5N6H4WYsyqtqzcf NAnW+pWYnLGC+qEMOoy63VDPPdiRYjwPGr8Rc4/3MJhMDpQvjVDxXPhbeOJnTANp B+u9X9ohjswMIireh2525QboDp5UhEGb6ZWvEwHkSnVOfuwjeJpmo1BpQAxmzo2z Y6YLYEOued3ERieSfwRtcxw8dOxtEZ/K1MbFBdHRh1fksxThCvS1afvIYNS+INn6 FKlBzip1oiqrAmQatKFl+8xWX8yjr28GFKFaqAT1w4FyOofstO2b9OXtHwk4vL7m XLWkOkKiFGt+IZ0ESHjl7m83zYyRtQ== =GMNJ -----END PGP SIGNATURE----- --Sig_/5D2QIwzzROaI.L5PSejrK=+--