Nick Mathewson [Mon, 13 Apr 2009 03:08:11 +0000 (03:08 +0000)]
Refactor new elements of bufferevent into bufferevent_private structure
This way we don't expose more of a bufferevent than we need to. One
motivation is to make it easier to automatically get deferred callbacks
with a bufferevent without exposing the deferred_cb structure.
Nick Mathewson [Fri, 10 Apr 2009 15:01:31 +0000 (15:01 +0000)]
Add a linked-pair abstraction to bufferevents.
The new bufferevent_pair abstraction works like a set of buferevent_sockets
connected by a socketpair, except that it doesn't require a socketpair,
and therefore doesn't need to get the kernel involved.
It's also a good way to make sure that deferred callbacks work. It's a good
use case for deferred callbacks: before I implemented them, the recursive
relationship between the evbuffer callback and the read callback would
make the unit tests overflow the stack.
Nick Mathewson [Fri, 10 Apr 2009 14:22:33 +0000 (14:22 +0000)]
Initial support for a lightweight 'deferred callbacks'.
A 'deferred callback' is just a function that we've queued in the
event base. This ability is needed for some mt stuff, and for complex
callback chains. For internal use only.
Nick Mathewson [Fri, 10 Apr 2009 14:21:53 +0000 (14:21 +0000)]
Don't allow internal events to starve lower-priority events.
This is exceptionally important with multithreaded stuff, where we use
an event to notify the base that other events have been made active.
If the activated events have a prioirty number greater than that of the
notification event, it will starve them, and that's no good.
Nick Mathewson [Wed, 8 Apr 2009 03:05:42 +0000 (03:05 +0000)]
Prevent unsupported modifications to bufferevent_sock buffers.
In particular, we don't allow adding any data to end front of inbuf
(we do that when we read), or removing it from the front of outbuf (we
drain data only when we write).
Nick Mathewson [Wed, 8 Apr 2009 03:04:39 +0000 (03:04 +0000)]
Add freeze support to evbuffers.
From the documentation:
Prevent calls that modify an evbuffer from succeeding. A buffer may
frozen at the front, at the back, or at both the front and the back.
If the front of a buffer is frozen, operations that drain data from
the front of the buffer, or that prepend data to the buffer, will
fail until it is unfrozen. If the back a buffer is frozen, operations
that append data from the buffer will fail until it is unfrozen.
We'll use this to ensure correctness on an evbuffer when we're waiting
for an overlapped IO call to finish.
Nick Mathewson [Wed, 8 Apr 2009 03:03:59 +0000 (03:03 +0000)]
Add a new facility to "pin" the memory in an evbuffer chain.
For overlapped IO (and possibly other stuff) we need to be able to
label an evbuffer_chain as "pinned", meaning that every byte in it
must remain at the same address as it is now until it unpinned. This
differs from being "immutable": it is okay to add data to the end
of a pinned chain, so long as existing data is not moved.
Nick Mathewson [Mon, 6 Apr 2009 20:38:42 +0000 (20:38 +0000)]
Avoid a double event_del() in evdns.c.
The bug could occur when a nameserver was marked as up, but then an
outstanding probe sent to the nameserver failed. Now, evdns_up() cancels
any outstanding probe.
Nick Mathewson [Sun, 5 Apr 2009 04:15:01 +0000 (04:15 +0000)]
Munge the read_suspended flag before re-enabling reads on the underlying bufferevent. This makes it so the enabled thing has some idea whether reads are supposed to be suspended or not.
Nick Mathewson [Fri, 3 Apr 2009 01:21:36 +0000 (01:21 +0000)]
Add a new improved search function.
The old evbuffer_find didn't allow iterative searching, and forced us
to repack the buffer completely every time we searched in it. The
new evbuffer_search addresses both of these. As a side-effect, the
evbuffer_find implementation is now a little more efficient.
Nick Mathewson [Tue, 10 Feb 2009 21:40:12 +0000 (21:40 +0000)]
Do not use ctypes functions in cases when we need the "net" locale.
This patch adds a new set of EVUTIL_IS* functions to replace use of
the ctypes is* functions in all cases where we care about characters'
interpretations in net ascii rather than in the locale. For example,
when we're working with DNS hostnames, we don't want to do the 0x20
hack on non-ascii characters, even if the host thinks they should be
isalpha.
Nick Mathewson [Tue, 10 Feb 2009 19:38:54 +0000 (19:38 +0000)]
More unit tests for evbuffer_add_reference to make sure that certain interleaved data patterns work; that free invokes callback; that callbacks are not invoked too early or later; etc.
Nick Mathewson [Sun, 1 Feb 2009 01:43:58 +0000 (01:43 +0000)]
Support temporarily suspending an evbuffer callback. This is different from disabling the callback, since we want to process changes, but not just yet.