diff options
Diffstat (limited to 'sysdeps/posix/getaddrinfo.c')
-rw-r--r-- | sysdeps/posix/getaddrinfo.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 78a2474b10..2638736d17 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -1855,8 +1855,41 @@ static int gaiconf_reload_flag; static int gaiconf_reload_flag_ever_set; /* Last modification time. */ +#ifdef _STATBUF_ST_NSEC + static struct timespec gaiconf_mtime; +static inline void +save_gaiconf_mtime (const struct stat64 *st) +{ + gaiconf_mtime = st->st_mtim; +} + +static inline bool +check_gaiconf_mtime (const struct stat64 *st) +{ + return (st->st_mtim.tv_sec == gaiconf_mtime.tv_sec + && st->st_mtim.tv_nsec == gaiconf_mtime.tv_nsec); +} + +#else + +static time_t gaiconf_mtime; + +static inline void +save_gaiconf_mtime (const struct stat64 *st) +{ + gaiconf_mtime = st->st_mtime; +} + +static inline bool +check_gaiconf_mtime (const struct stat64 *st) +{ + return st->mtime == gaiconf_mtime; +} + +#endif + libc_freeres_fn(fini) { @@ -2298,7 +2331,7 @@ gaiconf_init (void) if (oldscope != default_scopes) free ((void *) oldscope); - gaiconf_mtime = st.st_mtim; + save_gaiconf_mtime (&st); } else { @@ -2320,7 +2353,7 @@ gaiconf_reload (void) { struct stat64 st; if (__xstat64 (_STAT_VER, GAICONF_FNAME, &st) != 0 - || memcmp (&st.st_mtim, &gaiconf_mtime, sizeof (gaiconf_mtime)) != 0) + || !check_gaiconf_mtime (&st)) gaiconf_init (); } |