diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-11-17 20:31:09 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-11-17 20:31:09 +0000 |
commit | d7d1f1da09f32a14ff4c08dc0f1f0e0673ed5afd (patch) | |
tree | d02c3c5d7a4a50299aeaae5c3b7ea41d7cce6945 /evbuffer-internal.h | |
parent | 201d8d0bafeb2ba1388746ed745cd5d8defb3689 (diff) | |
download | libevent-d7d1f1da09f32a14ff4c08dc0f1f0e0673ed5afd.tar.gz |
Move responsibility for IOCP callback into bufferevent_async.
This patch from Chris Davis saves some callback depth, and adds proper
ref-counting to bufferevents when there's a deferred evbuffer callback
inflight. It could use a couple more comments to really nail down what
its invariants are.
svn:r1543
Diffstat (limited to 'evbuffer-internal.h')
-rw-r--r-- | evbuffer-internal.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/evbuffer-internal.h b/evbuffer-internal.h index d0129804..4499fec1 100644 --- a/evbuffer-internal.h +++ b/evbuffer-internal.h @@ -66,6 +66,7 @@ struct evbuffer_cb_entry { #endif }; +struct bufferevent; struct evbuffer_chain; struct evbuffer { /** The first chain in this buffer's linked list of chains. */ @@ -135,6 +136,10 @@ struct evbuffer { /** A doubly-linked-list of callback functions */ TAILQ_HEAD(evbuffer_cb_queue, evbuffer_cb_entry) callbacks; + + /** The parent bufferevent object this evbuffer belongs to. + * NULL if the evbuffer stands alone. */ + struct bufferevent *parent; }; /** A single item in an evbuffer. */ @@ -245,6 +250,8 @@ struct evbuffer_chain_reference { /** Increase the reference count of buf by one. */ void _evbuffer_incref(struct evbuffer *buf); +/** Increase the reference count of buf by one and acquire the lock. */ +void _evbuffer_incref_and_lock(struct evbuffer *buf); /** Pin a single buffer chain using a given flag. A pinned chunk may not be * moved or freed until it is unpinned. */ void _evbuffer_chain_pin(struct evbuffer_chain *chain, unsigned flag); @@ -273,6 +280,9 @@ int _evbuffer_read_setup_vecs(struct evbuffer *buf, ev_ssize_t howmuch, (i)->len = (ei)->iov_len; \ } while(0) +/** Set the parent bufferevent object for buf to bev */ +void evbuffer_set_parent(struct evbuffer *buf, struct bufferevent *bev); + #ifdef __cplusplus } #endif |