Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2017-06-01 12:24:37 +0300
committerFelix Fietkau <nbd@nbd.name>2017-06-01 12:24:44 +0300
commit368fd2645878edadc72c60948d1f19c6769751d6 (patch)
treeadae81a2dfe43e5d47f81715d150d0a0329c9f40 /uloop.c
parentfa9937cc4f8e60ddfc2dd9b5820eac49bef3de6e (diff)
uloop: allow specifying a timeout for uloop_run()
This can be useful for cleanup with pending timers, or for hooking into existing code that does not use uloop Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'uloop.c')
-rw-r--r--uloop.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/uloop.c b/uloop.c
index 26fef32..f503241 100644
--- a/uloop.c
+++ b/uloop.c
@@ -520,8 +520,9 @@ bool uloop_cancelling(void)
return uloop_run_depth > 0 && uloop_cancelled;
}
-int uloop_run(void)
+int uloop_run_timeout(int timeout)
{
+ int next_time = 0;
struct timeval tv;
/*
@@ -545,7 +546,11 @@ int uloop_run(void)
break;
uloop_gettime(&tv);
- uloop_run_events(uloop_get_next_timeout(&tv));
+
+ next_time = uloop_get_next_timeout(&tv);
+ if (timeout > 0 && next_time < timeout)
+ timeout = next_time;
+ uloop_run_events(timeout);
}
if (!--uloop_run_depth)