mdnsd: cope better with large changes in time

Large changes in time can happen due to sleep, or long uptime.
Maybe calling the sleep hooks should be considered for a future fix.

Change-Id: I746c2176a9b36cbafd5679ec1529ad59f8b691b5
Reviewed-by: Daniel Molkentin <daniel.molkentin@nokia.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
Fawzi Mohamed
2012-03-27 19:32:03 +02:00
parent 332072019a
commit 4f239ff00d

View File

@@ -1441,6 +1441,12 @@ mDNSexport void mDNSPosixGetFDSet(mDNS *m, int *nfds, fd_set *readfds, struct ti
if (timeout->tv_sec > interval.tv_sec ||
(timeout->tv_sec == interval.tv_sec && timeout->tv_usec > interval.tv_usec))
*timeout = interval;
// cope well with vey large changes in time (for example after sleep)
if (timeout->tv_sec > 1000) timeout->tv_sec = 1000;
if (timeout->tv_usec > 999999) timeout->tv_usec = 999999;
// should not happen, but let's be paranoid...
if (timeout->tv_sec < 0) timeout->tv_sec = 0;
if (timeout->tv_usec < 0) timeout->tv_usec = 1000;
}
mDNSexport void mDNSPosixProcessFDSet(mDNS *const m, fd_set *readfds)