Browse Source

*** empty log message ***

master
Marc Alexander Lehmann 14 years ago
parent
commit
e14e689e9f
  1. 4
      ev.c
  2. 1
      ev.h
  3. 3
      ev_epoll.c
  4. 2
      evdns.c
  5. 27
      event.c
  6. 4
      event.h

4
ev.c

@ -796,6 +796,8 @@ timers_reify (EV_P)
{
struct ev_timer *w = timers [0];
assert (("inactive timer on timer heap detected", ev_is_active (w)));
/* first reschedule or stop timer */
if (w->repeat)
{
@ -817,6 +819,8 @@ periodics_reify (EV_P)
{
struct ev_periodic *w = periodics [0];
assert (("inactive timer on periodic heap detected", ev_is_active (w)));
/* first reschedule or stop timer */
if (w->interval)
{

1
ev.h

@ -283,6 +283,7 @@ void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revent
#define ev_check_init(ev,cb) do { ev_watcher_init ((ev), (cb)); ev_check_set ((ev)); } while (0)
#define ev_child_init(ev,cb,pid) do { ev_watcher_init ((ev), (cb)); ev_child_set ((ev),(pid)); } while (0)
#define ev_is_pending(ev) (0 + (ev)->pending) /* true when watcher is waiting for callback invocation */
#define ev_is_active(ev) (0 + (ev)->active) /* true when the watcher has been started */
#define ev_set_priority(ev,pri) (ev)->priority = pri

3
ev_epoll.c

@ -42,7 +42,8 @@ epoll_modify (EV_P_ int fd, int oev, int nev)
(nev & EV_READ ? EPOLLIN : 0)
| (nev & EV_WRITE ? EPOLLOUT : 0);
epoll_ctl (epoll_fd, mode, fd, &ev);
if (!epoll_ctl (epoll_fd, mode, fd, &ev))
fd_kill (EV_A_ fd);
}
static void

2
evdns.c

@ -1,4 +1,4 @@
/* $Id: evdns.c,v 1.10 2007-11-04 18:29:44 root Exp $ */
/* $Id: evdns.c,v 1.11 2007-11-04 19:45:09 root Exp $ */
/* The original version of this module was written by Adam Langley; for
* a history of modifications, check out the subversion logs.

27
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;

4
event.h

@ -54,8 +54,6 @@ struct event
int ev_pri;
int ev_res;
short ev_events;
char initialised; /* flag to work around some idiosynchrasies in the API */
};
#define EV_PERSIST 0x10
@ -63,7 +61,7 @@ struct event
#define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd)
#define EVENT_FD(ev) ((int) (ev)->ev_fd)
#define event_initialized(ev) ((ev)->initialised)
#define event_initialized(ev) 1
#define evtimer_add(ev,tv) event_add (ev, tv)
#define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data)

Loading…
Cancel
Save