summaryrefslogtreecommitdiff
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
...
* | improve the description of parameter to evbuffer_read()yuangongji2019-09-221-1/+2
| |
* | Doxygen documentation improvementsyuangongji2019-08-2919-65/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Documentation for `bufferevent_compat.h` and `rpc.h` is not generated since the `@file` command is missing. It can be fixed by adding `@file` in file comment block. - The briefs of buffer.h,bufferevent.h and some other files are missing. Adding `@brief` command can fix it. - The parameters in the function declaration are different from the parameters following the `@param` command.We should change them to the same. - Documentation of `watch.h` is not generated since `watch.h` has not been added to the Doxyfile `INPUT` tag. - Add link to the watch.h in event.h
* | buffer: fix possible NULL dereference in evbuffer_setcb() on ENOMEMAzat Khuzhin2019-07-311-1/+2
| | | | | | | | | | | | | | | | | | | | | | [ @azat: - add return heredoc for evbuffer_setcb() - add unit test with event_set_mem_functions() - look through the report from abi-compliance-checker/abi-dumper ] Closes: #855
* | autotools: do not install bufferevent_ssl.h under --disable-opensslAzat Khuzhin2019-06-261-2/+5
| | | | | | | | Refs: https://github.com/libevent/libevent/issues/760#issuecomment-502345788
* | evdns: add new options -- so-rcvbuf/so-sndbufAzat Khuzhin2019-06-151-1/+2
| | | | | | | | | | | | This will allow to customize SO_RCVBUF/SO_SNDBUF for nameservers in this evdns_base, you may want to adjust them if the kernel starts dropping udp packages.
* | typo error in header fileyuangongji2019-05-312-7/+7
| |
* | Implement bufferevent_socket_connect_hostname_hints()Joseph Spadavecchia2019-05-131-2/+23
| | | | | | | | | | | | So that ai_flags (such as AI_ADDRCONFIG) can be specified. Closes: #193 (cherry-picked with conflicts resolved)
* | Protect min_heap_push_ against integer overflow.Tobias Stoeckmann2019-04-221-1/+1
| | | | | | | | | | | | | | | | Converting unsigned to size_t for size of memory objects allows proper handling of very large heaps on 64 bit systems. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Closes: #799 (cherry-picked)
* | Added http method extendingThomas Bernard2019-04-111-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | User can define his own response method by calling evhttp_set_ext_method_cmp() on the struct http, or evhttp_connection_set_ext_method_cmp() on the connection. We expose a new stucture `evhttp_ext_method` which is passed to the callback if it's set. So any field can be modified, with some exceptions (in evhttp_method_): If the cmp function is set, it has the ability to modify method, and flags. Other fields will be ignored. Flags returned are OR'd with the current flags. Based on changes to the #282 from: Mark Ellzey <socket@gmail.com>
* | http: Update allowed_methods field from 16 to 32bits.Thomas Bernard2019-04-111-1/+1
| |
* | Remove experimental note for finalizers APIAzat Khuzhin2019-04-071-19/+0
| |
* | evwatch: Add "prepare" and "check" watchers.Dan Rosen2019-04-032-0/+135
| | | | | | | | | | | | | | | | | | | | Adds two new callbacks: "prepare" watchers, which fire immediately before we poll for I/O, and "check" watchers, which fire immediately after we finish polling and before we process events. This allows other event loops to be embedded into libevent's, and enables certain performance monitoring. Closes: #710
* | evdns: add DNS_OPTION_NAMESERVERS_NO_DEFAULT/EVDNS_BASE_NAMESERVERS_NO_DEFAULTAzat Khuzhin2019-04-011-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | - DNS_OPTION_NAMESERVERS_NO_DEFAULT Do not "default" nameserver (i.e. "127.0.0.1:53") if there is no nameservers in resolv.conf, (iff DNS_OPTION_NAMESERVERS is set) - EVDNS_BASE_NAMESERVERS_NO_DEFAULT If EVDNS_BASE_INITIALIZE_NAMESERVERS isset, do not add default nameserver if there are no nameservers in resolv.conf (just set DNS_OPTION_NAMESERVERS_NO_DEFAULT internally) Fixes: #569
* | evdns: add descriptions for DNS_OPTION_*/DNS_OPTIONS_ALLAzat Khuzhin2019-04-011-1/+26
| |
* | Adjust evbuffer max read for buffereventsAzat Khuzhin2019-03-161-0/+2
| |
* | Maximum evbuffer read configurationAzat Khuzhin2019-03-161-0/+24
| | | | | | | | | | | | | | | | | | | | | | 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.
* | http: add WebDAV methods supportAlexander Drozdov2019-03-141-2/+12
| | | | | | | | | | | | | | WebDAV introduced new HTTP methods (RFC4918): PROPFIND, PROPPATCH, MKCOL, LOCK, UNLOCK, COPY, MOVE. Add support of the methods.
* | http: implement separate timeouts for read/write/connect phaseAzat Khuzhin2019-03-051-11/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch allows to change timeout for next events read/write/connect separatelly, using new API: - client: evhttp_connection_set_connect_timeout_tv() -- for connect evhttp_connection_set_read_timeout_tv() -- for read evhttp_connection_set_write_timeout_tv() -- for write - server: evhttp_set_read_timeout_tv() -- for read evhttp_set_write_timeout_tv() -- for write It also changes a logic a little, before there was next fallbacks which does not handled in new API: - HTTP_CONNECT_TIMEOUT - HTTP_WRITE_TIMEOUT - HTTP_READ_TIMEOUT And introduce another internal flag (EVHTTP_CON_TIMEOUT_ADJUSTED) that will be used in evrpc, which adjust evhttp_connection timeout only if it is not default. Fixes: #692 Fixes: #715
* | Add support for EV_TIMEOUT to event_base_active_by_fdJohn Ohl2019-03-031-1/+1
| | | | | | | | Closes: #194 (cherry-pick)
* | Define `_GNU_SOURCE` properly/consistently per autoconfEnji Cooper2019-02-271-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although `_GNU_SOURCE` can be defined as an arbitrary #define per the glibc docs [1], it's best to define it in a manner consistent with the way that autoconf defines it, i.e., `1`. While this shouldn't matter in most cases, it does when the headers from other projects follow the poorly defined GNU convention implemented by autoconf and are included after the libevent's util.h header. An example failure with clang, similar to the failure I encountered, is as follows: ``` $ printf "#define _GNU_SOURCE\n#define _GNU_SOURCE 1" | clang -c -x c - <stdin>:2:9: warning: '_GNU_SOURCE' macro redefined [-Wmacro-redefined] ^ <stdin>:1:9: note: previous definition is here ^ 1 warning generated. ``` This happened when compiling python [2] with a stale homebrew util.h file from libevent (which admittedly would not happen in a correct libevent install, as the header should be installed under /usr/local/include/event2/util.h). However, if both headers had been combined (which is more likely), it would have failed as shown above. Removing the ad hoc definition unbreaks compiling python's pyconfig.h.in header when included after util.h from libevent. 1. http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html 2. https://github.com/python/cpython/blob/master/configure.ac#L126 Closes: #773 (cherry-picked) Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
* | Eliminate fd conversion warnings and introduce EVUTIL_INVALID_SOCKET (windows)Azat Khuzhin2019-01-291-2/+5
| | | | | | | | | | | | | | windows has intptr_t instead of regular int. Also tt_fd_op() had been introduced, since we cannot use tt_int_op() for comparing fd, since it is not always int.
* | rpc: use *_new_with_arg() to match function prototypeAzat Khuzhin2019-01-111-2/+2
| | | | | | | | | | | | In 755fbf16c ("Add void* arguments to request_new and reply_new evrpc hooks") this new functions had been introduced, but newer used, what for? So let's use them.
* | Introduce EVENT_VISIBILITY_WANT_DLLIMPORTAzat Khuzhin2018-10-281-1/+2
| | | | | | | | | | | | | | | | | | And use it in places where event_debug() should be called (since it requires access to "event_debug_logging_mask_" and in win32 it is tricky). One of this places that is covered by this patch is the test for event_debug().
* | Check existence of IPV6_V6ONLY in evutil_make_listen_socket_ipv6only() (mingw32)Azat Khuzhin2018-10-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | MinGW 32-bit 5.3.0 does not defines it and our appveyour [1] build reports this instantly: evutil.c: In function 'evutil_make_listen_socket_ipv6only': evutil.c:392:40: error: 'IPV6_V6ONLY' undeclared (first use in this function) return setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void*) &one, [1]: https://www.appveyor.com/docs/windows-images-software/#mingw-msys-cygwin Another solution will be to use mingw64 which has it, but I guess we do want that #ifdef anyway.
* | Add evhttp_parse_query_str_flags()Azat Khuzhin2018-10-271-1/+29
| | | | | | | | | | | | | | | | And a set of flags: - EVHTTP_URI_QUERY_LAST - EVHTTP_URI_QUERY_NONCONFORMANT Fixes: #15
* | listener: ipv6only socket bind supportMurat Demirten2018-10-262-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | According to RFC3493 and most Linux distributions, default value is to work in IPv4-mapped mode. If there is a requirement to bind same port on same ip addresses but different handlers for both IPv4 and IPv6, it is required to set IPV6_V6ONLY socket option to be sure that the code works as expected without affected by bindv6only sysctl setting in system. See an example working with this patch: https://gist.github.com/demirten/023008a63cd966e48b0ebcf9af7fc113 Closes: #640 (cherry-pick)
* | Fix hangs due to watermarks overruns in bufferevents implementationsAzat Khuzhin2018-10-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some implementations of bufferevents (for example openssl) can overrun read high watermark. And after this if user callback will not drain enough data it will be suspended (i.e. it will not be runned again anymore). This is not the expecting behaviour as one may guess, since in this case the data will never be read. Hence once we detected that the watermark exceeded (even after calling user callback) we will schedule the callback again. This also can be fixed in bufferevent openssl implementation (by strictly limiting how much data is added to the read buffer according to read high watermark), but since this data is already available (and in memory) there is no point in doing so.
* | Fix typoXiaozhou Liu2018-07-301-1/+1
| | | | | | | | Closes: #658
* | Add convenience macros for user-triggered eventsPhilip Prindeville2018-06-181-2/+18
| | | | | | | | | | Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com> Closes: #647 (picked)
* | Make rpc headers self-compilableAzat Khuzhin2018-05-072-0/+16
| | | | | | | | Fixes: #633
* | [core] re-order fields in struct event for memory efficiencyNathan French2018-04-301-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The sizeof `struct event` can reduced on both 32 bit and 64 bit systems by moving the 4 bytes that make up `ev_events` and `ev_res` below `ev_fd`, before `struct event_base * ev_base;` since our compiler wouldn't dare do such a thing (it instead will pad twice, whereas it only needs to be padded once) ```C struct event { /* OFFS | SZ Bytes | Total Bytes | START - END */ struct event_callback ev_evcallback; /* 0x0 | 40 | 40 | 0x0 - 0x28 */ union { /* 0x28 | ----------- | ----------- | ------------ */ TAILQ_ENTRY(event) ev_next_with_common_timeout; /* | ((16)) | | */ int min_heap_idx; /* | ((04)) | | */ } ev_timeout_pos; /* | 16 | 56 | 0x28 - 0x38 */ int ev_fd; /* 0x38 | 04 | 60 | 0x38 - 0x3c */ ``` Since the next field is 8 bytes in length, and we are up to 60 bytes, `ev_fd` ends up being padded (4 more bytes on 64b). ```C /* --- 1 byte gap HERE ---> 1 | <61> */ /* --- 1 byte gap HERE ---> 1 | <62> */ /* --- 1 byte gap HERE ---> 1 | <63> */ /* --- 1 byte gap HERE ---> 1 | <64> */ struct event_base * ev_base; /* 0x3c | 8 | 68 | 0x3c - 0x40 */ union { /* 0x40 | ------------ | ---------- | ------------ */ struct { /* | ------------ | | */ LIST_ENTRY (event) ev_io_next; /* | ((16+ | | */ struct timeval ev_timeout; /* | 16)) | | */ } ev_io; /* | ((32)) | | */ struct { /* | ------------ | | */ LIST_ENTRY (event) ev_signal_next; /* | ((16+ | | */ short ev_ncalls; /* | 02+ | | */ short * ev_pncalls; /* | 08)) | | */ } ev_signal; /* | ((26)) | | */ } ev_; /* 0x60 | 32 | 100 | 0x40 - 0x60 */ short ev_events; /* 0x60 | 2 | 102 | 0x60 - 0x62 */ short ev_res; /* 0x62 | 2 | 104 | 0x62 - 0x64 */ ``` We now hit another line, `struct timeval` is 16 bytes on 64b arch, so we have 4 more bytes of padding on `ev_res`. ```C /* --- 1 byte gap HERE --- */ /* --- 1 byte gap HERE --- */ /* --- 1 byte gap HERE --- */ /* --- 1 byte gap HERE --- */ struct timeval ev_timeout; /* 0x64 | 16 | 120 | 0x64 - 0x74 */ }; ``` After moving `ev_events` and `ev_res` below `ev_fd` we have something a bit more optimal: ```C struct event2 { /* OFFS | SZ / Bytes | RSUM Bytes | START - END */ struct event_callback ev_evcallback; /* 0x0 | 40 | 40 | 0x0 - 0x28 */ union { /* 0x28 | ------------ | ---------- | ------------ */ TAILQ_ENTRY(event) ev_next_with_common_timeout; /* | ((16)) | | */ int min_heap_idx; /* | ((04)) | | */ } ev_timeout_pos; /* | 16 | 56 | 0x28 - 0x38 */ int ev_fd; /* 0x38 | 4 | 60 | 0x38 - 0x3c */ short ev_events; /* 0x3c | 2 | 62 | 0x3c - 0x3e */ short ev_res; /* 0x3e | 2 | 64 | 0x3e - 0x40 */ struct event_base * ev_base; /* 0x40 | 8 | 74 | 0x40 - 0x48 */ union { /* 0x48 | ------------ | ---------- | ------------ */ struct { /* | ------------ | | */ LIST_ENTRY (event) ev_io_next; /* | ((16+ | | */ struct timeval ev_timeout; /* | 16)) | | */ } ev_io; /* | ((32)) | | */ struct { /* | ------------ | | */ LIST_ENTRY (event) ev_signal_next; /* | ((16+ | | */ short ev_ncalls; /* | 02+ | | */ short * ev_pncalls; /* | 08)) | | */ } ev_signal; /* | ((26)) | | */ } ev_; /* | 32 | 106 | 0x48 - 0x68 */ struct timeval ev_timeout; /* 0x68 | 16 | 120 | 0x68 - 0x78 */ }; ``` We still have a gap here, but the first was removed. Again, we can save 8 bytes on both 32 and 64 word sizes (32/64 byte cacheline). Below are the results for testing v2.1.6 -> master -> master + this patch (Release/-O3) Code: ```C #include <event2/event.h> int main(int argc, char ** argv) { printf("%zu\n", event_get_struct_event_size()); return 0; } ``` Branch: `master` (2.2.x) ``` $ gcc -O3 -Wall -Wl,-R/usr/local/lib bleh.c -L/usr/local/lib -o bleh -levent $ ldd bleh linux-vdso.so.1 => (0x00007ffc3df50000) libevent.so.2.2.0 => /usr/local/lib/libevent.so.2.2.0 (0x00007f91fd781000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f91fd3a1000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f91fd182000) /lib64/ld-linux-x86-64.so.2 (0x00007f91fdbcc000) $ ./bleh 128 ``` Release: `2.1.6` ``` $ gcc -O3 bleh.c -o bleh -levent $ ldd bleh linux-vdso.so.1 => (0x00007ffd43773000) libevent-2.1.so.6 => /usr/lib/x86_64-linux-gnu/libevent-2.1.so.6 (0x00007feb3add6000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007feb3a9f6000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007feb3a7d7000) /lib64/ld-linux-x86-64.so.2 (0x00007feb3b22a000) $ ./bleh 128 ``` Branch: `this one` ``` $ gcc -O3 -Wl,-R./lib bleh.c -o bleh -L./lib -levent $ ldd bleh linux-vdso.so.1 => (0x00007ffff55f7000) libevent.so.2.2.0 => ./lib/libevent.so.2.2.0 (0x00007ff8e5c82000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff8e58a2000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff8e5683000) /lib64/ld-linux-x86-64.so.2 (0x00007ff8e60cd000) $ ./bleh 120 ```
* | Generating evdns_base_config_windows_nameservers docs on all platformsdpayne2018-04-031-1/+1
| |
* | Fixing doxygen docs for evdns_base_search_clear when generated on ↵dpayne2018-04-031-1/+1
|/ | | | non-windows machines
* Fix typos in commentsDmitry Alimov2018-01-151-10/+10
|
* http: add callback to allow server to decline (and thereby close) incoming ↵John Fremlin2017-12-181-0/+18
| | | | | | | | | | | connections. This is important, as otherwise clients can easily exhaust the file descriptors available on a libevent HTTP server, which can cause problems in other code which does not handle EMFILE well: for example, see https://github.com/bitcoin/bitcoin/issues/11368 Closes: #578 (patch cherry picked)
* Fix incorrect ref to evhttp_get_decoded_uri in http.hejurgensen2017-11-051-2/+2
| | | | | Replaces reference in the http.h include header file to evhttp_get_decoded_uri with evhttp_uridecode. There is no function called evhttp_get_decoded_uri.
* always define EV_INT16_MINCarlo Marcelo Arenas Belón2017-08-171-0/+1
| | | | somehow missing from 043ae7481f4a73b0f48055a0260afa454f02d136
* Merge remote-tracking branch 'official/pr/527' -- documentation fixesAzat Khuzhin2017-07-161-4/+4
|\ | | | | | | | | | | * official/pr/527: Fix a few trivial documentation typos Clarify event_free() documentation regarding pending/active events
| * Fix a few trivial documentation typosNikolay Edigaryev2017-07-071-2/+2
| |
| * Clarify event_free() documentation regarding pending/active eventsNikolay Edigaryev2017-07-071-2/+2
| | | | | | | | | | | | | | Currently it's not clear as to whether "first make it non-pending and non-active" sentence requires user to take some action (e.g. call event_del(), which event_free() already does internally) or just describes what this function does from the developer point of view.
* | Document some obvious cases where a function might also return NULLNikolay Edigaryev2017-07-025-9/+16
| | | | | | | | Closes: #525
* | Fix event_debug_logging_mask_ exporting on win32Azat Khuzhin2017-05-291-0/+12
| |
* | Fix visibility issues under (mostly on win32)Azat Khuzhin2017-05-291-12/+2
|/ | | | | | Refs: #511 Fixes: 7182c2f561570cd9ceb704623ebe9ae3608c7b43 ("cmake: build SHARED and STATIC libraries (like autoconf does)")
* Fix arc4random_addrandom() detecting and fallback (regression)Azat Khuzhin2017-03-271-1/+1
| | | | | | | | But this is kind of hot-fix, we definitelly need more sane arc4random compat layer. Fixes: #488 Introduced-in: 6541168 ("Detect arch4random_addrandom() existence")
* log/win32: fix exporting extern variableAzat Khuzhin2017-03-141-1/+11
| | | | ==> win: C:\vagrant\log.c(73): error C2370: 'event_debug_logging_mask_' : redefinition; different storage class [C:\vagrant\.cmake-vagrant\event_core_shared.vcxproj]
* cmake: eliminate EVENT_BUILDING_REGRESS_TEST, since we link with shared libsAzat Khuzhin2017-03-141-1/+1
| | | | | Before 7182c2f561570cd9ceb704623ebe9ae3608c7b43 ("cmake: build SHARED and STATIC libraries (like autoconf does)") it links with *.c.
* cmake: build SHARED and STATIC libraries (like autoconf does)Azat Khuzhin2017-03-131-6/+6
| | | | | | | | | | | | Since they are useful for debugging, and if autotools build them then cmamke has to do this too, to make migration more simple. And now: - tests: uses shared libraries (since this is upstreams one) - other binaries: uses static libraries This removes next private config: - EVENT__NEED_DLLIMPORT
* cmake: add missing event_openssl/event_pthreads librariesAzat Khuzhin2017-03-131-1/+5
| | | | | | | | | | | | This will remove openssl requirement if you don't use it (i.e. if you not link with openssl_pthreads). Plus it fixes some linking dependencies: - libm required only for test-ratelim And fix some coding style alignment issues. Refs: #246
* Export symbols for -fvisibility=hidden (under cmake)Azat Khuzhin2017-03-134-5/+60
| | | | Fixes: #442
* Detect arch4random_addrandom() existenceMarek Sebera2017-03-081-0/+2
| | | | | Refs: #370 Refs: #475