Author: yoann
Date: 2009-04-10 12:12:47 +0200 (Fri, 10 Apr 2009)
New Revision: 11142
Modified:
prelude-manager/trunk/libev/Changes
prelude-manager/trunk/libev/Makefile.am
prelude-manager/trunk/libev/ev.c
prelude-manager/trunk/libev/ev.h
prelude-manager/trunk/libev/ev_epoll.c
prelude-manager/trunk/libev/ev_kqueue.c
prelude-manager/trunk/libev/ev_poll.c
prelude-manager/trunk/libev/ev_port.c
prelude-manager/trunk/libev/ev_select.c
prelude-manager/trunk/libev/ev_vars.h
prelude-manager/trunk/libev/ev_win32.c
prelude-manager/trunk/libev/ev_wrap.h
prelude-manager/trunk/libev/libev.m4
Log:
Upgrade to libev 3.53.
Modified: prelude-manager/trunk/libev/Changes
===================================================================
--- prelude-manager/trunk/libev/Changes 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/Changes 2009-04-10 10:12:47 UTC (rev 11142)
@@ -1,5 +1,102 @@
Revision history for libev, a high-performance and full-featured event loop.
+3.53 Sun Feb 15 02:38:20 CET 2009
+ - fix a bug in event pipe creation on win32 that would cause a
+ failed assertion on event loop creation (patch by Malek Hadj-Ali).
+ - probe for CLOCK_REALTIME support at runtime as well and fall
+ back to gettimeofday if there is an error, to support older
+ operating systems with newer header files/libraries.
+ - prefer gettimeofday over clock_gettime with USE_CLOCK_SYSCALL
+ (default most everywhere), otherwise not.
+
+3.52 Wed Jan 7 21:43:02 CET 2009
+ - 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" in all assertion messages for potentially
+ clearer diagnostics.
+ - event_get_version (libevent compatibility) returned
+ a useless string instead of the expected version string
+ (patch by W.C.A. Wijngaards).
+
+3.51 Wed Dec 24 23:00:11 CET 2008
+ - fix a bug where an inotify watcher was added twice, causing
+ freezes on hash collisions (reported and analysed by Graham Leggett).
+ - new config symbol, EV_USE_CLOCK_SYSCALL, to make libev use
+ a direct syscall - slower, but no dependency on librt et al.
+ - assume negative return values != -1 signals success of port_getn
+ (http://cvs.epicsol.org/cgi/viewcvs.cgi/epic5/source/newio.c?rev=1.52)
+ (no known failure reports, but it doesn't hurt).
+ - fork detection in ev_embed now stops and restarts the watcher
+ automatically.
+ - EXPERIMENTAL: default the method to operator () in ev++.h,
+ to make it nicer to use functors (requested by Benedek László).
+ - fixed const object callbacks in ev++.h.
+ - replaced loop_ref argument of watcher.set (loop) by a direct
+ ev_loop * in ev++.h, to avoid clashes with functor patch.
+ - do not try to watch the empty string via inotify.
+ - inotify watchers could be leaked under certain circumstances.
+ - OS X 10.5 is actually even more broken than earlier versions,
+ so fall back to select on that piece of garbage.
+ - fixed some weirdness in the ev_embed documentation.
+
+3.49 Wed Nov 19 11:26:53 CET 2008
+ - ev_stat watchers will now use inotify as a mere hint on
+ kernels <2.6.25, or if the filesystem is not in the
+ "known to be good" list.
+ - better mingw32 compatibility (it's not as borked as native win32)
+ (analysed by Roger Pack).
+ - include stdio.h in the example program, as too many people are
+ confused by the weird C language otherwise. I guess the next thing
+ I get told is that the "..." ellipses in the examples don't compile
+ with their C compiler.
+
+3.48 Thu Oct 30 09:02:37 CET 2008
+ - further optimise away the EPOLL_CTL_ADD/MOD combo in the epoll
+ backend by assuming the kernel event mask hasn't changed if
+ ADD fails with EEXIST.
+ - work around spurious event notification bugs in epoll by using
+ a 32-bit generation counter. recreate kernel state if we receive
+ spurious notifications or unwanted events. this is very costly,
+ but I didn't come up with this horrible design.
+ - use memset to initialise most arrays now and do away with the
+ init functions.
+ - expand time-out strategies into a "Be smart about timeouts" section.
+ - drop the "struct" from all ev_watcher declarations in the
+ documentation and did other clarifications (yeah, it was a mistake
+ to have a struct AND a function called ev_loop).
+ - fix a bug where ev_default would not initialise the default
+ loop again after it was destroyed with ev_default_destroy.
+ - rename syserr to ev_syserr to avoid name clashes when embedding,
+ do similar changes for event.c.
+
+3.45 Tue Oct 21 21:59:26 CEST 2008
+ - disable inotify usage on linux <2.6.25, as it is broken
+ (reported by Yoann Vandoorselaere).
+ - ev_stat errornously would try to add inotify watchers
+ even when inotify wasn't available (this should only
+ have a performance impact).
+ - ev_once now passes both timeout and io to the callback if both
+ occur concurrently, instead of giving timeouts precedence.
+ - disable EV_USE_INOTIFY when sys/inotify.h is too old.
+
+3.44 Mon Sep 29 05:18:39 CEST 2008
+ - embed watchers now automatically invoke ev_loop_fork on the
+ embedded loop when the parent loop forks.
+ - new function: ev_now_update (loop).
+ - verify_watcher was not marked static.
+ - improve the "associating..." manpage section.
+ - documentation tweaks here and there.
+
3.43 Sun Jul 6 05:34:41 CEST 2008
- include more include files on windows to get struct _stati64
(reported by Chris Hulbert, but doesn't quite fix his issue).
Modified: prelude-manager/trunk/libev/Makefile.am
===================================================================
--- prelude-manager/trunk/libev/Makefile.am 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/Makefile.am 2009-04-10 10:12:47 UTC (rev 11142)
@@ -1,4 +1,4 @@
-EXTRA_DIST=ev_epoll.c ev_kqueue.c ev_poll.c ev_port.c ev_select.c ev_win32.c
+EXTRA_DIST=LICENSE Changes README ev_epoll.c ev_kqueue.c ev_poll.c ev_port.c ev_select.c ev_win32.c
noinst_HEADERS = ev.h ev_vars.h ev_wrap.h
noinst_LTLIBRARIES = libev.la
libev_la_SOURCES = ev.c
Modified: prelude-manager/trunk/libev/ev.c
===================================================================
--- prelude-manager/trunk/libev/ev.c 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/ev.c 2009-04-10 10:12:47 UTC (rev 11142)
@@ -1,7 +1,7 @@
/*
* libev event processing core, watcher management
*
- * Copyright (c) 2007,2008 Marc Alexander Lehmann <[email protected]>
+ * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
@@ -49,12 +49,24 @@
# include "config.h"
# endif
+# if HAVE_CLOCK_SYSCALL
+# ifndef EV_USE_CLOCK_SYSCALL
+# define EV_USE_CLOCK_SYSCALL 1
+# ifndef EV_USE_REALTIME
+# define EV_USE_REALTIME 0
+# endif
+# ifndef EV_USE_MONOTONIC
+# define EV_USE_MONOTONIC 1
+# endif
+# endif
+# endif
+
# if HAVE_CLOCK_GETTIME
# ifndef EV_USE_MONOTONIC
# define EV_USE_MONOTONIC 1
# endif
# ifndef EV_USE_REALTIME
-# define EV_USE_REALTIME 1
+# define EV_USE_REALTIME 0
# endif
# else
# ifndef EV_USE_MONOTONIC
@@ -166,6 +178,14 @@
/* this block tries to deduce configuration from header-defined symbols and defaults */
+#ifndef EV_USE_CLOCK_SYSCALL
+# if __linux && __GLIBC__ >= 2
+# define EV_USE_CLOCK_SYSCALL 1
+# else
+# define EV_USE_CLOCK_SYSCALL 0
+# endif
+#endif
+
#ifndef EV_USE_MONOTONIC
# if defined (_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0
# define EV_USE_MONOTONIC 1
@@ -175,7 +195,7 @@
#endif
#ifndef EV_USE_REALTIME
-# define EV_USE_REALTIME 0
+# define EV_USE_REALTIME !EV_USE_CLOCK_SYSCALL
#endif
#ifndef EV_USE_NANOSLEEP
@@ -288,13 +308,29 @@
#endif
#if EV_USE_INOTIFY
+# include <sys/utsname.h>
+# include <sys/statfs.h>
# include <sys/inotify.h>
+/* some very old inotify.h headers don't have IN_DONT_FOLLOW */
+# ifndef IN_DONT_FOLLOW
+# undef EV_USE_INOTIFY
+# define EV_USE_INOTIFY 0
+# endif
#endif
#if EV_SELECT_IS_WINSOCKET
# include <winsock.h>
#endif
+/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */
+/* which makes programs even slower. might work on other unices, too. */
+#if EV_USE_CLOCK_SYSCALL
+# include <syscall.h>
+# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts))
+# undef EV_USE_MONOTONIC
+# define EV_USE_MONOTONIC 1
+#endif
+
#if EV_USE_EVENTFD
/* our minimum requirement is glibc 2.7 which has the stub, but not the header */
# include <stdint.h>
@@ -363,9 +399,13 @@
#define ev_active(w) ((W)(w))->active
#define ev_at(w) ((WT)(w))->at
-#if EV_USE_MONOTONIC
+#if EV_USE_REALTIME
/* sig_atomic_t is used to avoid per-thread variables or locking but still */
/* giving it a reasonably high chance of working on typical architetcures */
+static EV_ATOMIC_T have_realtime; /* did clock_gettime (CLOCK_REALTIME) work? */
+#endif
+
+#if EV_USE_MONOTONIC
static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */
#endif
@@ -384,7 +424,7 @@
}
static void noinline
-syserr (const char *msg)
+ev_syserr (const char *msg)
{
if (!msg)
msg = "(libev) system error";
@@ -445,6 +485,11 @@
WL head;
unsigned char events;
unsigned char reify;
+ unsigned char emask; /* the epoll backend stores the actual kernel mask in here */
+ unsigned char unused;
+#if EV_USE_EPOLL
+ unsigned int egen; /* generation counter to counter epoll bugs */
+#endif
#if EV_SELECT_IS_WINSOCKET
SOCKET handle;
#endif
@@ -514,14 +559,17 @@
ev_time (void)
{
#if EV_USE_REALTIME
- struct timespec ts;
- clock_gettime (CLOCK_REALTIME, &ts);
- return ts.tv_sec + ts.tv_nsec * 1e-9;
-#else
+ if (expect_true (have_realtime))
+ {
+ struct timespec ts;
+ clock_gettime (CLOCK_REALTIME, &ts);
+ return ts.tv_sec + ts.tv_nsec * 1e-9;
+ }
+#endif
+
struct timeval tv;
gettimeofday (&tv, 0);
return tv.tv_sec + tv.tv_usec * 1e-6;
-#endif
}
ev_tstamp inline_size
@@ -607,6 +655,9 @@
return ev_realloc (base, elem * *cur);
}
+#define array_init_zero(base,count) \
+ memset ((void *)(base), 0, sizeof (*(base)) * (count))
+
#define array_needsize(type,base,cur,cnt,init) \
if (expect_false ((cnt) > (cur))) \
{ \
@@ -659,19 +710,6 @@
/*****************************************************************************/
-void inline_size
-anfds_init (ANFD *base, int count)
-{
- while (count--)
- {
- base->head = 0;
- base->events = EV_NONE;
- base->reify = 0;
-
- ++base;
- }
-}
-
void inline_speed
fd_event (EV_P_ int fd, int revents)
{
@@ -719,7 +757,7 @@
#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
@@ -810,6 +848,7 @@
if (anfds [fd].events)
{
anfds [fd].events = 0;
+ anfds [fd].emask = 0;
fd_change (EV_A_ fd, EV_IOFDSET | 1);
}
}
@@ -971,18 +1010,6 @@
static EV_ATOMIC_T gotsig;
-void inline_size
-signals_init (ANSIG *base, int count)
-{
- while (count--)
- {
- base->head = 0;
- base->gotsig = 0;
-
- ++base;
- }
-}
-
/*****************************************************************************/
void inline_speed
@@ -1013,7 +1040,7 @@
#endif
{
while (pipe (evpipe))
- syserr ("(libev) error creating signal/async pipe");
+ ev_syserr ("(libev) error creating signal/async pipe");
fd_intern (evpipe [0]);
fd_intern (evpipe [1]);
@@ -1113,7 +1140,7 @@
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;
@@ -1252,8 +1279,9 @@
flags &= ~EVBACKEND_KQUEUE;
#endif
#ifdef __APPLE__
- // flags &= ~EVBACKEND_KQUEUE; for documentation
- flags &= ~EVBACKEND_POLL;
+ /* 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;
@@ -1300,12 +1328,24 @@
{
if (!backend)
{
+#if EV_USE_REALTIME
+ if (!have_realtime)
+ {
+ struct timespec ts;
+
+ if (!clock_gettime (CLOCK_REALTIME, &ts))
+ have_realtime = 1;
+ }
+#endif
+
#if EV_USE_MONOTONIC
- {
- struct timespec ts;
- if (!clock_gettime (CLOCK_MONOTONIC, &ts))
- have_monotonic = 1;
- }
+ if (!have_monotonic)
+ {
+ struct timespec ts;
+
+ if (!clock_gettime (CLOCK_MONOTONIC, &ts))
+ have_monotonic = 1;
+ }
#endif
ev_rt_now = ev_time ();
@@ -1513,13 +1553,13 @@
}
#if EV_VERIFY
-void noinline
+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
@@ -1529,9 +1569,9 @@
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]));
}
@@ -1542,7 +1582,7 @@
{
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]);
}
}
@@ -1559,15 +1599,15 @@
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);
@@ -1654,6 +1694,8 @@
struct ev_loop *loop = ev_default_loop_ptr;
#endif
+ ev_default_loop_ptr = 0;
+
#ifndef _WIN32
ev_ref (EV_A); /* child watcher */
ev_signal_stop (EV_A_ &childev);
@@ -1669,8 +1711,7 @@
struct ev_loop *loop = ev_default_loop_ptr;
#endif
- if (backend)
- postfork = 1; /* must be in line with ev_loop_fork */
+ postfork = 1; /* must be in line with ev_loop_fork */
}
/*****************************************************************************/
@@ -1693,7 +1734,7 @@
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);
@@ -1734,7 +1775,7 @@
{
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)
@@ -1743,7 +1784,7 @@
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);
@@ -1766,14 +1807,14 @@
{
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);
@@ -1911,6 +1952,12 @@
--activecnt;
}
+void
+ev_now_update (EV_P)
+{
+ time_update (EV_A_ 1e100);
+}
+
static int loop_done;
void
@@ -2128,12 +2175,13 @@
if (expect_false (ev_is_active (w)))
return;
- assert (("ev_io_start called with negative fd", fd >= 0));
+ 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;
ev_start (EV_A_ (W)w, 1);
- array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init);
+ array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero);
wlist_add (&anfds[fd].head, (WL)w);
fd_change (EV_A_ fd, w->events & EV_IOFDSET | 1);
@@ -2149,7 +2197,7 @@
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;
@@ -2169,7 +2217,7 @@
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;
@@ -2182,7 +2230,7 @@
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
@@ -2197,7 +2245,7 @@
{
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;
@@ -2251,7 +2299,7 @@
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;
}
@@ -2269,7 +2317,7 @@
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
@@ -2284,7 +2332,7 @@
{
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;
@@ -2317,12 +2365,12 @@
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);
@@ -2335,7 +2383,7 @@
sigprocmask (SIG_SETMASK, &full, &prev);
#endif
- array_needsize (ANSIG, signals, signalmax, w->signum, signals_init);
+ array_needsize (ANSIG, signals, signalmax, w->signum, array_init_zero);
#ifndef _WIN32
sigprocmask (SIG_SETMASK, &prev, 0);
@@ -2383,7 +2431,7 @@
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;
@@ -2418,8 +2466,9 @@
# define lstat(a,b) _stati64 (a,b)
# endif
-#define DEF_STAT_INTERVAL 5.0074891
-#define MIN_STAT_INTERVAL 0.1074891
+#define DEF_STAT_INTERVAL 5.0074891
+#define NFS_STAT_INTERVAL 30.1074891 /* for filesystems potentially failing inotify */
+#define MIN_STAT_INTERVAL 0.1074891
static void noinline stat_timer_cb (EV_P_ ev_timer *w_, int revents);
@@ -2433,10 +2482,11 @@
if (w->wd < 0)
{
- ev_timer_start (EV_A_ &w->timer); /* this is not race-free, so we still need to recheck periodically */
+ w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL;
+ ev_timer_again (EV_A_ &w->timer); /* this is not race-free, so we still need to recheck periodically */
/* monitor some parent directory for speedup hints */
- /* note that exceeding the hardcoded limit is not a correctness issue, */
+ /* note that exceeding the hardcoded path limit is not a correctness issue, */
/* but an efficiency issue only */
if ((errno == ENOENT || errno == EACCES) && strlen (w->path) < 4096)
{
@@ -2450,8 +2500,8 @@
char *pend = strrchr (path, '/');
- if (!pend)
- break; /* whoops, no '/', complain to your admin */
+ if (!pend || pend == path)
+ break;
*pend = 0;
w->wd = inotify_add_watch (fs_fd, path, mask);
@@ -2459,11 +2509,28 @@
while (w->wd < 0 && (errno == ENOENT || errno == EACCES));
}
}
- else
- ev_timer_stop (EV_A_ &w->timer); /* we can watch this in a race-free way */
if (w->wd >= 0)
- wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w);
+ {
+ wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w);
+
+ /* now local changes will be tracked by inotify, but remote changes won't */
+ /* unless the filesystem it known to be local, we therefore still poll */
+ /* also do poll on <2.6.25, but with normal frequency */
+ struct statfs sfs;
+
+ if (fs_2625 && !statfs (w->path, &sfs))
+ if (sfs.f_type == 0x1373 /* devfs */
+ || sfs.f_type == 0xEF53 /* ext2/3 */
+ || sfs.f_type == 0x3153464a /* jfs */
+ || sfs.f_type == 0x52654973 /* reiser3 */
+ || sfs.f_type == 0x01021994 /* tempfs */
+ || sfs.f_type == 0x58465342 /* xfs */)
+ return;
+
+ w->timer.repeat = w->interval ? w->interval : fs_2625 ? NFS_STAT_INTERVAL : DEF_STAT_INTERVAL;
+ ev_timer_again (EV_A_ &w->timer);
+ }
}
static void noinline
@@ -2487,7 +2554,7 @@
infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev)
{
if (slot < 0)
- /* overflow, need to check for all hahs slots */
+ /* overflow, need to check for all hash slots */
for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot)
infy_wd (EV_A_ slot, wd, ev);
else
@@ -2503,6 +2570,7 @@
{
if (ev->mask & (IN_IGNORED | IN_UNMOUNT | IN_DELETE_SELF))
{
+ wlist_del (&fs_hash [slot & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w);
w->wd = -1;
infy_add (EV_A_ w); /* re-add, no matter what */
}
@@ -2526,11 +2594,38 @@
}
void inline_size
+check_2625 (EV_P)
+{
+ /* kernels < 2.6.25 are borked
+ * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html
+ */
+ struct utsname buf;
+ int major, minor, micro;
+
+ if (uname (&buf))
+ return;
+
+ if (sscanf (buf.release, "%d.%d.%d", &major, &minor, µ) != 3)
+ return;
+
+ if (major < 2
+ || (major == 2 && minor < 6)
+ || (major == 2 && minor == 6 && micro < 25))
+ return;
+
+ fs_2625 = 1;
+}
+
+void inline_size
infy_init (EV_P)
{
if (fs_fd != -2)
return;
+ fs_fd = -1;
+
+ check_2625 (EV_A);
+
fs_fd = inotify_init ();
if (fs_fd >= 0)
@@ -2567,9 +2662,8 @@
if (fs_fd >= 0)
infy_add (EV_A_ w); /* re-add, no matter what */
else
- ev_timer_start (EV_A_ &w->timer);
+ ev_timer_again (EV_A_ &w->timer);
}
-
}
}
@@ -2615,9 +2709,12 @@
|| w->prev.st_ctime != w->attr.st_ctime
) {
#if EV_USE_INOTIFY
- infy_del (EV_A_ w);
- infy_add (EV_A_ w);
- ev_stat_stat (EV_A_ w); /* avoid race... */
+ if (fs_fd >= 0)
+ {
+ infy_del (EV_A_ w);
+ infy_add (EV_A_ w);
+ ev_stat_stat (EV_A_ w); /* avoid race... */
+ }
#endif
ev_feed_event (EV_A_ w, EV_STAT);
@@ -2630,16 +2727,12 @@
if (expect_false (ev_is_active (w)))
return;
- /* since we use memcmp, we need to clear any padding data etc. */
- memset (&w->prev, 0, sizeof (ev_statdata));
- memset (&w->attr, 0, sizeof (ev_statdata));
-
ev_stat_stat (EV_A_ w);
- if (w->interval < MIN_STAT_INTERVAL)
- w->interval = w->interval ? MIN_STAT_INTERVAL : DEF_STAT_INTERVAL;
+ if (w->interval < MIN_STAT_INTERVAL && w->interval)
+ w->interval = MIN_STAT_INTERVAL;
- ev_timer_init (&w->timer, stat_timer_cb, w->interval, w->interval);
+ ev_timer_init (&w->timer, stat_timer_cb, 0., w->interval ? w->interval : DEF_STAT_INTERVAL);
ev_set_priority (&w->timer, ev_priority (w));
#if EV_USE_INOTIFY
@@ -2649,7 +2742,7 @@
infy_add (EV_A_ w);
else
#endif
- ev_timer_start (EV_A_ &w->timer);
+ ev_timer_again (EV_A_ &w->timer);
ev_start (EV_A_ (W)w, 1);
@@ -2829,6 +2922,23 @@
}
}
+static void
+embed_fork_cb (EV_P_ ev_fork *fork_w, int revents)
+{
+ ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork));
+
+ ev_embed_stop (EV_A_ w);
+
+ {
+ struct ev_loop *loop = w->other;
+
+ ev_loop_fork (EV_A);
+ ev_loop (EV_A_ EVLOOP_NONBLOCK);
+ }
+
+ ev_embed_start (EV_A_ w);
+}
+
#if 0
static void
embed_idle_cb (EV_P_ ev_idle *idle, int revents)
@@ -2845,7 +2955,7 @@
{
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);
}
@@ -2858,6 +2968,9 @@
ev_set_priority (&w->prepare, EV_MINPRI);
ev_prepare_start (EV_A_ &w->prepare);
+ ev_fork_init (&w->fork, embed_fork_cb);
+ ev_fork_start (EV_A_ &w->fork);
+
/*ev_idle_init (&w->idle, e,bed_idle_cb);*/
ev_start (EV_A_ (W)w, 1);
@@ -2874,11 +2987,10 @@
EV_FREQUENT_CHECK;
- ev_io_stop (EV_A_ &w->io);
+ ev_io_stop (EV_A_ &w->io);
ev_prepare_stop (EV_A_ &w->prepare);
+ ev_fork_stop (EV_A_ &w->fork);
- ev_stop (EV_A_ (W)w);
-
EV_FREQUENT_CHECK;
}
#endif
@@ -2984,7 +3096,7 @@
void (*cb)(int revents, void *arg) = once->cb;
void *arg = once->arg;
- ev_io_stop (EV_A_ &once->io);
+ ev_io_stop (EV_A_ &once->io);
ev_timer_stop (EV_A_ &once->to);
ev_free (once);
@@ -2994,13 +3106,17 @@
static void
once_cb_io (EV_P_ ev_io *w, int revents)
{
- once_cb (EV_A_ (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io)), revents);
+ struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io));
+
+ once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->to));
}
static void
once_cb_to (EV_P_ ev_timer *w, int revents)
{
- once_cb (EV_A_ (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to)), revents);
+ struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to));
+
+ once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->io));
}
void
Modified: prelude-manager/trunk/libev/ev.h
===================================================================
--- prelude-manager/trunk/libev/ev.h 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/ev.h 2009-04-10 10:12:47 UTC (rev 11142)
@@ -1,7 +1,7 @@
/*
* libev native API header
*
- * Copyright (c) 2007,2008 Marc Alexander Lehmann <[email protected]>
+ * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
@@ -167,9 +167,10 @@
/*
* struct member types:
- * private: you can look at them, but not change them, and they might not mean anything to you.
- * ro: can be read anytime, but only changed when the watcher isn't active
- * rw: can be read and modified anytime, even when the watcher is active
+ * private: you may look at them, but not change them,
+ * and they might not mean anything to you.
+ * ro: can be read anytime, but only changed when the watcher isn't active.
+ * rw: can be read and modified anytime, even when the watcher is active.
*
* some internal details that might be helpful for debugging:
*
@@ -178,7 +179,7 @@
* or the array index + 1 (most other watchers)
* or simply 1 for watchers that aren't in some array.
* pending is either 0, in which case the watcher isn't,
- * or the array index + 1 in the pendings array.
+ * or the array index + 1 in the pendings array.
*/
/* shared by all watchers */
@@ -337,7 +338,7 @@
ev_timer timer; /* unused */
ev_periodic periodic; /* unused */
ev_idle idle; /* unused */
- ev_fork fork; /* unused */
+ ev_fork fork; /* private */
} ev_embed;
#endif
@@ -424,12 +425,11 @@
void ev_set_syserr_cb (void (*cb)(const char *msg));
#if EV_MULTIPLICITY
-extern struct ev_loop *ev_default_loop_ptr;
-extern struct ev_loop *ev_default_loop_init (unsigned int flags);
-
EV_INLINE struct ev_loop *
ev_default_loop_uc (void)
{
+ extern struct ev_loop *ev_default_loop_ptr;
+
return ev_default_loop_ptr;
}
@@ -442,6 +442,8 @@
if (!loop)
{
+ extern struct ev_loop *ev_default_loop_init (unsigned int flags);
+
loop = ev_default_loop_init (flags);
}
@@ -455,6 +457,7 @@
void ev_loop_verify (EV_P);
ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */
+void ev_now_update (EV_P);
#else
@@ -473,6 +476,8 @@
ev_is_default_loop (EV_P)
{
#if EV_MULTIPLICITY
+ extern struct ev_loop *ev_default_loop_ptr;
+
return !!(EV_A == ev_default_loop_ptr);
#else
return 1;
@@ -511,7 +516,7 @@
void ev_ref (EV_P);
void ev_unref (EV_P);
-/* convinience function, wait for a single event, without registering an event watcher */
+/* convenience function, wait for a single event, without registering an event watcher */
/* if timeout is < 0, do wait indefinitely */
void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg);
#endif
Modified: prelude-manager/trunk/libev/ev_epoll.c
===================================================================
--- prelude-manager/trunk/libev/ev_epoll.c 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/ev_epoll.c 2009-04-10 10:12:47 UTC (rev 11142)
@@ -52,7 +52,9 @@
*
* lots of "weird code" and complication handling in this file is due
* to these design problems with epoll, as we try very hard to avoid
- * epoll_ctl syscalls for common usage patterns.
+ * epoll_ctl syscalls for common usage patterns and handle the breakage
+ * ensuing from receiving events for closed and otherwise long gone
+ * file descriptors.
*/
#include <sys/epoll.h>
@@ -61,17 +63,25 @@
epoll_modify (EV_P_ int fd, int oev, int nev)
{
struct epoll_event ev;
+ unsigned char oldmask;
/*
* we handle EPOLL_CTL_DEL by ignoring it here
* on the assumption that the fd is gone anyways
* if that is wrong, we have to handle the spurious
* event in epoll_poll.
+ * if the fd is added again, we try to ADD it, and, if that
+ * fails, we assume it still has the same eventmask.
*/
if (!nev)
return;
- ev.data.u64 = fd; /* use u64 to fully initialise the struct, for nicer strace etc. */
+ oldmask = anfds [fd].emask;
+ anfds [fd].emask = nev;
+
+ /* store the generation counter in the upper 32 bits, the fd in the lower 32 bits */
+ ev.data.u64 = (uint64_t)(uint32_t)fd
+ | ((uint64_t)(uint32_t)++anfds [fd].egen << 32);
ev.events = (nev & EV_READ ? EPOLLIN : 0)
| (nev & EV_WRITE ? EPOLLOUT : 0);
@@ -80,21 +90,29 @@
if (expect_true (errno == ENOENT))
{
- /* on ENOENT the fd went away, so try to do the right thing */
+ /* if ENOENT then the fd went away, so try to do the right thing */
if (!nev)
- return;
+ goto dec_egen;
if (!epoll_ctl (backend_fd, EPOLL_CTL_ADD, fd, &ev))
return;
}
else if (expect_true (errno == EEXIST))
{
- /* on EEXIST we ignored a previous DEL */
+ /* EEXIST means we ignored a previous DEL, but the fd is still active */
+ /* if the kernel mask is the same as the new mask, we assume it hasn't changed */
+ if (oldmask == nev)
+ goto dec_egen;
+
if (!epoll_ctl (backend_fd, EPOLL_CTL_MOD, fd, &ev))
return;
}
fd_kill (EV_A_ fd);
+
+dec_egen:
+ /* we didn't successfully call epoll_ctl, so decrement the generation counter again */
+ --anfds [fd].egen;
}
static void
@@ -106,7 +124,7 @@
if (expect_false (eventcnt < 0))
{
if (errno != EINTR)
- syserr ("(libev) epoll_wait");
+ ev_syserr ("(libev) epoll_wait");
return;
}
@@ -115,18 +133,33 @@
{
struct epoll_event *ev = epoll_events + i;
- int fd = ev->data.u64;
+ int fd = (uint32_t)ev->data.u64; /* mask out the lower 32 bits */
+ int want = anfds [fd].events;
int got = (ev->events & (EPOLLOUT | EPOLLERR | EPOLLHUP) ? EV_WRITE : 0)
| (ev->events & (EPOLLIN | EPOLLERR | EPOLLHUP) ? EV_READ : 0);
- int want = anfds [fd].events;
+ /* check for spurious notification */
+ if (expect_false ((uint32_t)anfds [fd].egen != (uint32_t)(ev->data.u64 >> 32)))
+ {
+ /* recreate kernel state */
+ postfork = 1;
+ continue;
+ }
+
if (expect_false (got & ~want))
{
+ anfds [fd].emask = want;
+
/* we received an event but are not interested in it, try mod or del */
+ /* I don't think we ever need MOD, but let's handle it anyways */
ev->events = (want & EV_READ ? EPOLLIN : 0)
| (want & EV_WRITE ? EPOLLOUT : 0);
- epoll_ctl (backend_fd, want ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, fd, ev);
+ if (epoll_ctl (backend_fd, want ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, fd, ev))
+ {
+ postfork = 1; /* an error occured, recreate kernel state */
+ continue;
+ }
}
fd_event (EV_A_ fd, got);
@@ -155,7 +188,7 @@
backend_modify = epoll_modify;
backend_poll = epoll_poll;
- epoll_eventmax = 64; /* intiial number of events receivable per poll */
+ epoll_eventmax = 64; /* initial number of events receivable per poll */
epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax);
return EVBACKEND_EPOLL;
@@ -173,7 +206,7 @@
close (backend_fd);
while ((backend_fd = epoll_create (256)) < 0)
- syserr ("(libev) epoll_create");
+ ev_syserr ("(libev) epoll_create");
fcntl (backend_fd, F_SETFD, FD_CLOEXEC);
Modified: prelude-manager/trunk/libev/ev_kqueue.c
===================================================================
--- prelude-manager/trunk/libev/ev_kqueue.c 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/ev_kqueue.c 2009-04-10 10:12:47 UTC (rev 11142)
@@ -101,7 +101,7 @@
if (expect_false (res < 0))
{
if (errno != EINTR)
- syserr ("(libev) kevent");
+ ev_syserr ("(libev) kevent");
return;
}
@@ -184,7 +184,7 @@
close (backend_fd);
while ((backend_fd = kqueue ()) < 0)
- syserr ("(libev) kqueue");
+ ev_syserr ("(libev) kqueue");
fcntl (backend_fd, F_SETFD, FD_CLOEXEC);
Modified: prelude-manager/trunk/libev/ev_poll.c
===================================================================
--- prelude-manager/trunk/libev/ev_poll.c 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/ev_poll.c 2009-04-10 10:12:47 UTC (rev 11142)
@@ -42,6 +42,8 @@
void inline_size
pollidx_init (int *base, int count)
{
+ /* consider using memset (.., -1, ...), which is pratically guarenteed
+ * to work on all systems implementing poll */
while (count--)
*base++ = -1;
}
@@ -96,7 +98,7 @@
else if (errno == ENOMEM && !syserr_cb)
fd_enomem (EV_A);
else if (errno != EINTR)
- syserr ("(libev) poll");
+ ev_syserr ("(libev) poll");
}
else
for (p = polls; res; ++p)
Modified: prelude-manager/trunk/libev/ev_port.c
===================================================================
--- prelude-manager/trunk/libev/ev_port.c 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/ev_port.c 2009-04-10 10:12:47 UTC (rev 11142)
@@ -59,7 +59,7 @@
if (errno == EBADFD)
fd_kill (EV_A_ fd);
else
- syserr ("(libev) port_associate");
+ ev_syserr ("(libev) port_associate");
}
}
@@ -89,10 +89,10 @@
ts.tv_nsec = (long)(timeout - (ev_tstamp)ts.tv_sec) * 1e9;
res = port_getn (backend_fd, port_events, port_eventmax, &nget, &ts);
- if (res < 0)
+ if (res == -1)
{
if (errno != EINTR && errno != ETIME)
- syserr ("(libev) port_getn");
+ ev_syserr ("(libev) port_getn");
return;
}
@@ -153,7 +153,7 @@
close (backend_fd);
while ((backend_fd = port_create ()) < 0)
- syserr ("(libev) port");
+ ev_syserr ("(libev) port");
fcntl (backend_fd, F_SETFD, FD_CLOEXEC);
Modified: prelude-manager/trunk/libev/ev_select.c
===================================================================
--- prelude-manager/trunk/libev/ev_select.c 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/ev_select.c 2009-04-10 10:12:47 UTC (rev 11142)
@@ -1,7 +1,7 @@
/*
* libev select fd activity backend
*
- * Copyright (c) 2007,2008 Marc Alexander Lehmann <[email protected]>
+ * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
@@ -79,6 +79,8 @@
int handle = fd;
#endif
+ assert (("libev: fd >= FD_SETSIZE passed to fd_set-based select backend", fd < FD_SETSIZE));
+
/* FD_SET is broken on windows (it adds the fd to a set twice or more,
* which eventually leads to overflows). Need to call it only on changes.
*/
@@ -158,6 +160,9 @@
*/
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
@@ -179,7 +184,7 @@
#ifdef _WIN32
/* select on windows errornously returns EINVAL when no fd sets have been
* provided (this is documented). what microsoft doesn't tell you that this bug
- * exists even when the fd sets are provided, so we have to check for this bug
+ * exists even when the fd sets _are_ provided, so we have to check for this bug
* here and emulate by sleeping manually.
* we also get EINVAL when the timeout is invalid, but we ignore this case here
* and assume that EINVAL always means: you have to wait manually.
@@ -196,7 +201,7 @@
else if (errno == ENOMEM && !syserr_cb)
fd_enomem (EV_A);
else if (errno != EINTR)
- syserr ("(libev) select");
+ ev_syserr ("(libev) select");
return;
}
@@ -265,7 +270,6 @@
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);
Modified: prelude-manager/trunk/libev/ev_vars.h
===================================================================
--- prelude-manager/trunk/libev/ev_vars.h 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/ev_vars.h 2009-04-10 10:12:47 UTC (rev 11142)
@@ -65,7 +65,7 @@
VARx(pid_t, curpid)
#endif
-VARx(int, postfork) /* true if we need to recreate kernel state after fork */
+VARx(char, postfork) /* true if we need to recreate kernel state after fork */
#if EV_USE_SELECT || EV_GENWRAP
VARx(void *, vec_ri)
@@ -156,6 +156,7 @@
#if EV_USE_INOTIFY || EV_GENWRAP
VARx(int, fs_fd)
VARx(ev_io, fs_w)
+VARx(char, fs_2625) /* whether we are running in linux 2.6.25 or newer */
VAR (fs_hash, ANFS fs_hash [EV_INOTIFY_HASHSIZE])
#endif
Modified: prelude-manager/trunk/libev/ev_win32.c
===================================================================
--- prelude-manager/trunk/libev/ev_win32.c 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/ev_win32.c 2009-04-10 10:12:47 UTC (rev 11142)
@@ -54,6 +54,8 @@
{
struct sockaddr_in addr = { 0 };
int addr_size = sizeof (addr);
+ struct sockaddr_in adr2;
+ int adr2_size = sizeof (adr2);
SOCKET listener;
SOCKET sock [2] = { -1, -1 };
@@ -67,7 +69,7 @@
if (bind (listener, (struct sockaddr *)&addr, addr_size))
goto fail;
- if (getsockname(listener, (struct sockaddr *)&addr, &addr_size))
+ if (getsockname (listener, (struct sockaddr *)&addr, &addr_size))
goto fail;
if (listen (listener, 1))
@@ -76,12 +78,36 @@
if ((sock [0] = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
goto fail;
- if (connect (sock[0], (struct sockaddr *)&addr, addr_size))
+ if (connect (sock [0], (struct sockaddr *)&addr, addr_size))
goto fail;
- if ((sock[1] = accept (listener, 0, 0)) < 0)
+ if ((sock [1] = accept (listener, 0, 0)) < 0)
goto fail;
+ /* windows vista returns fantasy port numbers for sockets:
+ * example for two interconnected tcp sockets:
+ *
+ * (Socket::unpack_sockaddr_in getsockname $sock0)[0] == 53364
+ * (Socket::unpack_sockaddr_in getpeername $sock0)[0] == 53363
+ * (Socket::unpack_sockaddr_in getsockname $sock1)[0] == 53363
+ * (Socket::unpack_sockaddr_in getpeername $sock1)[0] == 53365
+ *
+ * wow! tridirectional sockets!
+ *
+ * this way of checking ports seems to work:
+ */
+ if (getpeername (sock [0], (struct sockaddr *)&addr, &addr_size))
+ goto fail;
+
+ if (getsockname (sock [1], (struct sockaddr *)&adr2, &adr2_size))
+ goto fail;
+
+ errno = WSAEINVAL;
+ if (addr_size != adr2_size
+ || addr.sin_addr.s_addr != adr2.sin_addr.s_addr /* just to be sure, I mean, it's windows */
+ || addr.sin_port != adr2.sin_port)
+ goto fail;
+
closesocket (listener);
#if EV_SELECT_IS_WINSOCKET
Modified: prelude-manager/trunk/libev/ev_wrap.h
===================================================================
--- prelude-manager/trunk/libev/ev_wrap.h 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/ev_wrap.h 2009-04-10 10:12:47 UTC (rev 11142)
@@ -71,6 +71,7 @@
#define asynccnt ((loop)->asynccnt)
#define fs_fd ((loop)->fs_fd)
#define fs_w ((loop)->fs_w)
+#define fs_2625 ((loop)->fs_2625)
#define fs_hash ((loop)->fs_hash)
#else
#undef EV_WRAP_H
@@ -144,5 +145,6 @@
#undef asynccnt
#undef fs_fd
#undef fs_w
+#undef fs_2625
#undef fs_hash
#endif
Modified: prelude-manager/trunk/libev/libev.m4
===================================================================
--- prelude-manager/trunk/libev/libev.m4 2009-04-10 10:12:42 UTC (rev 11141)
+++ prelude-manager/trunk/libev/libev.m4 2009-04-10 10:12:47 UTC (rev 11142)
@@ -7,7 +7,19 @@
AC_CHECK_FUNCS(inotify_init epoll_ctl kqueue port_create poll select eventfd)
AC_CHECK_FUNC(clock_gettime, [], [
- if test -z "$LIBEV_M4_AVOID_LIBRT"; then
+ dnl on linux, try syscall wrapper first
+ if test $(uname) = Linux; then
+ AC_MSG_CHECKING(for clock_gettime syscall)
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(
+ [#include <syscall.h>
+ #include <time.h>],
+ [struct timespec ts; int status = syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts)])],
+ [ac_have_clock_syscall=1
+ AC_DEFINE(HAVE_CLOCK_SYSCALL, 1, "use syscall interface for clock_gettime")
+ AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)])
+ fi
+ if test -z "$LIBEV_M4_AVOID_LIBRT" && test -z "$ac_have_clock_syscall"; then
AC_CHECK_LIB(rt, clock_gettime)
unset ac_cv_func_clock_gettime
AC_CHECK_FUNCS(clock_gettime)
_______________________________________________
Prelude-cvslog site list
[email protected]
http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.