1585 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
cc1600afef Improve the speed of evbuffer_readln()
This makes some cases of bench_http about 5% faster.

Our internal evbuffer_strpbrk() function was overly general (it tried
to handle all character sets when we only used it for "\r\n"), and
not very efficient (it called memchr once for each character in the
buffer until it found a \r or a \n).  It actually showed up in some
profiles for HTTP testing, since evbuffer_readln() calls it when doing
loose CRLF detection.  This patch replaces it with a faster
implementation.
2010-03-03 16:45:32 -05:00
Nick Mathewson
2fac0f70a3 Remove signal_assign() and signal_new() macros.
These were introduced and deprecated in the same version (2.0.1-alpha),
presumably in two-stage process.  Everybody sane should be using
evsignal_assign() and evsignal_new() instead.
2010-03-03 12:15:15 -05:00
Christopher Davis
1273d2f519 VC has no getopt(), so do without in bench_http. 2010-03-02 15:31:50 -08:00
Christopher Davis
4ac38a5c38 Get bench_http to work on Windows; add a switch to enable IOCP. 2010-03-02 15:31:40 -08:00
Nick Mathewson
bf3bfd0c04 Revert the broken part of 2cffd6c937
It looks like I accidentally removed most of WIN32-Code/event-config.h
when I was bumping the version.  Fortunately, this happened when I
bumped to 2.0.4-alpha-dev rather than when I bumped to 2.0.4-alpha. :)

This patch restores the deleted parts of WIN32-Code/event-config.h
2010-03-01 22:12:04 -05:00
Nick Mathewson
22aff0492d Distribute libevent.pc.in, not libevent.pc 2010-03-01 22:06:12 -05:00
Nick Mathewson
2cffd6c937 Bump version to 2.0.4-alpha-dev 2010-02-28 16:53:42 -05:00
Nick Mathewson
9669ade525 Bump the version to 2.0.4-alpha release-2.0.4-alpha 2010-02-28 16:44:25 -05:00
Nick Mathewson
3a5cfb0d38 Add a changelog for 2.0.4-alpha from Git, sorted by hand 2010-02-28 16:44:14 -05:00
Nick Mathewson
ad85908a4f Fix compilation with --disable-debug-mode 2010-02-28 12:52:39 -05:00
Nick Mathewson
57b7248823 Small cleanups on freebsd-connect-refused patch.
There should be no need to call be_socket_enable: that does an
event_add().  What we really want to do is event_active(), to make
sure that the writecb is executed.

Also, there was one "} if () {" that was missing an else.

I've noted that the return value for evutil_socket_connect() is
getting screwy, but since that isn't an exported function, we can fix
it whenever.
2010-02-27 22:27:13 -05:00
Niels Provos
7bc48bfd3a deal with connect() failing immediately 2010-02-27 18:59:06 -08:00
Nick Mathewson
98edb891f8 Fix arc4random compilation on MSVC. 2010-02-25 17:14:41 -05:00
Nick Mathewson
1e14f82669 Try to define a sane _EVENT_SIZEOF_SIZE_T for msvc compilation 2010-02-25 17:11:48 -05:00
Nick Mathewson
23170a69f8 Fix mingw compilation 2010-02-25 16:57:57 -05:00
Nick Mathewson
7ffd387574 Delete stack-alloced event in new unit test before returning. 2010-02-24 13:40:06 -05:00
Nick Mathewson
f3dfe46206 Use new timeval diff comparison function in bufferevent test 2010-02-23 23:59:26 -05:00
Nick Mathewson
8fcb7a1b04 Add test for periodic timers that get activated for other reasons
This was already independently verified by the new bufferevent
timeout tests, but it's good to explicitly check that our code
does what it should.
2010-02-23 23:55:32 -05:00
Nick Mathewson
c02bfe12f8 Add a test for timeouts on filtering bufferevents. 2010-02-23 16:36:52 -05:00
Nick Mathewson
d3288293fd Provide consistent, tested semantics for bufferevent timeouts
The different bufferevent implementations had different behavior for
their timeouts.  Some of them kept re-triggering the timeouts
indefinitely; some disabled the event immediately the first time a
timeout triggered.  Some of them made the timeouts only count when
the bufferevent was actively trying to read or write; some did not.

The new behavior is modeled after old socket bufferevents, since
they were here first and their behavior is relatively sane.
Basically, each timeout disables the bufferevent's corresponding
read or write operation when it fires.  Timeouts are stopped
whenever we suspend writing or reading, and reset whenever we
unsuspend writing or reading.  Calling bufferevent_enable resets a
timeout, as does changing the timeout value.
2010-02-23 15:20:33 -05:00
Nick Mathewson
38ec0a773b Fix a bug in resetting timeouts on persistent events when IO triggers.
When we fixed persistent timeouts to make them reset themselves
based on the previous scheduled time rather than the current
time... we made them do so regardless of whether the event was
triggering because of a timeout or not!

This was of course bogus.  When a _timeout_ triggers, we should
schedule the event for N seconds based on the last
_schedule_ time... but when IO triggers, we should reset the
timeout for N seconds after now.
2010-02-23 15:20:33 -05:00
Nick Mathewson
e2642f0a88 Fix some race conditions in persistent events and event_reinit
I found these by adding an EVENT_BASE_ASSERT_LOCKED() call to most
of the functions in event.c that can only be called while holding
the lock.

event_reinit() never grabbed the lock, but it needed to.

event_persist_closure accessed the base to call event_add_internal()
and gettime() when its caller had already dropped the lock.

event_pending() called gettime() without grabbing the lock.
2010-02-23 15:20:33 -05:00
Nick Mathewson
4b37e6a5ea Merge remote branch 'github/split_free_from_decref' 2010-02-23 00:39:02 -05:00
Nick Mathewson
162ce8a856 Expose view of current rate limit as constrained by group limit 2010-02-23 00:38:30 -05:00
Nick Mathewson
b2fbeb3f07 Make bufferevent_free() clear all callbacks immediately.
This should end the family of bugs where we call bufferevent_free()
while a pending callback is holding a reference on the bufferevent,
and the callback tries to invoke the user callbacks before it releases
its own final reference.

This means that bufferevent_decref() is now a separate function from
bufferevent_free().
2010-02-22 15:38:23 -05:00
Nick Mathewson
db08f640d5 Suspend read/write on bufferevents during hostname lookup
When we're doing a lookup in preparation for doing a connect, we
might have an unconnected socket on hand, and mustn't actually do
any reading or writing with it.
2010-02-20 12:55:59 -05:00
Nick Mathewson
4faeaea90e Clean up formatting: function/keyword spacing consistency.
- Keywords always have a space before a paren.  Functions never do.

- No more than 3 blank lines in a row.
2010-02-19 03:39:50 -05:00
Nick Mathewson
e5cf98795e Clean up formatting: remove trailing spaces 2010-02-18 17:46:56 -05:00
Nick Mathewson
e5bbd40ad7 Clean up formatting: use tabs, not 8-spaces, to indent. 2010-02-18 17:44:09 -05:00
Nick Mathewson
8fdf09c09d Clean up formatting: Disallow space-before-tab. 2010-02-18 17:08:50 -05:00
Nick Mathewson
7515de91fe When connect() succeeds immediately, don't invoke the callback immediately.
We need this to get unit tests to pass on freebsd.
2010-02-18 14:50:44 -05:00
Nick Mathewson
b72be50d7a Add some headers to fix freebsd compilation 2010-02-18 13:52:04 -05:00
Nick Mathewson
1ba6bed89a Add the "compile" script to gitignore. 2010-02-18 13:50:15 -05:00
Nick Mathewson
48a29b6816 Add a unit test for secure rng.
Mostly, this is just to make sure our arc4random_buf() implementation isn't
dumb.
2010-02-18 01:43:37 -05:00
Nick Mathewson
ff2a134d6e Fix getpid() usage on Windows
On Windows, getpid() is _getpid(), and requires that we first include
<process.h>.  arc4random.c previously didn't know that.

Actually, I question whether arc4random needs to do its getpid() tricks
on Windows.  They exist only so that we remember to re-seed the ARC4
cipher whenever we fork... but Windows has no fork(), so I think we're
in the clear.
2010-02-18 00:54:44 -05:00
Nick Mathewson
cb52838fc5 When working without a current event base, don't try to use IOCP listeners
This fixes a bug turned up with the http unit tests, where we create
the evhttp object using an implicit (NULL) event_base.  This failed
pretty badly when we tried to use IOCP-based listeners.  We could
hunt for the current base from inside listener.c in the future, or
get the iocp base some other way, but for now this is probably the safest
solution.
2010-02-18 00:27:35 -05:00
Nick Mathewson
32c6f1bacd Construct Windows locks using InitializeCriticalSectionAndSpinCount
Previously we were using InitializeCriticalSection, which creates a
lock that blocks immediately on contention and waits to be
rescheduled.  This is inefficient; it's better to wait for a little
while before telling the US to reschedule us, in case the lock becomes
available again really soon (since most locks mostly do).

Good pthreads implementations do this automatically.  On Windows,
though, we need to call this magic function, and we need to pick the
spin count ourselves.
2010-02-18 00:27:13 -05:00
Nick Mathewson
ca46d25b01 Merge branch 'arc4random' 2010-02-17 23:02:28 -05:00
Nick Mathewson
e15e1e9486 Add the arc4random.c license to the LICENSE file. 2010-02-17 22:54:43 -05:00
Nick Mathewson
7116bf2314 Fix two unlocked reads in evbuffer.
Some initializers (in evbuffer_read and evbuffer_commit) were reading
the last and/or previous_to_last fields without grabbing the evbuffer
lock.

This may fix a hard-to-trigger race condition or two.
2010-02-15 21:11:41 -05:00
Nick Mathewson
aae7db5256 Update event-config.h version number to match configure.in 2010-02-15 17:53:24 -05:00
Nick Mathewson
60753da0e9 Merge commit 'niels/http_close_connection' 2010-02-15 17:07:26 -05:00
Nick Mathewson
63e868e69f Increment the submicro version number.
We've changed a couple of APIs introduced in 2.0.1-alpha, so it
behooves us to give high-needs apps (like Tor) a way to tell we've
done this.

Sensible apps will just say "is it 2.0.3-alpha or 2.0.4-alpha" and
ignore the existence of 2.0.3-alpha-dev, which is just as it should
be.
2010-02-15 16:45:19 -05:00
Niels Provos
2f782af35b validate close cb on server when client connection closes 2010-02-13 17:04:17 -08:00
Niels Provos
e8a9782c1d clean up terminate_chunked test 2010-02-13 16:59:37 -08:00
Nick Mathewson
4ec8fea68e Make RNG work when we have arc4random() but not arc4random_buf() 2010-02-13 00:11:44 -05:00
Nick Mathewson
3fe60fdf47 Use off_t for the length parameter of evbuffer_add_file 2010-02-12 23:40:13 -05:00
Nick Mathewson
d4de062efc Add an arc4random implementation for use by evdns
Previously, evdns was at the mercy of the user for providing a good
entropy source; without one, it would be vulnerable to various
active attacks.

This patch adds a port of OpenBSD's arc4random() calls to Libevent
[port by Chris Davis], and wraps it up a little bit so we can use it
more safely.
2010-02-11 12:53:32 -05:00
Nick Mathewson
1dd7e6dc3a Remove the 'flags' argument from evdns_base_set_option()
The 'flags' argument made sense when passed to
evdns_(base_)?parse_resolv_conf when it said which parts of the
resolv.conf file to obey.  But for evdns_set_option(), it was really
silly, since you wouldn't be calling evdns_set_option() unless you
actually wanted to set the option.  Its meaning was basically, "set
this to DNS_OPTIONS_ALL unless you want a funny surprise."

evdns_base_set_option was new in 2.0.1-alpha, so we aren't committed
to keeping it source-compatible.
2010-02-05 13:55:12 -05:00