Nick Mathewson [Thu, 23 Apr 2009 05:40:06 +0000 (05:40 +0000)]
Fix c89 bugs reported by Cory Stup.
Others may remain. I wasn't able to get gcc --std=c89 to build libevent
at all, so I don't know what compiler the original reporter is using here.
Note that this change requires us to disable the part of our rpc code
that uses variadic macros when using a non-gcc compiler. This is a
problem if we want our rpc api to be portable.
Nick Mathewson [Thu, 23 Apr 2009 00:21:23 +0000 (00:21 +0000)]
Use signal.h, not sys/signal.h.
This is patch 2673214 from mmadia. It is correct, since we unconditionally
include signal.h in many other places, and only sometimes include sys/signal.h.
It is necessary to compile on Haiku, I'm told.
Nick Mathewson [Thu, 23 Apr 2009 00:01:24 +0000 (00:01 +0000)]
Fix min_heap_erase when we remove an element from the middle of the heap.
Previously, we could lose the heap property when we removed an item
whose parent was greater than the last element in the heap. We would
replace the removed item with the last element, and consider shifting
it down, but we wouldn't consider shifting it up.
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.