418 Commits

Author SHA1 Message Date
Nick Mathewson
539466e568 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	Makefile.am
	WIN32-Code/event2/event-config.h
	configure.in
2012-02-10 17:33:50 -05:00
Nick Mathewson
e49e289129 Update copyright notices to 2012 2012-02-10 17:29:53 -05:00
Nick Mathewson
ca76cd931f Use a wrapper function to create the notification pipe/socketpair/eventfd 2012-02-10 16:15:10 -05:00
Sebastian Hahn
e4a56ed527 Fix a compile warning in event_reinit
Introduced in 272033efe575a9dc7ec6f123a96afba5c69ff1c6
2012-01-31 19:00:24 +01:00
Nick Mathewson
604569bf3f Remove the eventqueue list and the ev_next pointers.
Those pointers were once used to maintain a complete list of
inserted IO and signal events.  But such a list is now available by
walking over ev_io_map and ev_signal_map!  So all they did was
require extra pointer operations to maintain, and extra 8-16 bytes
of storage in each struct event.

To be cowardly and keep the option of going back to having this
redundancy, I'm wrapping the removed code in a set of ifdefs.

This is a first cut; it needs cleanups and stress-testing!!  In
particular, it just plain disables a couple of functions that could
probably be saved.

There seems to be a need for an evmap_{io,signal}_foreach() or something.
2012-01-27 16:35:04 -05:00
Nick Mathewson
2c4b5de16a Restore fast-path event_reinit() for slower backends
We used to use the needs_reinit flag in struct eventop to indicate
whether an event backend had shared state across a fork(), and
therefore would require us to construct a new event backend.  But
when we realized that the signal notification fds and the thread
notification fds would always be shared across forks, we stopped
looking at it.

This patch restores the old behavior so that poll, select, and
win32select don't need to do a linear scan over all pending
fds/signals when they do a reinit.  Their life is hard enough
already.
2012-01-27 14:30:41 -05:00
Nick Mathewson
272033efe5 Make event_reinit() more robust and maintainable
Previously, event_reinit required a bunch of really dubious hacks,
and violated a lot of abstraction barriers to mess around with lists
of internal events and "pretend" to re-add them.

The new (and fairly well commented!) implementation tries to be much
smarter, by isolating the changes as much as possible to the backend
state, and minimizing the amount of abstraction violations.

Specifically, we now use event_del() to remove events we want to
remove, rather than futzing around with queues in event_reinit().
To avoid bogus calls to evsel->del(), we temporarily replace evsel
with a null-object stub.

Also, we now push the responsibility for calling evsel->add() down
into the evmap code, so that we don't actually need to unlink and
re-link all of our events.
2012-01-27 13:54:05 -05:00
Nick Mathewson
fe0afabb59 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	event.c

Edits required in:
        evmap.c
2012-01-24 10:29:31 -05:00
Nick Mathewson
3f18ad1b5f Fix a fd leak in event_reinit()
We were supposed to be closing the ev_signal_pair sockets.
2012-01-23 18:15:44 -05:00
Nick Mathewson
6e41cdc16b Fix a list corruption bug when using event_reinit() with signals present
While re-adding all the events, event_reinit() could add a signal
event, which could then cause evsig_add() to add the
base->sig.ev_signal event.  Later on its merry path through
base->eventqueue, event_reinit() would find that same event and give
it to event_io_add a second time.  This would make the ev_io_next
list for that fd become circular.  Ouch!
2012-01-23 17:59:16 -05:00
Nick Mathewson
27737d55ae Add function to check referential integrity of an event_base 2012-01-21 12:55:15 -05:00
Nick Mathewson
d5a3fe5f3e Merge remote-tracking branch 'origin/patches-2.0' 2012-01-09 12:00:04 -05:00
Nick Mathewson
f032516718 Remove bogus casts of socket to int before calling ev_callback
This should make 64-bit windows act better.

Found by Mark Heily.
2012-01-09 11:33:38 -05:00
Nick Mathewson
35c5c9558a Bypass event_add when using event_base_once() for a 0-sec timeout
Some people use event_base_once(EV_TIMEOUT) to make a callback get
called "immediately".  But this is pretty roundabout: it uses the
timeout heap to immediately put the event onto the active queue, when
it could just use event_active.  Additionally, it can lead to
surprising re-ordering behavior.

This patch changes event_base_once so it bypasses event_add() and
called event_active() directly on a pure-timeout event with an empty
timeout.
2011-12-07 11:49:52 -05:00
Nick Mathewson
9ce5053d6e Merge remote-tracking branch 'origin/patches-2.0' 2011-12-06 11:02:12 -05:00
Nick Mathewson
11f36a5f76 Be absolutely sure to clear pncalls before leaving event_signal_closure
I thought we'd fixed the cases where this could come up, but
apparently having an event_base_break() happen while processing
signal events could get us in trouble.

Found by Remi Gacogne.  Sourceforge issue 3451433 .
2011-12-05 15:06:46 -05:00
Nick Mathewson
f5b937e65f Merge remote-tracking branch 'origin/patches-2.0' 2011-11-14 18:22:08 -05:00
Nick Mathewson
e787413329 Don't try to make notifiable event_base when no threading fns are configured 2011-11-14 17:33:02 -05:00
Nick Mathewson
4e797f388f Warn when unable to construct base because of failing make_base_notifiable 2011-11-14 17:32:22 -05:00
Nick Mathewson
0cb70e3333 Merge remote-tracking branch 'origin/patches-2.0' 2011-10-26 10:17:21 -04:00
Nick Mathewson
3c824bd334 Update copyright dates to 2011. 2011-10-24 13:18:09 -04:00
Abel Mathew
212533e4a1 New event_base_update_cache_time() to set cached_tv to current time
This function is particularly useful for selectively increasing
the accuracy of the cached time value in 'base' during callbacks
that take a long time to execute.

This function has no effect if the base is currently not in its
event loop or if timeval caching is disabled via EVENT_BASE_FLAG_NO_CACHE_TIME.
2011-10-21 18:08:08 -04:00
Mansour Moufid
c8953d1b48 Add argument checks to some memory functions in `event.c'.
Add a zero check to the function `event_mm_malloc_',
i.e. simply return NULL if the sz argument is zero.
On failure, set errno to ENOMEM and return NULL.

Add a zero check to the function `event_mm_calloc_',
i.e. simply return NULL if either argument is zero.
Also add an unsigned integer multiplication check, and if an integer
overflow would occur, set errno to ENOMEM and return NULL.
On failure, set errno to ENOMEM and return NULL.

Add a NULL check to the function `event_mm_strdup_',
i.e. set errno to EINVAL and return NULL.
Also add an unsigned integer addition check, and if an integer
overflow would occur, set errno to ENOMEM and return NULL.
If a memory allocation error occurs, again set errno to ENOMEM
and return NULL.

Add unit tests to `test/regress_util.c'.
2011-10-19 23:21:57 -04:00
Nick Mathewson
128c8d6c0f Merge remote-tracking branch 'origin/patches-2.0' 2011-10-19 22:44:33 -04:00
Leonid Evdokimov
9e6a4efa51 More detailed message in case of libevent self-debugging failure. 2011-10-19 22:41:15 -04:00
Nick Mathewson
3c55b5ee0a Make evbase_priority_init() and evbase_get_npriorities() threadsafe 2011-10-11 09:50:57 -04:00
Alexander Drozdov
ee3a4ee880 Add event_base_get_npriorities() function. 2011-10-11 09:43:12 -04:00
Nick Mathewson
084e68f3f2 New EVLOOP_NO_EXIT_ON_EMPTY option to keep looping even when no events are pending
This can be useful if you want to start an event loop and then add or
remove events to it from another thread.
2011-10-05 11:11:44 -04:00
Nick Mathewson
1ebe795544 Merge remote-tracking branch 'origin/patches-2.0' 2011-09-26 11:11:30 -04:00
Nick Mathewson
4e8eb6a595 When a signal callback is activated to run multiple times, allow event_base_loopbreak to work even before they all have run.
Found by Abilio Marques.
2011-09-09 20:57:54 -04:00
Nick Mathewson
2cbe115cbc Merge remote-tracking branch 'origin/patches-2.0' 2011-08-24 16:17:56 -04:00
Nick Mathewson
5b18f13048 Make rate limiting work with common_timeout logic 2011-08-24 16:17:05 -04:00
Nick Mathewson
3c63edd1f7 Make the priority inversion code use gettime(), not evutil_gettimeofday()
Since we're computing the time after each callback, we might as well
update the time cache (if we're using it) and use monotonic time (if
we've got that).
2011-08-17 22:04:04 -04:00
Nick Mathewson
a37a0c0e35 Make max_dispatch_interval able to apply only to low-priority events
Suggested by Alexander Drozdov
2011-08-17 22:03:57 -04:00
Alexander Drozdov
a9866aa8c1 Optimization in event_process_active(): ignore maxcb & endtime for highest priority events. 2011-08-17 22:03:57 -04:00
Nick Mathewson
9fa56bdf1c Make sure max_dispatch_callbacks is never negative
Suggested by Alexander Drozdov.
2011-08-17 22:03:57 -04:00
Nick Mathewson
fd4de1e7fe Add event_config function to limit time/callbacks between calls to dispatch 2011-08-17 22:03:57 -04:00
Mark Ellzey
67275433ec more event dbg updates 2011-08-11 16:53:01 -05:00
Mark Ellzey
4b7d298415 added timeout debug logs to include event ptr. 2011-08-11 13:25:24 -05:00
Mark Ellzey
3baab0dce9 Added usec debug in another area for debug 2011-08-11 12:06:54 -05:00
Mark Ellzey
ac43ce0450 Debug addition for printing usec on TIMEOUT debugging. 2011-08-11 11:56:26 -05:00
Nick Mathewson
e91d57f1f6 Merge remote-tracking branch 'github/21_split_functions'
Conflicts:
	event.c

The conflicts were with the 21_faster_timeout_adj branch, which
added a "reinsert" function that needed to get renamed to
"reinsert_timeout".  Also, some of the code that 21_split_functions
changes got removed by 21_faster_timeout_adj.
2011-08-08 16:20:53 -04:00
Nick Mathewson
24e2480520 Merge remote-tracking branch 'github/21_faster_timeout_adj' 2011-08-08 16:17:18 -04:00
Nick Mathewson
78fb99ceb2 Merge remote-tracking branch 'origin/patches-2.0' 2011-07-04 12:22:54 -04:00
Nick Mathewson
e7fe92709e Merge remote-tracking branch 'github/20_global_locks_init' into patches-2.0 2011-07-04 12:16:08 -04:00
Nick Mathewson
5099d858b1 Merge remote-tracking branch 'origin/patches-2.0' 2011-06-08 14:29:36 -04:00
Nick Mathewson
09fe97da3b Replace an assertion for event_base_free(NULL) with a check-and-warn
event_base_free(NULL) means "free the current event base".
Previously, it would assert if there was no 'current' base.  Now it
just warns and returns.

Reported by Gilad Benjamini
2011-06-08 14:24:45 -04:00
Nick Mathewson
e40bafe796 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	Makefile.am
	WIN32-Code/event2/event-config.h
	configure.in
	test/regress_ssl.c
2011-06-04 21:40:55 -04:00
Nick Mathewson
27ce38b618 Avoid a segfault when all methods are disabled or broken 2011-06-01 17:28:21 -04:00
Nick Mathewson
94b8e676f3 Allow base-notification functions to exist without setting an fd
The kqueue and evport backends can make good use of this.
2011-05-27 22:54:16 -04:00