diff --git a/release/src-rt-6.x.4708/router/miniupnpd/asyncsendto.c b/release/src-rt-6.x.4708/router/miniupnpd/asyncsendto.c index 5689f0b288..5e60a01a67 100644 --- a/release/src-rt-6.x.4708/router/miniupnpd/asyncsendto.c +++ b/release/src-rt-6.x.4708/router/miniupnpd/asyncsendto.c @@ -1,4 +1,4 @@ -/* $Id: asyncsendto.c,v 1.8 2017/05/24 22:51:57 nanard Exp $ */ +/* $Id: asyncsendto.c,v 1.9 2018/04/12 08:12:31 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2017 Thomas Bernard @@ -120,7 +120,7 @@ sendto_schedule2(int sockfd, const void *buf, size_t len, int flags, } /* schedule */ - if(gettimeofday(&tv, 0) < 0) { + if(upnp_gettimeofday(&tv) < 0) { return -1; } /* allocate enough space for structure + buffers */ @@ -283,7 +283,7 @@ void finalize_sendto(void) struct timeval timeout; int max_fd; - if(gettimeofday(&deadline, NULL) < 0) { + if(upnp_gettimeofday(&deadline) < 0) { syslog(LOG_ERR, "gettimeofday: %m"); return; } @@ -317,7 +317,7 @@ void finalize_sendto(void) free(elt); } /* check deadline */ - if(gettimeofday(&now, NULL) < 0) { + if(upnp_gettimeofday(&now) < 0) { syslog(LOG_ERR, "gettimeofday: %m"); return; } diff --git a/release/src-rt-6.x.4708/router/miniupnpd/miniupnpd.c b/release/src-rt-6.x.4708/router/miniupnpd/miniupnpd.c index df79199887..4912523a25 100644 --- a/release/src-rt-6.x.4708/router/miniupnpd/miniupnpd.c +++ b/release/src-rt-6.x.4708/router/miniupnpd/miniupnpd.c @@ -1,4 +1,4 @@ -/* $Id: miniupnpd.c,v 1.226 2018/03/13 10:35:55 nanard Exp $ */ +/* $Id: miniupnpd.c,v 1.227 2018/04/12 08:12:31 nanard Exp $ */ /* vim: tabstop=4 shiftwidth=4 noexpandtab * MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ @@ -2094,7 +2094,7 @@ main(int argc, char * * argv) } /* Check if we need to send SSDP NOTIFY messages and do it if * needed */ - if(gettimeofday(&timeofday, 0) < 0) + if(upnp_gettimeofday(&timeofday) < 0) { syslog(LOG_ERR, "gettimeofday(): %m"); timeout.tv_sec = v.notify_interval; diff --git a/release/src-rt-6.x.4708/router/miniupnpd/upnputils.c b/release/src-rt-6.x.4708/router/miniupnpd/upnputils.c index 010150f1a2..0bc25b43cc 100644 --- a/release/src-rt-6.x.4708/router/miniupnpd/upnputils.c +++ b/release/src-rt-6.x.4708/router/miniupnpd/upnputils.c @@ -1,4 +1,4 @@ -/* $Id: upnputils.c,v 1.12 2018/03/13 10:25:20 nanard Exp $ */ +/* $Id: upnputils.c,v 1.13 2018/04/12 08:12:34 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2018 Thomas Bernard @@ -220,3 +220,19 @@ time_t upnp_get_uptime(void) #endif return upnp_time() - startup_time; } + +int upnp_gettimeofday(struct timeval * tv) +{ +#if defined(CLOCK_MONOTONIC_FAST) || defined(CLOCK_MONOTONIC) + struct timespec ts; + int ret_code = clock_gettime(UPNP_CLOCKID, &ts); + if (ret_code == 0) + { + tv->tv_sec = ts.tv_sec; + tv->tv_usec = ts.tv_nsec / 1000; + } + return ret_code; +#else + return gettimeofday(tv, NULL); +#endif +} diff --git a/release/src-rt-6.x.4708/router/miniupnpd/upnputils.h b/release/src-rt-6.x.4708/router/miniupnpd/upnputils.h index 66f3fc924b..771f02d48f 100644 --- a/release/src-rt-6.x.4708/router/miniupnpd/upnputils.h +++ b/release/src-rt-6.x.4708/router/miniupnpd/upnputils.h @@ -1,4 +1,4 @@ -/* $Id: upnputils.h,v 1.9 2018/03/13 10:25:20 nanard Exp $ */ +/* $Id: upnputils.h,v 1.10 2018/04/12 08:12:34 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2011-2018 Thomas Bernard @@ -40,6 +40,12 @@ time_t upnp_time(void); */ time_t upnp_get_uptime(void); +/** + * get the time for upnp + * Similar to a monotonic gettimeofday(tv, NULL) + */ +int upnp_gettimeofday(struct timeval * tv); + /** * define portability macros */