60 Commits

Author SHA1 Message Date
Nick Mathewson
17efc1cdfa Update all our copyright notices to say "2010" 2010-03-04 01:38:48 -05:00
Nick Mathewson
c8c6a8978e Minimize epoll_ctl calls by using changelist
The logic here is a little complex, since epoll_add must used called exactly
when no events were previously set, epoll_mod must be used when any events
were previously set, and epoll_del only called when the removing all events.
2010-01-23 17:02:11 -05:00
Jardel Weyrich
d0939d2b97 Introduced evutil_make_socket_closeonexec() to preserve fd flags for F_SETFD.
Use this to eliminate the various macros that called F_SETFD throughout
the code.
2009-12-29 15:12:56 -05:00
Nick Mathewson
76cd2b70bb Stop passing EVTHREAD_READ and EVTHREAD_WRITE to non-rw locks.
Previously, our default lock model kind of assumed that every lock was
potentially a read-write lock.  This was a poor choice, since
read-write locks are far more expensive than regular locks, and so the
lock API should only use them when we can actually take advantage of
them.  Neither our pthreads or win32 lock implementation provided rw
locks.

Now that we have a way (not currently used!) to	indicate that we
really want a read-write lock, we shouldn't actually say "lock this
for reading" or "lock this for writing" unless we mean it.
2009-11-27 17:36:51 -05:00
Nick Mathewson
18a8cfac39 Prefer calloc(a,b) to malloc(a*b). via openbsd.
svn:r1531
2009-11-15 19:00:12 +00:00
Nick Mathewson
784b8773a4 We do not work any more without an event-config.h; stop pretending that it is meaningful to check for HAVE_CONFIG_H
svn:r1516
2009-11-06 21:46:57 +00:00
Nick Mathewson
0fd0255fa4 Remove compat/sys/_time.h
I've gone through everything that it declared to see where it was used,
and it seems that we probably don't need it anywhere.

Here's what it declared, and why I think we're okay dropping it.

o struct timeval {}
  (Used all over, and we can't really get away with declaring it ourselves;
  we need the same definition the system uses.  If we can't find struct
  timeval, we're pretty much sunk.)

o struct timespec {}
  (Used in event.c, evdns.c, kqueue.c, evport.c.  Of these,
   kqueue.c and event.c include sys/_time.h.  event.c conditions its use on
   _EVENT_HAVE_CLOCK_GETTIME, and kqueue() only works if timespec is defined.)

o TIMEVAL_TO_TIMESPEC
  (Used in kqueue.c, but every place with kqueue has sys/time.h)

o struct timezone {}
  (event2/util.h has a forward declaration; only evutil.c references it and
   doesn't look at its contents.)

o timerclear, timerisset, timercmp, timeradd, timersub
  (Everything now uses the evutil_timer* variants.)

o ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF, struct itemerval
  (These are only used in test/regress.c, which does not include _time.h)

o CLOCK_REALTIME
  (Only used in evdns.c, which does not include _time.h)

o TIMESPEC_TO_TIMEVAL
o DST_*
o timespecclear, timespecisset, timespeccmp, timespecadd, timespecsub
o struct clockinfo {}
o CLOCK_VIRTUAL, CLOCK_PROF
o TIMER_RELTIME, TIMER_ABSTIME
  (unused)

svn:r1494
2009-11-03 19:54:56 +00:00
Nick Mathewson
2e36dbe1a6 Use EVUTIL_ASSERT() consistently instead of assert.
svn:r1464
2009-10-26 20:00:43 +00:00
Nick Mathewson
6b22e74aa1 Add locking to event_base_loop.
This is harder than it sounds, since we need to make sure to
release the lock around the key call to the kernel (e.g.,
select, epoll_wait, kevent), AND we need to make sure that
none of the fields that are used in that call are touched by
anything that might be running concurrently in another
thread.  I managed to do this pretty well for everything but
poll().  With poll, I needed to introduce a copy of the
event_set structure.

This patch also fixes a bug in win32.c where we called
realloc() instead of mm_realloc().

svn:r1450
2009-10-21 03:54:00 +00:00
Nick Mathewson
e3fd294a6d Spelling fixes in comments and strings.
svn:r1445
2009-10-16 13:19:57 +00:00
Nick Mathewson
2622e5ace2 Fix the assert I added to epoll.c: spotted by Dmitry Novikov
svn:r1432
2009-09-16 17:17:57 +00:00
Nick Mathewson
85255a6397 Make epoll use less RAM.
We do this by not allocating the maximum epoll_event array for the epoll
backend at startup.  Instead, we start out accepting 32 events at a time, and
double the array's size when it seems that the OS is generating events faster
than we're requesting them.  This saves up to 374K per epoll-based
event_base.  Resolves bug 2839240.

svn:r1428
2009-09-11 18:47:35 +00:00
Nick Mathewson
b85b710cf5 Update copyright statements to reflect the facts that:
a) this is 2009
b) niels and nick have been comaintainers for a while
c) saying "all rights reserved" when you then go on to explicitly
   disclaim some rights is sheer cargo-cultism.

svn:r1065
2009-01-27 22:34:36 +00:00
Nick Mathewson
8889a77039 Replace all use of config.h with event-config.h.
svn:r1064
2009-01-27 22:30:46 +00:00
Nick Mathewson
554e14934e Move per-fd info from eventops into evmap. Not done for win32.c yet.
svn:r1008
2009-01-14 20:52:32 +00:00
Nick Mathewson
169321c9e6 Rename four internal headers to follow the -internal.h convention.
svn:r1000
2009-01-13 20:26:37 +00:00
Niels Provos
d776f8462b deprecate the usage of signal_{add,del,set} and name it evsignal_{add,del,set} instead; move the old definitions to compat
svn:r973
2008-12-23 22:23:37 +00:00
Niels Provos
02b2b4d1be Restructure the event backends so that they do not need to keep track of events themselves, as a side effect multiple events can use the same fd or signal.
svn:r972
2008-12-23 16:37:01 +00:00
Niels Provos
808f00e1a1 constify structs; from Andrei Nigmatulin
svn:r959
2008-12-13 06:11:12 +00:00
Nick Mathewson
05965921ab Add new functions to access backends by their features and to query the features of a backend.
svn:r842
2008-05-31 14:37:31 +00:00
Nick Mathewson
39400e68b6 Patch from Valery Kholodkov: support for edge-triggered events with epoll and kqueue. Changed from original patch: made test into a regression test, with explicit success/failure for edge-triggered and non-edge-triggered cases. Closes SF request 1968284.
svn:r840
2008-05-30 16:56:34 +00:00
Niels Provos
2deb3ce061 simplify handling of environment variables for disabling backends;
make event_get_supported_methods obey environment variables; this
fixes make verify; problem reported by Scott Lamb.


svn:r838
2008-05-29 01:39:43 +00:00
Nick Mathewson
49868b618a r15316@tombo: nickm | 2008-04-24 20:58:36 -0400
Rename internal memory management functions from event_malloc() etc to mm_malloc() etc.


svn:r725
2008-04-25 01:18:08 +00:00
Nick Mathewson
3f3a16757f r15219@tombo: nickm | 2008-04-17 15:12:17 -0400
Use new includes in epoll.c


svn:r716
2008-04-17 19:17:50 +00:00
Nick Mathewson
f9f4d4fe17 r19309@catbus: nickm | 2008-04-11 16:02:07 -0400
Fix for epoll-on-linux bug (#1908866) where timeout values over (LONG_MAX-999)/HZ) (35 for me, or maybe 6 hours 50 min for some people, or maybe 3 hours 25 minutes for a special few) get treated as "wait forever".  This actually deserves to be fixed in the kernel, but even if it is we will need to support Linux versions with this bug.


svn:r709
2008-04-11 20:02:50 +00:00
Nick Mathewson
44ceb945a3 r19305@catbus: nickm | 2008-04-10 15:34:10 -0400
Fix bug 1938754: do not warn when epoll_create() fails with ENOSYS.


svn:r706
2008-04-10 19:34:50 +00:00
Niels Provos
ca42671a14 make event methods static so that they are not exported; from Andrei Nigmatulin
svn:r692
2008-03-29 01:45:45 +00:00
Nick Mathewson
d80c1c3689 r17185@catbus: nickm | 2007-12-16 14:33:40 -0500
Fix compilation with --enable-gcc-warnings enabled.


svn:r599
2007-12-16 19:34:09 +00:00
Niels Provos
fbe24f43ab remove obsoleted recalc code
svn:r581
2007-12-09 05:07:20 +00:00
Niels Provos
5f3e31596b move EV_PERSIST handling out of the event backends
svn:r555
2007-11-27 01:39:10 +00:00
Nick Mathewson
7eb250e9c5 r14939@tombo: nickm | 2007-11-25 11:59:26 -0500
New function event_set_mem_functions to replace internal calls to malloc, free, etc with a user-supplied functions.


svn:r541
2007-11-25 17:14:19 +00:00
Niels Provos
88897852fc provide event_reinit() to reinitialized an event_base after fork - necessary for epoll/kqueue
svn:r539
2007-11-25 06:57:59 +00:00
Niels Provos
bbed0954b1 revert r505; it introduced errors in epoll
svn:r508
2007-11-11 03:05:03 +00:00
Nick Mathewson
9f0f3d6da2 r16584@catbus: nickm | 2007-11-10 00:00:59 -0500
Patch from Christopher Lane: reduce branch count in epoll_dispatch.c and generally improve clarity.


svn:r505
2007-11-10 05:18:11 +00:00
Nick Mathewson
3c1bbca672 r14744@tombo: nickm | 2007-11-06 21:30:11 -0500
Fix coding error: patch from Charles Kerr.


svn:r483
2007-11-07 02:30:17 +00:00
Nick Mathewson
d257a4c0d6 r16454@catbus: nickm | 2007-11-06 09:59:45 -0500
Small code cleanups in epoll_dispatch(): remove a needless variable and some redundant conditionals.


svn:r478
2007-11-06 20:57:32 +00:00
Niels Provos
2026b21598 remove last vestiges of RBTREE
svn:r470
2007-11-03 23:53:49 +00:00
Niels Provos
3ad6b47e03 make clock_monotonic work; do not use default timeout;
from Scott Lamb, plus some fixes from me.


svn:r371
2007-07-30 22:41:00 +00:00
Niels Provos
41b7cbc381 more the signal base into the event base; this removes global state and makes signals
work better with threading; from Wouter Wijngaards
small fixes for kqueue and style by me


svn:r351
2007-03-10 06:37:53 +00:00
Niels Provos
b5d2f9a255 rolling back r339: evconfig.h does not work
svn:r341
2007-03-01 06:25:18 +00:00
Niels Provos
8d94bd03eb signal fixes from scott lamb
svn:r340
2007-02-28 04:29:18 +00:00
Niels Provos
127c260bb7 make evconfig.h available as installed header file; not
really ideal but good enough for me; from Nick Mathewson


svn:r339
2007-02-28 04:02:29 +00:00
Niels Provos
2e8051f593 introduce a way to free the base from Nick Mathewson <nickm@freehaven.net>
svn:r210
2006-03-28 04:40:54 +00:00
Niels Provos
65644dfb80 solaris kernel changes are not backwards compatible - how retarded. problem
pointed out by: Geoffrey Giesemann


svn:r185
2005-11-12 19:04:17 +00:00
Niels Provos
cdcfae7fc1 call epoll_ctl after changing our state table; in case that epoll_ctl fails
we need to make sure that the table is consistent. from William Ahern


svn:r162
2005-05-10 08:14:39 +00:00
Niels Provos
1919a4aed6 suppress valgrind warnings from knew -a- pimb.org
svn:r138
2005-03-31 19:53:06 +00:00
Niels Provos
fbdaf3ab62 debugging callbacks from Nick Mathewson <nickm@freehaven.net>
svn:r136
2005-03-29 07:03:10 +00:00
Niels Provos
3ba224dbd5 fixes for threaded operations from Andrew Danforth
svn:r129
2005-01-03 18:58:40 +00:00
Niels Provos
8773c4c96c make libevent thread-safe; first cut
svn:r122
2004-11-25 09:50:18 +00:00
Niels Provos
96a25ae6a2 when converting usec to msec round up; so that libevent does not spin until
the time conversion has caught up; from Aaron Hopkins <aaron at die.net>


svn:r121
2004-09-19 22:38:34 +00:00