miniupnpd: updated to 2.0.20180412

Fixed "Switching to use of a monotonic clock": https://github.com/miniupnp/miniupnp/issues/288
arm-ng
kille72 8 years ago
parent 91570d8c5c
commit a0a0205878

@ -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 /* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2017 Thomas Bernard * (c) 2006-2017 Thomas Bernard
@ -120,7 +120,7 @@ sendto_schedule2(int sockfd, const void *buf, size_t len, int flags,
} }
/* schedule */ /* schedule */
if(gettimeofday(&tv, 0) < 0) { if(upnp_gettimeofday(&tv) < 0) {
return -1; return -1;
} }
/* allocate enough space for structure + buffers */ /* allocate enough space for structure + buffers */
@ -283,7 +283,7 @@ void finalize_sendto(void)
struct timeval timeout; struct timeval timeout;
int max_fd; int max_fd;
if(gettimeofday(&deadline, NULL) < 0) { if(upnp_gettimeofday(&deadline) < 0) {
syslog(LOG_ERR, "gettimeofday: %m"); syslog(LOG_ERR, "gettimeofday: %m");
return; return;
} }
@ -317,7 +317,7 @@ void finalize_sendto(void)
free(elt); free(elt);
} }
/* check deadline */ /* check deadline */
if(gettimeofday(&now, NULL) < 0) { if(upnp_gettimeofday(&now) < 0) {
syslog(LOG_ERR, "gettimeofday: %m"); syslog(LOG_ERR, "gettimeofday: %m");
return; return;
} }

@ -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 /* vim: tabstop=4 shiftwidth=4 noexpandtab
* MiniUPnP project * MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * 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 /* Check if we need to send SSDP NOTIFY messages and do it if
* needed */ * needed */
if(gettimeofday(&timeofday, 0) < 0) if(upnp_gettimeofday(&timeofday) < 0)
{ {
syslog(LOG_ERR, "gettimeofday(): %m"); syslog(LOG_ERR, "gettimeofday(): %m");
timeout.tv_sec = v.notify_interval; timeout.tv_sec = v.notify_interval;

@ -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 /* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2018 Thomas Bernard * (c) 2006-2018 Thomas Bernard
@ -220,3 +220,19 @@ time_t upnp_get_uptime(void)
#endif #endif
return upnp_time() - startup_time; 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
}

@ -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 /* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2011-2018 Thomas Bernard * (c) 2011-2018 Thomas Bernard
@ -40,6 +40,12 @@ time_t upnp_time(void);
*/ */
time_t upnp_get_uptime(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 * define portability macros
*/ */

Loading…
Cancel
Save