forked from qt-creator/qt-creator
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:
@@ -1441,6 +1441,12 @@ mDNSexport void mDNSPosixGetFDSet(mDNS *m, int *nfds, fd_set *readfds, struct ti
|
|||||||
if (timeout->tv_sec > interval.tv_sec ||
|
if (timeout->tv_sec > interval.tv_sec ||
|
||||||
(timeout->tv_sec == interval.tv_sec && timeout->tv_usec > interval.tv_usec))
|
(timeout->tv_sec == interval.tv_sec && timeout->tv_usec > interval.tv_usec))
|
||||||
*timeout = interval;
|
*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)
|
mDNSexport void mDNSPosixProcessFDSet(mDNS *const m, fd_set *readfds)
|
||||||
|
Reference in New Issue
Block a user