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>2023-05-23 16:09:33 +0300
committerFelix Fietkau <nbd@nbd.name>2023-05-23 16:32:36 +0300
commit362951a2d96e5c00a2ca5f9495d18cf16f43bc68 (patch)
treef87b3d9fed6c198681406e33dce4b792fd03c14e
parent5893cf78da4002eaf6caa01ff27134b3368c1161 (diff)
uloop: fix uloop_run_timeout
Avoid running infinite poll loop, fix timeout value Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--uloop.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/uloop.c b/uloop.c
index 0134fa4..d3135d6 100644
--- a/uloop.c
+++ b/uloop.c
@@ -557,8 +557,7 @@ int uloop_run_timeout(int timeout)
uloop_status = 0;
uloop_cancelled = false;
- while (!uloop_cancelled)
- {
+ do {
uloop_gettime(&tv);
uloop_process_timeouts(&tv);
@@ -571,10 +570,10 @@ int uloop_run_timeout(int timeout)
uloop_gettime(&tv);
next_time = uloop_get_next_timeout(&tv);
- if (timeout >= 0 && timeout < next_time)
- next_time = timeout;
+ if (timeout >= 0 && (next_time < 0 || timeout < next_time))
+ next_time = timeout;
uloop_run_events(next_time);
- }
+ } while (!uloop_cancelled && timeout < 0);
--uloop_run_depth;