2906 Commits

Author SHA1 Message Date
Greg Hazel
bff5f94073 check for arc4random_buf at runtime, on OS X
(Tweaked by nickm: Fix up the arcr4andom_buf OSX hack so that the
fallback case isn't compiled into the code when we have
arc4random_buf() and we are not on OSX.  Also add a comment
explaining what's up.)
2012-05-31 00:48:24 -04:00
Nick Mathewson
76b994ac61 Merge pull request #54 from rosslagerwall/configure-dup
Remove unnecessary code in configure.in.
2012-05-21 10:59:20 -07:00
Nick Mathewson
9444524f85 Make it more clear that NOLOCK means "I promise, no multithreading" 2012-05-14 11:10:51 -04:00
Nick Mathewson
6fab9eef8f Add caveat to docs about bufferevent_free() with data in outbuf
Based on libevent-users thread wtih Alexander Klauer
2012-05-14 10:58:01 -04:00
Nick Mathewson
371efebdc3 Be more clear that LEV_OPT_DEFERRED_ACCEPT has tricky prereqs 2012-05-14 10:55:27 -04:00
Ross Lagerwall
e65914fdfe Remove unnecessary code in configure.in. 2012-05-12 08:38:19 +02:00
Nick Mathewson
7d6aa5ee68 Add an event_base_loopcontinue() to tell libevent to rescan right away 2012-05-09 12:06:00 -04:00
Nick Mathewson
c0e425abdc Restore our priority-inversion-prevention code with deferreds
Back when deferred_cb stuff had its own queue, the queue was always
executed, but we never ran more than 16 callbacks per iteration.
That made for two problems:

1: Because deferred_cb stuff would always run, and had no priority,
it could cause priority inversion.

2: It doesn't respect the max_dispatch_interval code.

Then, when I refactored deferred_cb to be a special case of
event_callback, that solved the above issues, but made for two more
issues:

3: Because deferred_cb stuff would always get the default priority,
it could could low-priority bufferevents to get too much priority.

4: With code like bufferevent_pair, it's easy to get into a
situation where two deferreds keep adding one another, preventing
the event loop from ever actually scanning for more events.

This commit fixes the above by giving deferreds a better notion of
priorities, and by limiting the number of deferreds that can be
added to the _current_ loop iteration's active queues.  (Extra
deferreds are put into the active_later state.)

That isn't an all-purpose priority inversion solution, of course: for
that, you may need to mess around with max_dispatch_interval.
2012-05-09 12:06:00 -04:00
Nick Mathewson
581b5beb98 Give event_base_process_active a single exit path 2012-05-09 12:06:00 -04:00
Nick Mathewson
c46cb9c3a2 Make event_base_getnpriorities work with old "implicit base" code 2012-05-09 12:06:00 -04:00
Nick Mathewson
bd395549a3 Add a bufferevent_get_priority() function 2012-05-09 12:06:00 -04:00
Nick Mathewson
f90e25593c New event_get_priority() function to return an event's priority 2012-05-09 12:06:00 -04:00
Nick Mathewson
a4079aa88a Replace more deferred_cb names with event_callback 2012-05-09 12:05:59 -04:00
Nick Mathewson
ae2b84b257 Replace deferred_cbs with event_callback-based implementation. 2012-05-09 12:05:53 -04:00
Nick Mathewson
fec8bae267 event_base_assert_ok: check value of event_active_count for correctness 2012-05-09 12:05:53 -04:00
Nick Mathewson
745a63dba3 Add "active later" event_callbacks to supersede deferred
An event or event callback can now be in an additional state: "active
later".  When an event is in this state, it will become active the
next time we run through the event loop.  This lets us do what we
wanted to with deferred callbacks: make a type of active thing that
avoids infinite circular regress in a way that starves other events or
exhausts the stack.  It improves on deferred callbacks by respecting
priorities, and by having a non-kludgy way to avoid event starvation.
2012-05-09 12:05:53 -04:00
Nick Mathewson
9889a3d883 Remove the unused bits from EVLIST_ALL 2012-05-09 12:05:53 -04:00
Nick Mathewson
cba59e5325 Refactor the callback part of an event into its own event_callback type
This shouldn't have any visible effect, but it's necessary or
advisible for a few changes and cleanups I would like to make,
including:
   * Replacing the deferred queue with a type that works more as if it
     were an event.
   * Introducing a useful "activate this on the next round through the
     event loop" state for events and deferreds.
   * Adding an "on until further notice" status for events, to allow a
     saner win32-hybrid approach.
   * Eventually, making all user callbacks first-class things with
     event-like semantics.
2012-05-09 12:05:53 -04:00
Nick Mathewson
981aa0efc9 Merge remote-tracking branch 'origin/patches-2.0' 2012-05-03 16:37:39 -04:00
Nick Mathewson
faa92253e9 Bump version to 2.0.19-stable-dev 2012-05-03 16:34:29 -04:00
Nick Mathewson
8a9b0cdf63 Increment version to 2.0.19-stable release-2.0.19-stable 2012-05-03 12:33:36 -04:00
Nick Mathewson
e0aa08666e Merge remote-tracking branch 'github/patches-2.0'
Conflicts:
	test/regress.c
2012-05-03 12:21:57 -04:00
Nick Mathewson
e06206ebd8 Oops; fix the *right* windows compile issue 2012-05-03 12:15:11 -04:00
Nick Mathewson
be7a0be816 Fix win32 build issues: sleep, pid_t 2012-05-03 12:05:52 -04:00
Nick Mathewson
4b70286ef1 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	ChangeLog
	README
	evdns.c
	sample/dns-example.c
2012-05-02 17:12:23 -04:00
Nick Mathewson
cecb111bcd Start changelog for 2.0.19-stable 2012-05-02 17:09:11 -04:00
Nick Mathewson
265e6779dd Fix evdns build with threads disabled
The last evdns change apparently broke it, by using a "base"
variable that we were only declaring with threads turned on.
2012-05-02 16:52:27 -04:00
Nick Mathewson
3d9e52ac56 When retransmitting a timed-out DNS request, pick a fresh nameserver.
Otherwise, requests initially sent to a failing nameserver would
stay there indefinitely, even if other nameservers would work.

Fix for sourceforge bug 3518439
2012-05-01 19:52:55 -04:00
Nick Mathewson
d873d6787c Make some evdns.c debug logs more verbose 2012-05-01 19:52:49 -04:00
Nick Mathewson
6610fa5a27 dns-example.c can now take a resolv.conf file on the commandline 2012-05-01 17:07:50 -04:00
Nick Mathewson
9fbfe9b948 Correctly handle running on a system where accept4 doesn't work.
Previously, we treated EINVAL as the only errno that indicated a
broken accept4.  But EINVAL only appears when one of the SOCK_*
options isn't supported.  If the accept4 syscall itself isn't there,
we'll get an ENOSYS.

Reported by Azat Khuzhin.
2012-05-01 14:34:31 -04:00
Nick Mathewson
a163026099 Merge branch '21_robust_monotonic' 2012-05-01 13:22:56 -04:00
Nick Mathewson
2e882a071b Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	event.c
2012-04-30 22:00:05 -04:00
Nick Mathewson
30f0671526 Merge remote-tracking branch 'github/20_active_prio_inv' into patches-2.0 2012-04-30 21:45:43 -04:00
Nick Mathewson
b98624ef35 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	bufferevent_openssl.c
2012-04-30 21:33:56 -04:00
Nick Mathewson
b3887cdf3b Work-around a stupid gcov-breaking bug in OSX 10.6
This only affects the unit tests.

Fix found at http://rachelbythebay.com/w/2011/07/12/forkcrash/

(Backport from 2.1)
2012-04-30 21:17:26 -04:00
Mark Ellzey
4e62cd167b Fixed potential double-readcb execution with openssl bufferevents.
the function do_read() will call SSL_read(), and if successful, will
call _bufferevent_run_readcb() before returning to consider_reading().

consider_reading() will then check SSL_pending() to make sure all
pending data has also been read. If it does not, do_read() is called
again.

The issue with this is the possibility that the function that is
executed by _bufferevent_run_readcb() called
bufferevent_disable(ssl_bev, EV_READ) before the second do_read(); In
this case, the users read callback is executed a second time. This is
potentially bad for applications that expect the bufferevent to stay
disabled until further notice. (this is why running openssl bufferevents
without DEFER_CALLBACKS has always been troublesome).
2012-04-30 21:02:01 -04:00
Nick Mathewson
2bfda4012c If a higher-priority event becomes active, don't continue running events of the current priority.
Bug found by Ralph Castain.
2012-04-30 17:30:48 -04:00
Zack Weinberg
5859c235de Generate event-config.h with a single sed script
This approach should make the creation of the file more atomic, to
fix a bug reported by Dinh.

This patch has one change from Zack's original version: it avoids
$<, since Dave Hart tells me he thinks that's not so portable.

(commit message by nickm)
2012-04-27 09:42:01 -04:00
Nick Mathewson
e02222741e Merge remote-tracking branch 'origin/patches-2.0' 2012-04-27 09:36:13 -04:00
Zack Weinberg
30b6f889f7 Generate event-config.h with a single sed script
This approach should make the creation of the file more atomic, to
fix a bug reported by Dinh.

This patch has one change from Zack's original version: it avoids
$<, since Dave Hart tells me he thinks that's not so portable.

(commit message by nickm)
2012-04-27 09:32:51 -04:00
Nick Mathewson
26c75828b7 When PRECISE_TIMERS is set with epoll, use timerfd for microsecond precision
The epoll interface ordinarily gives us one-millisecond
precision, so on Linux it makes perfect sense to use the
CLOCK_MONOTONIC_COARSE timer.  But when the user has set the new
PRECISE_TIMER flag for an event_base (either by the
EVENT_BASE_FLAG_PRECISE_TIMER flag, or by the EVENT_PRECISE_TIMER
environment variable), they presumably want finer granularity.

On not-too-old Linuxes, we can achieve this using the Timerfd
mechanism, which accepts nanosecond granularity and understands
posix clocks.  It's a little more expensive than just calling
epoll_wait(), so we won't do it by default.
2012-04-26 16:42:21 -04:00
Nick Mathewson
7428c78a95 Improve the monotonic-time unit test: make it check the step size 2012-04-26 16:42:21 -04:00
Nick Mathewson
630f077c29 Simple unit tests for monotonic timers 2012-04-26 16:42:21 -04:00
Nick Mathewson
2c470452fb Implement fast/precise monotonic clocks on Windows
This uses code from libutp, which was released under the MIT
license; see evutil_time.c and LICENSE changes.
2012-04-26 15:44:37 -04:00
Nick Mathewson
a2598ec6bd Add EVENT_PRECISE_TIMER environment var for selecting precise-but-slow timer 2012-04-26 15:44:37 -04:00
Nick Mathewson
f5e4eb05e5 Refactor monotonic timer handling into a new type and set of functions; add a gettimeofday-based ratcheting implementation
Now, event.c can always assume that we have a monotonic timer; this
makes event.c easier to write.
2012-04-26 15:44:31 -04:00
Nick Mathewson
71bca50f12 Split out time-related prototypes into time-internal.h 2012-04-20 12:27:12 -04:00
Nick Mathewson
c419485442 Split out time-related evutil functions into a new evutil_time.c 2012-04-20 12:19:03 -04:00
Nick Mathewson
2711cda300 Split long lists in Makefile.am into one-item-per-line 2012-04-20 12:14:20 -04:00