summaryrefslogtreecommitdiff
path: root/evbuffer-internal.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-09-29 09:30:04 -0400
committerNick Mathewson <nickm@torproject.org>2011-09-29 10:32:16 -0400
commit0ba0af9c6c3dbf4dfec8c3cd53b0d90b49153016 (patch)
tree445b061fa7a3105a1a75b8900502b8cf497672f3 /evbuffer-internal.h
parent1ef1f68462cb5509d978ae490efeff0c73569f25 (diff)
downloadlibevent-0ba0af9c6c3dbf4dfec8c3cd53b0d90b49153016.tar.gz
Prefer mmap to sendfile unless a DRAINS_TO_FD flag is set. Allows add_file to work with SSL.
The sendfile() implementation for evbuffer_add_file is potentially more efficient, but it has a problem: you can only use it to send bytes over a socket using sendfile(). If you are writing bytes via SSL_send() or via a filter, or if you need to be able to inspect your buffer, it doesn't work. As an easy fix, this patch disables the sendfile-based implementation of evbuffer_add_file on an evbuffer unless the user sets a new EVBUFFER_FLAG_DRAINS_TO_FD flag on that evbuffer, indicating that the evbuffer will not be inspected, but only written out via evbuffer_write(), evbuffer_write_atmost(), or drained with stuff like evbuffer_drain() or evbuffer_add_buffer(). This flag is off by default, except for evbuffers used for output on bufferevent_socket. In the future, it could be interesting to make a best-effort file segment implementation that tries to send via sendfile, but mmaps on demand. That's too much complexity for a stable release series, though.
Diffstat (limited to 'evbuffer-internal.h')
-rw-r--r--evbuffer-internal.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/evbuffer-internal.h b/evbuffer-internal.h
index 5879f874..89139602 100644
--- a/evbuffer-internal.h
+++ b/evbuffer-internal.h
@@ -129,6 +129,8 @@ struct evbuffer {
/** True iff this buffer is set up for overlapped IO. */
unsigned is_overlapped : 1;
#endif
+ /** Zero or more EVBUFFER_FLAG_* bits */
+ ev_uint32_t flags;
/** Used to implement deferred callbacks. */
struct deferred_cb_queue *cb_queue;