uloop: optimize uloop_timeout_set() implementaiton a bit.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
This commit is contained in:
parent
73c4b4fdfe
commit
08c27ceb01
1 changed files with 2 additions and 2 deletions
4
uloop.c
4
uloop.c
|
@ -453,14 +453,14 @@ int uloop_timeout_set(struct uloop_timeout *timeout, int msecs)
|
||||||
if (timeout->pending)
|
if (timeout->pending)
|
||||||
uloop_timeout_cancel(timeout);
|
uloop_timeout_cancel(timeout);
|
||||||
|
|
||||||
uloop_gettime(&timeout->time);
|
uloop_gettime(time);
|
||||||
|
|
||||||
time->tv_sec += msecs / 1000;
|
time->tv_sec += msecs / 1000;
|
||||||
time->tv_usec += (msecs % 1000) * 1000;
|
time->tv_usec += (msecs % 1000) * 1000;
|
||||||
|
|
||||||
if (time->tv_usec > 1000000) {
|
if (time->tv_usec > 1000000) {
|
||||||
time->tv_sec++;
|
time->tv_sec++;
|
||||||
time->tv_usec %= 1000000;
|
time->tv_usec -= 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
return uloop_timeout_add(timeout);
|
return uloop_timeout_add(timeout);
|
||||||
|
|
Loading…
Reference in a new issue