From patchwork Tue Mar 24 13:18:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 38603 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id D0B5B385B834 for ; Tue, 24 Mar 2020 13:18:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D0B5B385B834 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 48msJm6Gfzz1qs3w; Tue, 24 Mar 2020 14:18:48 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 48msJm5Ybbz1r0bv; Tue, 24 Mar 2020 14:18:48 +0100 (CET) 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 KLdUUs7HqHcn; Tue, 24 Mar 2020 14:18:47 +0100 (CET) X-Auth-Info: +ucURvOxm0FMQGrohJWBlhVkiHZ4wjXq1E2cnAZE1xE= Received: from localhost.localdomain (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; Tue, 24 Mar 2020 14:18:47 +0100 (CET) From: Lukasz Majewski To: Joseph Myers , Adhemerval Zanella Cc: Alistair Francis , Alistair Francis , GNU C Library , Florian Weimer , Andreas Schwab , Lukasz Majewski Subject: [PATCH 4/5] y2038: nscd: Modify nscd_helper to use __clock_gettime64 Date: Tue, 24 Mar 2020 14:18:20 +0100 Message-Id: <20200324131821.22048-5-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324131821.22048-1-lukma@denx.de> References: <20200324131821.22048-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-30.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, 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: Tue, 24 Mar 2020 13:18:51 -0000 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. Reviewed-by: Alistair Francis --- 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 #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;