X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;ds=sidebyside;f=uloop.c;h=26fef32bd67b1818617e3b88ecaf34292badf0e5;hb=de3f14b643f09c799845073eaf3577a334d0726d;hp=0b75d4b3f4bd72f2d7fc33a918b09782c204d9a6;hpb=1ad3d93eb888ae7db3dd97e43e611979352b1aac;p=project%2Flibubox.git diff --git a/uloop.c b/uloop.c index 0b75d4b..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); @@ -387,7 +388,13 @@ static void uloop_handle_processes(void) static void uloop_signal_wake(void) { - write(waker_pipe, "w", 1); + do { + if (write(waker_pipe, "w", 1) < 0) { + if (errno == EINTR) + continue; + } + break; + } while (1); } static void uloop_handle_sigint(int signo) @@ -508,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; @@ -537,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;