remove uhtbl - i don't think we will need it
[project/libubox.git] / uloop.c
diff --git a/uloop.c b/uloop.c
index ec37925..4be5f45 100644 (file)
--- a/uloop.c
+++ b/uloop.c
@@ -48,7 +48,7 @@
 
 struct uloop_timeout *first_timeout;
 static int poll_fd;
 
 struct uloop_timeout *first_timeout;
 static int poll_fd;
-static bool cancel;
+bool uloop_cancelled = false;
 
 #ifdef USE_KQUEUE
 
 
 #ifdef USE_KQUEUE
 
@@ -94,7 +94,7 @@ static int register_poll(struct uloop_fd *fd, unsigned int flags)
 
        if (changed & ULOOP_WRITE) {
                uint16_t kflags = get_flags(flags, ULOOP_WRITE);
 
        if (changed & ULOOP_WRITE) {
                uint16_t kflags = get_flags(flags, ULOOP_WRITE);
-               EV_SET(&ev[nev++], fd->fd, EVFILT_READ, kflags, 0, 0, fd);
+               EV_SET(&ev[nev++], fd->fd, EVFILT_WRITE, kflags, 0, 0, fd);
        }
 
        if (nev && (kevent(poll_fd, ev, nev, NULL, 0, &timeout) == -1))
        }
 
        if (nev && (kevent(poll_fd, ev, nev, NULL, 0, &timeout) == -1))
@@ -236,7 +236,7 @@ int uloop_fd_add(struct uloop_fd *sock, unsigned int flags)
        unsigned int fl;
        int ret;
 
        unsigned int fl;
        int ret;
 
-       if (!sock->registered) {
+       if (!sock->registered && !(flags & ULOOP_BLOCKING)) {
                fl = fcntl(sock->fd, F_GETFL, 0);
                fl |= O_NONBLOCK;
                fcntl(sock->fd, F_SETFL, fl);
                fl = fcntl(sock->fd, F_GETFL, 0);
                fl |= O_NONBLOCK;
                fcntl(sock->fd, F_SETFL, fl);
@@ -327,7 +327,7 @@ int uloop_timeout_cancel(struct uloop_timeout *timeout)
 
 static void uloop_handle_sigint(int signo)
 {
 
 static void uloop_handle_sigint(int signo)
 {
-       cancel = true;
+       uloop_cancelled = true;
 }
 
 static void uloop_setup_signals(void)
 }
 
 static void uloop_setup_signals(void)
@@ -370,7 +370,7 @@ static void uloop_process_timeouts(struct timeval *tv)
 
 void uloop_end(void)
 {
 
 void uloop_end(void)
 {
-       cancel = true;
+       uloop_cancelled = true;
 }
 
 void uloop_run(void)
 }
 
 void uloop_run(void)
@@ -378,7 +378,7 @@ void uloop_run(void)
        struct timeval tv;
 
        uloop_setup_signals();
        struct timeval tv;
 
        uloop_setup_signals();
-       while(!cancel)
+       while(!uloop_cancelled)
        {
                gettimeofday(&tv, NULL);
                uloop_process_timeouts(&tv);
        {
                gettimeofday(&tv, NULL);
                uloop_process_timeouts(&tv);