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-02-03 18:52:17 +0300
committerFelix Fietkau <nbd@nbd.name>2017-02-03 18:52:21 +0300
commitde3f14b643f09c799845073eaf3577a334d0726d (patch)
tree0e40bd9a5eb0f3316b155a3b07a513c919fb4a0e /uloop.c
parent3b6181b63d80e77c04a52d7439a87850eea1fe78 (diff)
uloop: add uloop_cancelling function
Returns true if uloop_run is still running and uloop_cancelled is set Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'uloop.c')
-rw-r--r--uloop.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/uloop.c b/uloop.c
index 1c5bcee..26fef32 100644
--- a/uloop.c
+++ b/uloop.c
@@ -63,6 +63,7 @@ static bool do_sigchld = false;
static struct uloop_fd_event cur_fds[ULOOP_MAX_EVENTS];
static int cur_fd, cur_nfds;
+static int uloop_run_depth = 0;
int uloop_fd_add(struct uloop_fd *sock, unsigned int flags);
@@ -514,16 +515,20 @@ static void uloop_clear_processes(void)
uloop_process_delete(p);
}
+bool uloop_cancelling(void)
+{
+ return uloop_run_depth > 0 && uloop_cancelled;
+}
+
int uloop_run(void)
{
- static int recursive_calls = 0;
struct timeval tv;
/*
* Handlers are only updated for the first call to uloop_run() (and restored
* when this call is done).
*/
- if (!recursive_calls++)
+ if (!uloop_run_depth++)
uloop_setup_signals(true);
uloop_status = 0;
@@ -543,7 +548,7 @@ int uloop_run(void)
uloop_run_events(uloop_get_next_timeout(&tv));
}
- if (!--recursive_calls)
+ if (!--uloop_run_depth)
uloop_setup_signals(false);
return uloop_status;