diff options
author | Azat Khuzhin <azat@libevent.org> | 2019-03-16 17:09:51 +0300 |
---|---|---|
committer | Azat Khuzhin <azat@libevent.org> | 2019-03-16 17:30:15 +0300 |
commit | 8c2001e92a6615cc7b4efc8e33cff58c28effd30 (patch) | |
tree | afb0e63e08e7441310f37c9ffac986214f451c78 /include | |
parent | 6995b9a864c16bcb84ea0f7a2cf856143020316b (diff) | |
download | libevent-8c2001e92a6615cc7b4efc8e33cff58c28effd30.tar.gz |
Maximum evbuffer read configuration
Before this patch evbuffer always reads 4K at a time, while this is fine
most of time you can find an example when this will decrease throughput.
So add an API to change default limit:
- evbuffer_set_max_read()
- evbuffer_get_max_read()
And a notice that most of time default is sane.
Diffstat (limited to 'include')
-rw-r--r-- | include/event2/buffer.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/event2/buffer.h b/include/event2/buffer.h index 468588b9..56f620af 100644 --- a/include/event2/buffer.h +++ b/include/event2/buffer.h @@ -158,6 +158,30 @@ struct evbuffer *evbuffer_new(void); EVENT2_EXPORT_SYMBOL void evbuffer_free(struct evbuffer *buf); + +/** + Set maximum read buffer size + + Default is 4096 and it works fine most of time, so before increasing the + default check carefully, since this has some negative effects (like memory + fragmentation and unfair resource distribution, i.e. some events will make + less progress than others). + + @param buf pointer to the evbuffer + @param max buffer size + @return 0 on success, -1 on failure (if @max > INT_MAX). + */ +EVENT2_EXPORT_SYMBOL +int evbuffer_set_max_read(struct evbuffer *buf, size_t max); +/** + Get maximum read buffer size + + @param buf pointer to the evbuffer + @return current maximum buffer read + */ +EVENT2_EXPORT_SYMBOL +size_t evbuffer_get_max_read(struct evbuffer *buf); + /** Enable locking on an evbuffer so that it can safely be used by multiple threads at the same time. |