mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 20:40:05 +00:00
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.
This commit is contained in:
parent
e008836c4a
commit
481d01fa2b
@ -37,6 +37,7 @@
|
|||||||
#include <not-cancel.h>
|
#include <not-cancel.h>
|
||||||
#include <kernel-features.h>
|
#include <kernel-features.h>
|
||||||
#include <nss.h>
|
#include <nss.h>
|
||||||
|
#include <struct___timespec64.h>
|
||||||
|
|
||||||
#include "nscd-client.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
|
/* Handle the case where the poll() call is interrupted by a
|
||||||
signal. We cannot just use TEMP_FAILURE_RETRY since it might
|
signal. We cannot just use TEMP_FAILURE_RETRY since it might
|
||||||
lead to infinite loops. */
|
lead to infinite loops. */
|
||||||
struct timespec now;
|
struct __timespec64 now;
|
||||||
__clock_gettime (CLOCK_REALTIME, &now);
|
__clock_gettime64 (CLOCK_REALTIME, &now);
|
||||||
long int end = (now.tv_sec * 1000 + usectmo
|
int64_t end = (now.tv_sec * 1000 + usectmo
|
||||||
+ (now.tv_nsec + 500000) / 1000000);
|
+ (now.tv_nsec + 500000) / 1000000);
|
||||||
long int timeout = usectmo;
|
long int timeout = usectmo;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -71,7 +72,7 @@ wait_on_socket (int sock, long int usectmo)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* Recompute the timeout time. */
|
/* Recompute the timeout time. */
|
||||||
__clock_gettime (CLOCK_REALTIME, &now);
|
__clock_gettime64 (CLOCK_REALTIME, &now);
|
||||||
timeout = end - ((now.tv_sec * 1000
|
timeout = end - ((now.tv_sec * 1000
|
||||||
+ (now.tv_nsec + 500000) / 1000000));
|
+ (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);
|
memcpy (reqdata->key, key, keylen);
|
||||||
|
|
||||||
bool first_try = true;
|
bool first_try = true;
|
||||||
struct timespec tvend = { 0, 0 };
|
struct __timespec64 tvend = { 0, 0 };
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
#ifndef MSG_NOSIGNAL
|
#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. */
|
/* The daemon is busy wait for it. */
|
||||||
int to;
|
int to;
|
||||||
struct timespec now;
|
struct __timespec64 now;
|
||||||
__clock_gettime (CLOCK_REALTIME, &now);
|
__clock_gettime64 (CLOCK_REALTIME, &now);
|
||||||
if (first_try)
|
if (first_try)
|
||||||
{
|
{
|
||||||
tvend.tv_nsec = now.tv_nsec;
|
tvend.tv_nsec = now.tv_nsec;
|
||||||
|
Loading…
Reference in New Issue
Block a user