mirror of /home/gitosis/repositories/libev.git
*** empty log message ***
This commit is contained in:
parent
934b12dbac
commit
cb5b97b5c7
9
Changes
9
Changes
|
@ -1,10 +1,19 @@
|
|||
Revision history for libev, a high-performance and full-featured event loop.
|
||||
|
||||
- fix compilation of select backend in fd_set mode when NFDBITS is
|
||||
missing (to get it to compile on QNX, reported by Rodrigo Campos).
|
||||
- better select-nfds handling when select backend is in fd_set mode.
|
||||
- diagnose fd_set overruns when select backend is in fd_set mode.
|
||||
- due to a thinko, instead of disabling everything but
|
||||
select on the borked OS X platform, everything but select was
|
||||
allowed (reported by Emanuele Giaquinta).
|
||||
- actually verify that local and remote port are matching in
|
||||
libev's socketpair emulation, which makes denial-of-service
|
||||
attacks harder (but not impossible - it's windows). Make sure
|
||||
it even works under vista, which thinks that getpeer/sockname
|
||||
should return fantasy port numbers.
|
||||
- include "libev" all assertion messages for potentially
|
||||
clearer diagnostics.
|
||||
|
||||
3.51 Wed Dec 24 23:00:11 CET 2008
|
||||
- fix a bug where an inotify watcher was added twice, causing
|
||||
|
|
65
ev.c
65
ev.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* libev event processing core, watcher management
|
||||
*
|
||||
* Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de>
|
||||
* Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modifica-
|
||||
|
@ -750,7 +750,7 @@ fd_reify (EV_P)
|
|||
#else
|
||||
anfd->handle = _get_osfhandle (fd);
|
||||
#endif
|
||||
assert (("libev only supports socket fds in this configuration", ioctlsocket (anfd->handle, FIONREAD, &arg) == 0));
|
||||
assert (("libev: only socket fds supported in this configuration", ioctlsocket (anfd->handle, FIONREAD, &arg) == 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1133,7 +1133,7 @@ ev_feed_signal_event (EV_P_ int signum)
|
|||
WL w;
|
||||
|
||||
#if EV_MULTIPLICITY
|
||||
assert (("feeding signal events is only supported in the default loop", loop == ev_default_loop_ptr));
|
||||
assert (("libev: feeding signal events is only supported in the default loop", loop == ev_default_loop_ptr));
|
||||
#endif
|
||||
|
||||
--signum;
|
||||
|
@ -1272,8 +1272,9 @@ ev_recommended_backends (void)
|
|||
flags &= ~EVBACKEND_KQUEUE;
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
// flags &= ~EVBACKEND_KQUEUE & ~EVBACKEND_POLL; for documentation
|
||||
flags &= ~EVBACKEND_SELECT;
|
||||
/* only select works correctly on that "unix-certified" platform */
|
||||
flags &= ~EVBACKEND_KQUEUE; /* horribly broken, even for sockets */
|
||||
flags &= ~EVBACKEND_POLL; /* poll is based on kqueue from 10.5 onwards */
|
||||
#endif
|
||||
|
||||
return flags;
|
||||
|
@ -1536,10 +1537,10 @@ ev_loop_fork (EV_P)
|
|||
static void noinline
|
||||
verify_watcher (EV_P_ W w)
|
||||
{
|
||||
assert (("watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
|
||||
assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
|
||||
|
||||
if (w->pending)
|
||||
assert (("pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w));
|
||||
assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w));
|
||||
}
|
||||
|
||||
static void noinline
|
||||
|
@ -1549,9 +1550,9 @@ verify_heap (EV_P_ ANHE *heap, int N)
|
|||
|
||||
for (i = HEAP0; i < N + HEAP0; ++i)
|
||||
{
|
||||
assert (("active index mismatch in heap", ev_active (ANHE_w (heap [i])) == i));
|
||||
assert (("heap condition violated", i == HEAP0 || ANHE_at (heap [HPARENT (i)]) <= ANHE_at (heap [i])));
|
||||
assert (("heap at cache mismatch", ANHE_at (heap [i]) == ev_at (ANHE_w (heap [i]))));
|
||||
assert (("libev: active index mismatch in heap", ev_active (ANHE_w (heap [i])) == i));
|
||||
assert (("libev: heap condition violated", i == HEAP0 || ANHE_at (heap [HPARENT (i)]) <= ANHE_at (heap [i])));
|
||||
assert (("libev: heap at cache mismatch", ANHE_at (heap [i]) == ev_at (ANHE_w (heap [i]))));
|
||||
|
||||
verify_watcher (EV_A_ (W)ANHE_w (heap [i]));
|
||||
}
|
||||
|
@ -1562,7 +1563,7 @@ array_verify (EV_P_ W *ws, int cnt)
|
|||
{
|
||||
while (cnt--)
|
||||
{
|
||||
assert (("active index mismatch", ev_active (ws [cnt]) == cnt + 1));
|
||||
assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1));
|
||||
verify_watcher (EV_A_ ws [cnt]);
|
||||
}
|
||||
}
|
||||
|
@ -1579,15 +1580,15 @@ ev_loop_verify (EV_P)
|
|||
|
||||
assert (fdchangemax >= fdchangecnt);
|
||||
for (i = 0; i < fdchangecnt; ++i)
|
||||
assert (("negative fd in fdchanges", fdchanges [i] >= 0));
|
||||
assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0));
|
||||
|
||||
assert (anfdmax >= 0);
|
||||
for (i = 0; i < anfdmax; ++i)
|
||||
for (w = anfds [i].head; w; w = w->next)
|
||||
{
|
||||
verify_watcher (EV_A_ (W)w);
|
||||
assert (("inactive fd watcher on anfd list", ev_active (w) == 1));
|
||||
assert (("fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i));
|
||||
assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1));
|
||||
assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i));
|
||||
}
|
||||
|
||||
assert (timermax >= timercnt);
|
||||
|
@ -1714,7 +1715,7 @@ call_pending (EV_P)
|
|||
|
||||
if (expect_true (p->w))
|
||||
{
|
||||
/*assert (("non-pending watcher on pending list", p->w->pending));*/
|
||||
/*assert (("libev: non-pending watcher on pending list", p->w->pending));*/
|
||||
|
||||
p->w->pending = 0;
|
||||
EV_CB_INVOKE (p->w, p->events);
|
||||
|
@ -1755,7 +1756,7 @@ timers_reify (EV_P)
|
|||
{
|
||||
ev_timer *w = (ev_timer *)ANHE_w (timers [HEAP0]);
|
||||
|
||||
/*assert (("inactive timer on timer heap detected", ev_is_active (w)));*/
|
||||
/*assert (("libev: inactive timer on timer heap detected", ev_is_active (w)));*/
|
||||
|
||||
/* first reschedule or stop timer */
|
||||
if (w->repeat)
|
||||
|
@ -1764,7 +1765,7 @@ timers_reify (EV_P)
|
|||
if (ev_at (w) < mn_now)
|
||||
ev_at (w) = mn_now;
|
||||
|
||||
assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.));
|
||||
assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.));
|
||||
|
||||
ANHE_at_cache (timers [HEAP0]);
|
||||
downheap (timers, timercnt, HEAP0);
|
||||
|
@ -1787,14 +1788,14 @@ periodics_reify (EV_P)
|
|||
{
|
||||
ev_periodic *w = (ev_periodic *)ANHE_w (periodics [HEAP0]);
|
||||
|
||||
/*assert (("inactive timer on periodic heap detected", ev_is_active (w)));*/
|
||||
/*assert (("libev: inactive timer on periodic heap detected", ev_is_active (w)));*/
|
||||
|
||||
/* first reschedule or stop timer */
|
||||
if (w->reschedule_cb)
|
||||
{
|
||||
ev_at (w) = w->reschedule_cb (w, ev_rt_now);
|
||||
|
||||
assert (("ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now));
|
||||
assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now));
|
||||
|
||||
ANHE_at_cache (periodics [HEAP0]);
|
||||
downheap (periodics, periodiccnt, HEAP0);
|
||||
|
@ -2155,8 +2156,8 @@ ev_io_start (EV_P_ ev_io *w)
|
|||
if (expect_false (ev_is_active (w)))
|
||||
return;
|
||||
|
||||
assert (("ev_io_start called with negative fd", fd >= 0));
|
||||
assert (("ev_io start called with illegal event mask", !(w->events & ~(EV_IOFDSET | EV_READ | EV_WRITE))));
|
||||
assert (("libev: ev_io_start called with negative fd", fd >= 0));
|
||||
assert (("libev: ev_io start called with illegal event mask", !(w->events & ~(EV_IOFDSET | EV_READ | EV_WRITE))));
|
||||
|
||||
EV_FREQUENT_CHECK;
|
||||
|
||||
|
@ -2177,7 +2178,7 @@ ev_io_stop (EV_P_ ev_io *w)
|
|||
if (expect_false (!ev_is_active (w)))
|
||||
return;
|
||||
|
||||
assert (("ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
|
||||
assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
|
||||
|
||||
EV_FREQUENT_CHECK;
|
||||
|
||||
|
@ -2197,7 +2198,7 @@ ev_timer_start (EV_P_ ev_timer *w)
|
|||
|
||||
ev_at (w) += mn_now;
|
||||
|
||||
assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
|
||||
assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
|
||||
|
||||
EV_FREQUENT_CHECK;
|
||||
|
||||
|
@ -2210,7 +2211,7 @@ ev_timer_start (EV_P_ ev_timer *w)
|
|||
|
||||
EV_FREQUENT_CHECK;
|
||||
|
||||
/*assert (("internal timer heap corruption", timers [ev_active (w)] == (WT)w));*/
|
||||
/*assert (("libev: internal timer heap corruption", timers [ev_active (w)] == (WT)w));*/
|
||||
}
|
||||
|
||||
void noinline
|
||||
|
@ -2225,7 +2226,7 @@ ev_timer_stop (EV_P_ ev_timer *w)
|
|||
{
|
||||
int active = ev_active (w);
|
||||
|
||||
assert (("internal timer heap corruption", ANHE_w (timers [active]) == (WT)w));
|
||||
assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w));
|
||||
|
||||
--timercnt;
|
||||
|
||||
|
@ -2279,7 +2280,7 @@ ev_periodic_start (EV_P_ ev_periodic *w)
|
|||
ev_at (w) = w->reschedule_cb (w, ev_rt_now);
|
||||
else if (w->interval)
|
||||
{
|
||||
assert (("ev_periodic_start called with negative interval value", w->interval >= 0.));
|
||||
assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.));
|
||||
/* this formula differs from the one in periodic_reify because we do not always round up */
|
||||
ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
|
||||
}
|
||||
|
@ -2297,7 +2298,7 @@ ev_periodic_start (EV_P_ ev_periodic *w)
|
|||
|
||||
EV_FREQUENT_CHECK;
|
||||
|
||||
/*assert (("internal periodic heap corruption", ANHE_w (periodics [ev_active (w)]) == (WT)w));*/
|
||||
/*assert (("libev: internal periodic heap corruption", ANHE_w (periodics [ev_active (w)]) == (WT)w));*/
|
||||
}
|
||||
|
||||
void noinline
|
||||
|
@ -2312,7 +2313,7 @@ ev_periodic_stop (EV_P_ ev_periodic *w)
|
|||
{
|
||||
int active = ev_active (w);
|
||||
|
||||
assert (("internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w));
|
||||
assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w));
|
||||
|
||||
--periodiccnt;
|
||||
|
||||
|
@ -2345,12 +2346,12 @@ void noinline
|
|||
ev_signal_start (EV_P_ ev_signal *w)
|
||||
{
|
||||
#if EV_MULTIPLICITY
|
||||
assert (("signal watchers are only supported in the default loop", loop == ev_default_loop_ptr));
|
||||
assert (("libev: signal watchers are only supported in the default loop", loop == ev_default_loop_ptr));
|
||||
#endif
|
||||
if (expect_false (ev_is_active (w)))
|
||||
return;
|
||||
|
||||
assert (("ev_signal_start called with illegal signal number", w->signum > 0));
|
||||
assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0));
|
||||
|
||||
evpipe_init (EV_A);
|
||||
|
||||
|
@ -2411,7 +2412,7 @@ void
|
|||
ev_child_start (EV_P_ ev_child *w)
|
||||
{
|
||||
#if EV_MULTIPLICITY
|
||||
assert (("child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
|
||||
assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
|
||||
#endif
|
||||
if (expect_false (ev_is_active (w)))
|
||||
return;
|
||||
|
@ -2935,7 +2936,7 @@ ev_embed_start (EV_P_ ev_embed *w)
|
|||
|
||||
{
|
||||
struct ev_loop *loop = w->other;
|
||||
assert (("loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
|
||||
assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
|
||||
ev_io_init (&w->io, embed_io_cb, backend_fd, EV_READ);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* libev select fd activity backend
|
||||
*
|
||||
* Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de>
|
||||
* Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modifica-
|
||||
|
@ -72,6 +72,7 @@ select_modify (EV_P_ int fd, int oev, int nev)
|
|||
|
||||
{
|
||||
#if EV_SELECT_USE_FD_SET
|
||||
assert (("libev: fd >= FD_SETSIZE passed to fd_set-based select backend", fd < FD_SETSIZE));
|
||||
|
||||
#if EV_SELECT_IS_WINSOCKET
|
||||
SOCKET handle = anfds [fd].handle;
|
||||
|
@ -158,6 +159,9 @@ select_poll (EV_P_ ev_tstamp timeout)
|
|||
*/
|
||||
memcpy (vec_eo, vec_wi, fd_setsize);
|
||||
res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, (fd_set *)vec_eo, &tv);
|
||||
#elif EV_SELECT_USE_FD_SET
|
||||
fd_setsize = anfdmax < FD_SETSIZE ? anfdmax : FD_SETSIZE;
|
||||
res = select (fd_setsize, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv);
|
||||
#else
|
||||
res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv);
|
||||
#endif
|
||||
|
@ -265,7 +269,6 @@ select_init (EV_P_ int flags)
|
|||
backend_poll = select_poll;
|
||||
|
||||
#if EV_SELECT_USE_FD_SET
|
||||
vec_max = FD_SETSIZE / 32;
|
||||
vec_ri = ev_malloc (sizeof (fd_set)); FD_ZERO ((fd_set *)vec_ri);
|
||||
vec_ro = ev_malloc (sizeof (fd_set));
|
||||
vec_wi = ev_malloc (sizeof (fd_set)); FD_ZERO ((fd_set *)vec_wi);
|
||||
|
|
2
event.c
2
event.c
|
@ -99,7 +99,7 @@ void *event_init (void)
|
|||
else
|
||||
ev_x_cur = (struct event_base *)ev_default_loop (EVFLAG_AUTO);
|
||||
#else
|
||||
assert (("multiple event bases not supported when not compiled with EV_MULTIPLICITY", !ev_x_cur));
|
||||
assert (("libev: multiple event bases not supported when not compiled with EV_MULTIPLICITY", !ev_x_cur));
|
||||
|
||||
ev_x_cur = (struct event_base *)(long)ev_default_loop (EVFLAG_AUTO);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue