Lines Matching +full:reference +full:- +full:buffer
2 * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
3 * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
34 #include "event2/event-config.h"
35 #include "evconfig-private.h"
38 #include "util-internal.h"
39 #include "defer-internal.h"
63 /** Structures to implement a doubly-linked queue of callbacks */
81 /** The first chain in this buffer's linked list of chains. */
83 /** The last chain in this buffer's linked list of chains. */
91 * If all chains in the buffer are empty, it is the first chain.
92 * If the buffer has no chains, it is NULL.
97 * is &buf->first.
104 /** Number of bytes we have added to the buffer since we last tried to
107 /** Number of bytes we have removed from the buffer since we last
112 /** A lock used to mediate access to this buffer. */
118 /** True iff we should not allow changes to the front of the buffer
121 /** True iff we should not allow changes to the end of the buffer
125 * upon a change in the buffer, but instead are deferred to be invoked
131 /** True iff this buffer is set up for overlapped IO. */
140 /** A reference count on this evbuffer. When the reference count
141 * reaches 0, the buffer is destroyed. Manipulated with
146 /** A struct event_callback handle to make all of this buffer's callbacks
150 /** A doubly-linked-list of callback functions */
172 /** points to next buffer in the chain */
175 /** total allocation available in the buffer field. */
178 /** unused space at the beginning of buffer or an offset into a
182 /** Offset into buffer + misalign at which to start writing.
184 * in buffer. */
191 #define EVBUFFER_REFERENCE 0x0004 /**< a chain with a mem reference */
192 #define EVBUFFER_IMMUTABLE 0x0008 /**< read-only chain */
194 * memmoved, until the chain is un-pinned. */
199 * un-pinned. */
207 /** Usually points to the read-write memory belonging to this
208 * buffer allocated as part of the evbuffer_chain allocation.
209 * For mmap, this can be a read-only buffer and
213 unsigned char *buffer; member
216 /** callback for a reference chain; lets us know what to do with it when
224 /** File segment for a file-segment chain. Lives at the end of an
234 /* Declared in event2/buffer.h; defined here. */
237 int refcnt; /**< Reference count for this file segment */
271 /** source buffer the multicast parent belongs to */
282 #define ASSERT_EVBUFFER_LOCKED(buffer) \ argument
283 EVLOCK_ASSERT_LOCKED((buffer)->lock)
285 #define EVBUFFER_LOCK(buffer) \ argument
287 EVLOCK_LOCK((buffer)->lock, 0); \
289 #define EVBUFFER_UNLOCK(buffer) \ argument
291 EVLOCK_UNLOCK((buffer)->lock, 0); \
295 EVLOCK_LOCK2((buffer1)->lock, (buffer2)->lock, 0, 0); \
299 EVLOCK_UNLOCK2((buffer1)->lock, (buffer2)->lock, 0, 0); \
302 /** Increase the reference count of buf by one. */
304 /** Increase the reference count of buf by one and acquire the lock. */
306 /** Pin a single buffer chain using a given flag. A pinned chunk may not be
309 /** Unpin a single buffer chain using a given flag. */
311 /** As evbuffer_free, but requires that we hold a lock on the buffer, and
312 * releases the lock before freeing it and the buffer. */
313 void evbuffer_decref_and_unlock_(struct evbuffer *buffer);
319 /** Helper: prepares for a readv/WSARecv call by expanding the buffer to
331 (i)->buf = (ei)->iov_base; \
332 (i)->len = (unsigned long)(ei)->iov_len; \
343 int evbuffer_get_callbacks_(struct evbuffer *buffer,