Helmut Schaa
510e4956e5
uloop: Fix incorrect timeout
...
uloop timeouts are calculated based on a time value that was fetched
before any callbacks were executed. Hence, the next timeout is off by
the time the callback execution took which can lead to strange side
effects.
Fix this by calculating the next timeout based on a fresh time value.
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
2013-07-24 15:01:19 +02:00
Felix Fietkau
b9ebdbcc64
uloop: fix corner cases with recursive uloop_run calls
...
With multiple recursive calls to uloop_run, the callback for the same fd
can be run multiple times from different levels in the stack.
Prevent this by tracking the stack of uloop_fd callbacks and buffering new
incoming events for fds already on the stack.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-18 12:05:09 +02:00
Felix Fietkau
35cee2c206
uloop: fix event flags processing on mac os x
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-18 12:05:09 +02:00
Felix Fietkau
e386259632
libubox: make uloop_fd::flags generic
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-18 12:05:09 +02:00
Felix Fietkau
cd5238b500
uloop: fix edge trigger handling on mac os x
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-18 11:02:20 +02:00
Felix Fietkau
ae40b66130
uloop: rework event processing, fix use-after-free issues
...
Recursive calls to uloop_run() need to process already fetched events
first, before running kqueue/epoll to get more.
The state of cur_fd/cur_nfds and the event list needs to be maintained
properly to prevent accidental running of events pointing at deleted
uloop_fd structs.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-11 12:55:21 +02:00
Felix Fietkau
766ff98050
uloop: remove file descriptors if neither read nor write notification is requested
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-31 16:43:08 +01:00
Jo-Philipp Wich
8b0d933154
uloop: rename uloop_timeout_pending() to uloop_timeout_remaining()
2013-01-23 19:33:12 +01:00
Jo-Philipp Wich
77984bd24d
uloop: add uloop_timeout_pending() function to determine the remaining time of an active timeout
2013-01-23 19:32:45 +01:00
Felix Fietkau
569bc29c5a
uloop: replace copyright info (code has been completely rewritten over time), relicense to ISC
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-13 09:47:51 +01:00
Felix Fietkau
dde64e47ca
uloop: use clock_gettime with the monotonic clock instead of using gettimeofday()
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-06 03:04:04 +01:00
Felix Fietkau
b7930023ee
uloop: add back state tracking on mac os x, it seems to work reliably now (after the other fixes)
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-05 16:04:55 +01:00
Felix Fietkau
17f4e41ecb
uloop: improve edge trigger reliability on mac os x
...
Sometimes after re-arming a fd, an initial event for reads is not generated,
even though there is data pending. Work around this by making the trigger
level-triggered first, then switching to edge trigger after processing the first
event.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-04 03:18:42 +01:00
Felix Fietkau
c2916d7bcc
uloop: ensure SIGCHLD is properly received on mac os x
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-04 03:13:29 +01:00
Felix Fietkau
6a8df07590
uloop: do less state/change tracking for kevent() on mac os x, it is unreliable
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-04 01:15:48 +01:00
Felix Fietkau
e7825661a2
uloop: fix immediate timeout processing on mac os x
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-01 23:37:22 +01:00
Felix Fietkau
9c8ab5d64c
utils: move ARRAY_SIZE from uloop to utils.h
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-31 15:24:27 +01:00
Felix Fietkau
407f7a0bb3
uloop: fix tv_diff() calculation
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-10-31 20:28:15 +01:00
Felix Fietkau
0385cbc068
uloop: another timer fix
...
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-10-31 20:09:47 +01:00
Felix Fietkau
33b9f3aa0b
uloop: fix sub-second timer offsets for uloop_timeout_set
2012-10-31 20:03:45 +01:00
Felix Fietkau
6e7e8a1a91
uloop: fix a segfault on deleting the first active timer from within another timer
2012-10-23 03:41:45 +02:00
Felix Fietkau
e3efdcfe15
uloop: fix event delete races on mac os x
2012-10-21 03:40:35 +02:00
Felix Fietkau
cca2ed6c8c
uloop: clear processes and timeouts on uloop_done()
2012-07-08 22:27:40 +02:00
Jo-Philipp Wich
0001d8ab26
uloop: handle EPOLLHUP like EPOLLERR to prevent infinite tight loops between epoll_wait() and the continue in uloop_run_events()
2012-07-07 18:17:40 +02:00
Felix Fietkau
63bc6593c3
uloop: prevent fd callbacks for unregistered fds by ensuring that pointers in the epoll array are cleared
2012-06-24 21:06:16 +02:00
Felix Fietkau
d6ebb84ad6
add a missing include
2011-08-11 15:37:48 -06:00
Felix Fietkau
a8032be64c
uloop: use list.h, add support for handling sigchld
2011-05-24 22:12:17 +02:00
Felix Fietkau
9abfbad95f
uloop: fix event timeouts on darwin
2011-02-12 21:33:32 +01:00
Felix Fietkau
83037e345d
uloop: allow timeouts to cancel the event loop
2011-02-11 02:38:36 +01:00
Felix Fietkau
7ec33884a3
allow multiple calls to uloop_init() without annoying side effects
2011-02-11 01:25:37 +01:00
Felix Fietkau
e44dbfb102
uloop: make first_timeout static
2011-02-07 17:52:33 +01:00
Felix Fietkau
db19e64c1a
make uloop_end() inline
2011-02-07 17:51:20 +01:00
Felix Fietkau
bf87f247d8
uloop: export the cancelled flag
2011-02-06 16:13:58 +01:00
Felix Fietkau
aa5276dcd6
uloop: fix the write flag for mac os x
2011-02-06 01:56:37 +01:00
Felix Fietkau
cd086c7c15
uloop: add a flag for keeping the socket blocking
2010-12-06 16:54:13 +01:00
Felix Fietkau
869fc39f50
uloop: fix infinite waiting with kqueue
2010-12-06 01:16:59 +01:00
Felix Fietkau
0d1a602dcf
port uloop to BSD kqueue
2010-12-05 00:38:58 +01:00
Felix Fietkau
e82d74f898
Initial import
2010-10-13 21:29:08 +02:00