1457 Commits

Author SHA1 Message Date
Nick Mathewson
b34abf3069 Do not close(-1) when freeing an uninitialized socket bufferevent 2010-03-13 00:31:14 -05:00
Nick Mathewson
70a44b61bb Avoid a spurious close(-1) on Linux
On Linux, we use only one fd to do main-thread signaling (since we have
eventfd()), so we don't need to close th_notify_fd[1] as we would if we were
using a socketpair.
2010-03-13 00:31:14 -05:00
Nick Mathewson
75018951ec Fix a possible double-free bug in SSL bufferevents with CLOSE_ON_FREE
With CLOSE_ON_FREE set, we were telling the BIO to free the bufferevent when
it was closed, and also freeing it ourselves.
2010-03-13 00:30:34 -05:00
Nick Mathewson
0d047c3f11 Fix an obnoxious typo in the bufferevent_timeout_filter test
We were using the same bufferevent as the child of two filtering parents,
orphaning another.  This made one get freed twice, and the other not at all.

Possible fix for bug 2963306 spotted by Doug Cuthbertson.
2010-03-13 00:29:15 -05:00
Nick Mathewson
f1bc125eb4 Improve robustness for refcounting
Document that we do intend to double-decref underlying bufferevents under
some circumstances.  Check to make sure that we don't decref past 0.
2010-03-13 00:28:50 -05:00
Nick Mathewson
6c83e6c972 Merge branch 'evbuffer_insert_point' 2010-03-12 12:26:06 -05:00
Nick Mathewson
ee41aca63e Functions to manipulate existing rate limiting groups.
This patch adds a function to change the current rate limit of a rate
limiting group, and another to free an empty rate limiting group.
2010-03-12 00:47:39 -05:00
Nick Mathewson
cdd4c4905b Try to comment some of the event code more 2010-03-12 00:38:50 -05:00
Nick Mathewson
17da042db6 Add some glass-box tests for the last_with_data code. 2010-03-11 15:39:44 -05:00
Nick Mathewson
1e7b986827 Fix last_with_data compilation on windows 2010-03-11 14:23:02 -05:00
Nick Mathewson
78772c3503 Clarify Christopher Clark's status as writer of original ht code. 2010-03-11 00:18:02 -05:00
Nick Mathewson
e470ad3c35 Allow evbuffer_read() to split across more than 2 iovecs
Previously it would only accept 2 iovecs at most, because our
previous_to_last nonsense didn't let it take any more.  This forced us
to do more reallocations in some cases when an extra small malloc
would have sufficed.
2010-03-10 23:39:30 -05:00
Nick Mathewson
6f47bd12ed Remove previous_to_last from evbuffer 2010-03-10 23:28:51 -05:00
Nick Mathewson
c8ac57f1f5 Use last_with_data in place of previous_to_last
This actually makes some of the code a lot simpler.  The only
ones that actually used previous_to_last for anything were reserving
and committing space.
2010-03-10 23:24:14 -05:00
Nick Mathewson
2a6d2a1e4b Revise evbuffer to add last_with_data
This is the first patch in a series to replace previous_to_last with
last_with_data.  Currently, we can only use two partially empty chains
at the end of an evbuffer, so if we have one with 511 bytes free, and
another with 512 bytes free, and we try to do a 1024 byte read, we
can't just stick another chain on the end: we need to reallocate the
last one.  That's stupid and inefficient.

Instead, this patch adds a last_with_data pointer to eventually
replace previous_to_last.  Instead of pointing to the penultimated
chain (if any) as previous_to_last does, last_with_data points to the
last chain that has any data in it, if any.  If all chains are empty,
last_with_data points to the first chain.  If there are no chains,
last_with_data is NULL.

The next step is to start using last_with_data everywhere that we
currently use previous_to_last.  When that's done, we can remove
previous_to_last and the code that maintains it.
2010-03-10 22:16:14 -05:00
Nick Mathewson
c7f1b820fc Merge branch 'evport' 2010-03-10 21:21:33 -05:00
Nick Mathewson
b2f2be6edc Make evdns use the regular logging system by default
Once, for reasons that made sense at the time, we had evdns.c use its
own logging subsystem with two levels, "warn" and "debug".  This leads
to problems, since setting a log handler for Libevent wouldn't actually
trap these messages, since they weren't on by default, and since some of
the warns should really be msgs.

This patch changes the default behavior of evdns.c to log to
event_(debugx,warnx,msgx) by default, and adds a new (internal-use-only)
log level of EVDNS_LOG_MSG.  Programs that set a evdns logging
function will see no change.  Programs that don't will now see evdns
warnings reported like other warnings.
2010-03-10 16:25:16 -05:00
Brodie Thiesfield
13e4f3bd89 Avoid errors in http.c when building with VC 2003 .NET 2010-03-08 13:46:48 -05:00
Brodie Thiesfield
b677032ba2 Avoid errors in evutil.c when building with _UNICODE defined 2010-03-08 13:46:04 -05:00
Nick Mathewson
2c2618d858 more whitespace normalization 2010-03-05 13:00:15 -05:00
Nick Mathewson
c7cf6f0049 Replace users of "int fd" with "evutil_socket_t fd" in portable code
Remeber, win32 has a socket type that's actually a handle, so if
there's a chance that code is run on win32, we can't use "int" as the
socket type.

This isn't a blind search-and-replace: sometimes an fd is really in
fact for a file, and not a socket at all.
2010-03-05 12:47:46 -05:00
Nick Mathewson
38b7b571c8 Add Christopher Clark and Maxim Yegorushkin to the LICENSE file 2010-03-04 01:42:04 -05:00
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