summaryrefslogtreecommitdiff
path: root/event.c
diff options
context:
space:
mode:
authorroot <root>2007-11-04 19:45:09 +0000
committerroot <root>2007-11-04 19:45:09 +0000
commitc04c7d0577ceddfe470b6fdcaf727ced91a67d1a (patch)
tree7aae857c1b460c6e5c00cdd337adb2fe8d904ed2 /event.c
parentf776d56f36abeed4a6091c2ec9b96363213ce2b2 (diff)
*** empty log message ***
Diffstat (limited to 'event.c')
-rw-r--r--event.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/event.c b/event.c
index 030df49..98260d6 100644
--- a/event.c
+++ b/event.c
@@ -158,22 +158,21 @@ x_cb_io (EV_P_ struct ev_io *w, int revents)
static void
x_cb_to (EV_P_ struct ev_timer *w, int revents)
{
- x_cb ((struct event *)(((char *)w) - offsetof (struct event, to)), revents);
+ struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, to));
+
+ event_del (ev);
+
+ x_cb (ev, revents);
}
void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg)
{
- if (!ev->initialised)
- {
- ev->initialised = 1;
-
- if (events & EV_SIGNAL)
- ev_watcher_init (&ev->iosig.sig, x_cb_sig);
- else
- ev_watcher_init (&ev->iosig.io, x_cb_io);
+ if (events & EV_SIGNAL)
+ ev_watcher_init (&ev->iosig.sig, x_cb_sig);
+ else
+ ev_watcher_init (&ev->iosig.io, x_cb_io);
- ev_watcher_init (&ev->to, x_cb_to);
- }
+ ev_watcher_init (&ev->to, x_cb_to);
ev->ev_base = x_cur; /* not threadsafe, but its like libevent works */
ev->ev_fd = fd;
@@ -248,17 +247,17 @@ int event_pending (struct event *ev, short events, struct timeval *tv)
if (ev->ev_events & EV_SIGNAL)
{
/* sig */
- if (ev->iosig.sig.pending)
+ if (ev_is_active (&ev->iosig.sig) || ev_is_pending (&ev->iosig.sig))
revents |= EV_SIGNAL;
}
else
{
/* io */
- if (ev->iosig.io.pending)
+ if (ev_is_active (&ev->iosig.io) || ev_is_pending (&ev->iosig.io))
revents |= ev->ev_events & (EV_READ | EV_WRITE);
}
- if (ev->to.pending)
+ if (ev->ev_events & EV_TIMEOUT || ev_is_active (&ev->to) || ev_is_pending (&ev->to))
{
revents |= EV_TIMEOUT;