ensure next timer event is in the future for recurrent timers
r1614 | dcl | 2007-03-08 16:23:57 +1100 (Thu, 08 Mar 2007) | 2 lines
This commit is contained in:
12
nwatch.c
12
nwatch.c
@@ -403,12 +403,24 @@ int NetWatchTask (void* pData)
|
||||
}
|
||||
NetWatchTimerRemQue(self, pNew);
|
||||
iStatus = pNew->func(pNew->cntx, 0);
|
||||
/*
|
||||
* If this is a recurrent timer and the function
|
||||
* indicates to keep it going, put it back in
|
||||
*/
|
||||
if (pNew->tick && iStatus == 1) {
|
||||
/*
|
||||
* While the expiration time is in the past, increment
|
||||
*/
|
||||
gettimeofday(&tv, NULL);
|
||||
while (tv.tv_sec > pNew->tv.tv_sec ||
|
||||
(tv.tv_sec == pNew->tv.tv_sec &&
|
||||
tv.tv_usec > pNew->tv.tv_usec)) {
|
||||
pNew->tv.tv_usec += 1000 * pNew->tick;
|
||||
if (pNew->tv.tv_usec > 1000000) {
|
||||
pNew->tv.tv_sec += pNew->tv.tv_usec / 1000000;
|
||||
pNew->tv.tv_usec %= 1000000;
|
||||
}
|
||||
}
|
||||
NetWatchTimerInsQue(self, pNew);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user