bufferevent_openssl.c

Branch


Log

Author Commit Date CI Message
Andy Pan fef2a867 2024-05-21T11:05:23 Fix -Wcast-function-type errors --------- Signed-off-by: Andy Pan <i@andypan.me>
Cœur af31823f 2024-05-05T16:43:23 Fix potential Null pointer dereference in bufferevent_openssl.c
Michael Davidsaver 21d2f5a4 2023-08-18T07:51:02 Fixes #include of winsock.h before winsock2.h
Azat Khuzhin e5941b2c 2023-05-16T21:16:33 Drop unused le_ssl_ops::err_is_ok It is not used anymore since errors are ignored if some progress had been done.
Azat Khuzhin 7652cf40 2023-05-14T16:53:13 ssl: do not triger EOF if some data had been successfully read Previously in case when evbuffer_reserve_space() returns > 1, but it was able to read only 1 IO vector, it will try to read the next one, got 0 (EOF for mbedTLS or SSL_ERROR_ZERO_RETURN for OpenSSL) and will trigger EOF, while instead, it should trigger EV_READ w/o EOF and only after EOF.
Azat Khuzhin 6375dcb4 2023-05-14T16:45:14 ssl: rename err_is_ok to handshake_is_ok (internal API)
Azat Khuzhin e67085e5 2022-07-10T09:26:16 Suppress -Wunused-value for BIO_set_close()
William Marlow 29c420c4 2022-06-18T21:43:31 Initial OpenSSL 3.0 support * Don't use deprecated functions when building against OpenSSL 3.0. * Recognise that OpenSSL 3.0 can signal a dirty shutdown as a protocol. error in addition to the expected IO error produced by OpenSSL 1.1.1 * Update regress_mbedtls.c for compatibility with OpenSSL 3
Azat Khuzhin 7e0fc878 2020-10-31T21:45:22 Introduce new API for flags of the SSL bufferevent Introduce more generic API (like for evbuffer): - bufferevent_ssl_set_flags() - bufferevent_ssl_clear_flags() - bufferevent_ssl_get_flags() And deprecate existing: - bufferevent_openssl_get_allow_dirty_shutdown() - bufferevent_openssl_set_allow_dirty_shutdown() - bufferevent_mbedtls_get_allow_dirty_shutdown() - bufferevent_mbedtls_set_allow_dirty_shutdown()
okhowang(王沛文) f07898e3 2020-07-25T17:17:46 bufferevent_openssl: fix -Wcast-function-type for SSL_pending Introduced-in: #1028
Azat Khuzhin 948ad304 2020-07-23T23:38:53 Fix bufferevent_get_{openssl,mbedtls}_error() The bufferevent_get_openssl_error() returns unsigned long, so returning -1 on error in unclear. Let's use 0. Fixes: #1028
Azat Khuzhin 5671575a 2020-07-22T23:08:50 Join le_ssl_ops.post_init with le_ssl_ops.init
okhowang(王沛文) d095b834 2020-07-07T17:26:46 Merge ssl implementations (openssl and mbedtls) This patch splits common part out to avoid copy-paste from the - bufferevent_openssl.c - bufferevent_mbedtls.c It uses VFS/bufferevent-like approach, i.e. structure of callbacks.
Yury Korzhetsky a30d6d85 2019-02-26T12:33:49 Don't loose top error in SSL Closes: #775 (cherry-picked)
Azat Khuzhin b29207dc 2019-01-29T21:12:33 Eliminate fd conversion warnings and introduce EVUTIL_INVALID_SOCKET (windows) 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.
Azat Khuzhin acf09c00 2018-10-27T18:35:08 be_openssl: avoid leaking of SSL structure From nmathewson/Libevent#83 by @fancycode: There are a few code paths where the passed SSL object is not released in error cases, even if BEV_OPT_CLOSE_ON_FREE is passed as option while for others it is released. That way it's impossible for the caller to know it he has to free it on errors himself or not. Line numbers are from "bufferevent_openssl.c" in 911abf3: L1414 ("underlying == NULL" passed) L1416 (bio could not be created) L1446 (different fd passed) L1325 (both underlying and fd passed) L1328 (out-of-memory) L1333 ("bufferevent_init_common_" failed) In all error cases after the "bufferevent_ops_openssl" has been assigned, the option is evaluated on "bufferevent_free" (L1399) and the SSL object released (L1226). Fixes: nmathewson/Libevent#83
Azat Khuzhin 474d72ae 2018-10-27T18:29:57 be_openssl: drop close_flag parameter of the BIO_new_bufferevent()
an-tao 0789bc52 2018-05-25T18:07:28 fix spelling mistakes Closes: nmathewson/Libevent#162
Azat Khuzhin c2c08e02 2017-11-22T10:33:15 Add missing includes into openssl-compat.h Before it depends from the caller #include appropriate headers (at least for OPENSSL_VERSION_NUMBER), but let's make it independent. Fixes: #574
David Benjamin c6c74ce2 2017-04-20T18:03:50 Explicitly call SSL_clear when reseting the fd. If reconnecting the via BEV_CTRL_SET_FD, bufferevent_openssl.c expects OpenSSL to reuse the configuration state in the SSL object but retain connection state. This corresponds to the SSL_clear API. The code currently only calls SSL_set_connect_state or SSL_set_accept_state. Due to a quirk in OpenSSL, doing this causes the handshake to implicitly SSL_clear the next time it is entered. However, this, in the intervening time, leaves the SSL object in an odd state as the connection state has not been dropped yet. This behavior also does not appear to be documented by OpenSSL. Instead, call SSL_clear explicitly: https://www.openssl.org/docs/manmaster/man3/SSL_clear.html
Dominic Chen 92cc0b9c 2017-04-13T14:58:13 bufferevent: refactor to use type check macros
Azat Khuzhin 89396767 2016-12-07T02:53:07 be_openssl: Fix writing into filted openssl bufferevent after connected The main problems was due to when bufferevent_openssl has underlying (i.e. created with bufferevent_openssl_filter_new()) some events was disabled/suspended, while with openssl, READ can require WRITE and vice-versa hence this issues. The BEV_CTRL_GET_FD hunk to fix http subsystem, since it depends from what bufferevent_getfd() returns. Fixes: #428 Fixes: ssl/bufferevent_filter_write_after_connect Fixes: http/https_filter_chunk_out Fixes: da52933550fd4736aa1c213b6de497e2ffc31e34 ("be_openssl: don't call do_write() directly from outbuf_cb")
Azat Khuzhin 32adf434 2016-12-07T01:48:54 be_openssl: make be_openssl_set_fd() static (no prototype required)
Azat Khuzhin d94b1762 2016-11-19T18:00:36 Fix dirty_shutdown for openssl 1.1 SSL_read() returns -1, even when underlying read() return 0
Azat Khuzhin 5ab9518f 2016-11-19T17:08:53 Fix reusing bufferevent_openssl after fd was reseted (i.e. on new connection) For example if you trying to issue multiple requests over the same evhttp_conneciton, and if connection already closed (IOW it should be re-connected), than you will get into trouble since it will got wrong openssl state. This patch addresses this issue by restoring state to initial if SETFD called with -1 fd.
Philip Prindeville 6bf2061c 2016-11-11T17:51:37 C90 doesn't like declarations intermingled with statements So move all of the declarations to the top of the offending function. This patch includes both of issues (Fixes:), from @jeking3 and @pprindeville Fixes: #418 Fixes: nmathewson/Libevent#136
Kurt Roeckx 3e9e0a0d 2016-09-19T22:05:15 Make it build using OpenSSL 1.1.0 Rebased (azat): - tabs instead of whitespaces - make openssl-compat.h safe for complex expressions - do not call sk_SSL_COMP_free() in 1.1 (fixes double free) TODO: - clean methods_bufferevent Closes: #397 (cherry-picked)
Adam Langley 6702da1a 2016-10-12T17:49:17 Don't call BIO_number_{read|written} on NULL BIOs. OpenSSL doesn't document the behaviour of these functions when given a NULL BIO, and it happens to return zero at the moment. But don't depend on that. Closes: #406 (cherry-picked)
Azat Khuzhin 38e0f4a5 2016-05-02T15:21:50 be_openssl: clear all pending errors before SSL_*() calls Refs: #350 Reported-by: @CapSel
Azat Khuzhin da529335 2015-11-13T16:00:39 be_openssl: don't call do_write() directly from outbuf_cb Otherwise we can trigger incorrect callback, the simplest way to trigger this is using http regression tests -- https_chunk_out, since all it do is: evhttp_send_reply_end() evbuffer_add() do_write() evhttp_write_buffer() evcon->cb = cb And indeed this is what happens: (gdb) bt #0 do_write (bev_ssl=0x738a90, atmost=16384) at bufferevent_openssl.c:717 #1 0x00000000004b69f7 in consider_writing (bev_ssl=0x738a90) at bufferevent_openssl.c:875 #2 0x00000000004b7386 in be_openssl_outbuf_cb (buf=0x7387b0, cbinfo=0x7fffffffd590, arg=0x738a90) at bufferevent_openssl.c:1147 #3 0x0000000000490100 in evbuffer_run_callbacks (buffer=0x7387b0, running_deferred=0) at buffer.c:508 #4 0x00000000004901e5 in evbuffer_invoke_callbacks_ (buffer=0x7387b0) at buffer.c:529 #5 0x0000000000493a30 in evbuffer_add (buf=0x7387b0, data_in=0x4ecfb2, datlen=5) at buffer.c:1803 #6 0x00000000004be2e3 in evhttp_send_reply_end (req=0x7371a0) at http.c:2794 #7 0x000000000045c407 in http_chunked_trickle_cb (fd=-1, events=1, arg=0x75aaf0) at regress_http.c:402 ... (gdb) p bev.writecb $4 = (bufferevent_data_cb) 0x4ba17e <evhttp_write_cb> $5 = (void *) 0x7379b0 (gdb) p (struct evhttp_connection *)bev.cbarg $6 = (struct evhttp_connection *) 0x7379b0 (gdb) p $6->cb $7 = (void (*)(struct evhttp_connection *, void *)) 0x0 And be_sock don't do like this anyway. Fixes: https_chunk_out
Azat Khuzhin 0c66d321 2015-11-05T17:56:07 be_openssl: use bufferevent_enable() instead of bufferevent_add_event_() By using bufferevent_enable() there will be no event for READ *or* WRITE if they are not enabled before, and this patch reduces difference for be_sock_enable/be_openssl_enable (handshake)
Azat Khuzhin 3c1f58f5 2015-11-05T17:45:09 be: introduce bufferevent_generic_adj_existing_timeouts_() And use it in openssl/sock layers to avoid copy-pasting it's variants.
Azat Khuzhin f4b6284b 2015-11-05T17:40:25 be_openssl: don't add events during bev creation (like be_sock) Using the following examples you can get changes between be_openssl and be_sock: $ function diff_addr() { eval diff -u $(printf "<(strip_addr %s) " "$@") } $ function strip_addr() { sed 's/0x[a-zA-Z0-9]*/0xFFFF/g' "$@" } $ EVENT_DEBUG_LOGGING_ALL= regress --verbose --no-fork +http/https_connection_retry 2> /tmp/https-retry.log >&2 $ EVENT_DEBUG_LOGGING_ALL= regress --verbose --no-fork +http/connection_retry 2> /tmp/http-retry.log >&2 $ diff_addr /tmp/http-retry.log /tmp/https-retry.log
Azat Khuzhin 877280db 2015-09-02T15:09:24 be_openssl: don't use *_auto() in do_handshake() we can't have fd == -1 there
Azat Khuzhin e8a2da96 2015-09-02T14:19:16 be_openssl: don't call set_open_callbacks() if fd == -1 This must be illegal, firstly we must do set_do handshake and only after this we could read/write.
Azat Khuzhin 2a8a7112 2015-09-02T12:42:29 be_openssl: introduce be_openssl_auto_fd() helper
Azat Khuzhin 510da71f 2015-09-02T12:40:26 be_openssl: introduce set_open_callbacks_auto() This will split cases when we need to extract fd (cases when we have fd==-1 passed to set_open_callbacks()), and cases when we mustn't have to do this -- SET_FD via be_openssl_ctrl().
Azat Khuzhin 40b03798 2015-08-22T21:38:18 be_openssl: get rid off hackish "fd_is_set", to fix some corner cases This patch is a cleanup and a bug fix, it drops ```fd_is_set``` flag, and replace it with some checks to event_initialized(), and now we will not call event_assign() on already added event, plus we will delete event when we really have to (this patch fixes the case when server is down, IOW before this patch we will not call event_del() because ```fd_is_set``` was reset to 0) and this will fix some issues with retries in http layer for ssl. Reported-in: #258 Fixes: regress ssl/bufferevent_socketpair_timeout Fixes: regress ssl/bufferevent_socketpair_timeout_freed_fd
Azat Khuzhin 3da84c29 2014-09-21T18:29:17 bufferevent_openssl: reset fd_is_set when setfd with -1 is called Otherwise we will use old fd after close(2) called on it: (Traces trimmed, to minimize it) $ strace -keclose,open,socket,epoll_ctl https-client -url https://libevent.org socket(PF_INET, SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_IP) = 5 > /lib/x86_64-linux-gnu/libc-2.19.so(socket+0x7) [0xe6da7] > /usr/lib/libevent-2.1.so.4.0.0(evutil_socket_+0x25) [0x27835] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect+0xe9) [0x1b1a9] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect+0x21f) [0x1b2df] > /usr/lib/libevent-2.1.so.4.0.0(evutil_getaddrinfo_async_+0x65) [0x271a5] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect_hostname+0x106) [0x1b416] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_connect_+0xe7) [0x39f07] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_make_request+0xb8) [0x3a218] epoll_ctl(3, EPOLL_CTL_ADD, 5, {EPOLLIN, {u32=5, u64=5}}) = 0 > ... > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xfdd) [0x2ced] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_setfd+0x3b) [0x16d9b] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect+0x75) [0x1b135] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect+0x21f) [0x1b2df] > /usr/lib/libevent-2.1.so.4.0.0(evutil_getaddrinfo_async_+0x65) [0x271a5] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect_hostname+0x106) [0x1b416] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_connect_+0xe7) [0x39f07] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_make_request+0xb8) [0x3a218] epoll_ctl(3, EPOLL_CTL_MOD, 5, {EPOLLIN|EPOLLOUT, {u32=5, u64=5}}) = 0 > ... > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xfee) [0x2cfe] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_setfd+0x3b) [0x16d9b] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect+0x75) [0x1b135] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect+0x21f) [0x1b2df] > /usr/lib/libevent-2.1.so.4.0.0(evutil_getaddrinfo_async_+0x65) [0x271a5] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect_hostname+0x106) [0x1b416] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_connect_+0xe7) [0x39f07] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_make_request+0xb8) [0x3a218] epoll_ctl(3, EPOLL_CTL_MOD, 5, {EPOLLOUT, {u32=5, u64=5}}) = 0 > ... > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xbbc) [0x28cc] > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xd96) [0x2aa6] > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xeb8) [0x2bc8] > /usr/lib/libevent-2.1.so.4.0.0(event_free+0x3fe) [0x1fd1e] > /usr/lib/libevent-2.1.so.4.0.0(event_base_loop+0x407) [0x20677] epoll_ctl(3, EPOLL_CTL_DEL, 5, 7fffa1f841e0) = 0 > ... > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xbc4) [0x28d4] > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xd96) [0x2aa6] > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xeb8) [0x2bc8] > /usr/lib/libevent-2.1.so.4.0.0(event_free+0x3fe) [0x1fd1e] > /usr/lib/libevent-2.1.so.4.0.0(event_base_loop+0x407) [0x20677] close(5) = 0 > /lib/x86_64-linux-gnu/libpthread-2.19.so(__close_nocancel+0x7) [0xeb20] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_reset_+0x55) [0x373f5] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_connect_+0x1d) [0x39e3d] > /usr/lib/libevent-2.1.so.4.0.0(event_free+0x3fe) [0x1fd1e] > /usr/lib/libevent-2.1.so.4.0.0(event_base_loop+0x407) [0x20677] epoll_ctl(3, EPOLL_CTL_ADD, 5, {EPOLLIN, {u32=5, u64=5}}) = -1 EBADF (Bad file descriptor) ) = -1 EBADF (Bad file descriptor) /src/oss/strace-code/strace: Can't initiate libunwind: No such process > ... > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xfdd) [0x2ced] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_setfd+0x3b) [0x16d9b] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_connect_+0x14c) [0x39f6c] > /usr/lib/libevent-2.1.so.4.0.0(event_free+0x3fe) [0x1fd1e] > /usr/lib/libevent-2.1.so.4.0.0(event_base_loop+0x407) [0x20677] /src/oss/strace-code/strace: Exit of unknown pid 28185 seen [warn] Epoll ADD(1) on fd 5 failed. Old events were 0; read change was 1 (add); write change was 0 (none); close change was 0 (none): Bad file descriptor epoll_ctl(3, EPOLL_CTL_ADD, 5, {EPOLLOUT, {u32=5, u64=5}}) = -1 EBADF (Bad file descriptor) ) = -1 EBADF (Bad file descriptor) /src/oss/strace-code/strace: Can't initiate libunwind: No such process > ... > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xfee) [0x2cfe] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_setfd+0x3b) [0x16d9b] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_connect_+0x14c) [0x39f6c] > /usr/lib/libevent-2.1.so.4.0.0(event_free+0x3fe) [0x1fd1e] > /usr/lib/libevent-2.1.so.4.0.0(event_base_loop+0x407) [0x20677] /src/oss/strace-code/strace: Exit of unknown pid 28186 seen [warn] Epoll ADD(4) on fd 5 failed. Old events were 0; read change was 0 (none); write change was 1 (add); close change was 0 (none): Bad file descriptor <getaddrinfo traces trimmed> close(5) = -1 EBADF (Bad file descriptor) ) = -1 EBADF (Bad file descriptor) /src/oss/strace-code/strace: Can't initiate libunwind: No such process > /lib/x86_64-linux-gnu/libpthread-2.19.so(__close_nocancel+0x7) [0xeb20] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_reset_+0x55) [0x373f5] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_fail_+0xc1) [0x3aed1] > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_fail_+0x4a3) [0x3b2b3] > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_enable+0x192) [0x16722] > /usr/lib/libevent-2.1.so.4.0.0(event_free+0x5df) [0x1feff] > /usr/lib/libevent-2.1.so.4.0.0(event_base_loop+0x407) [0x20677] /src/oss/strace-code/strace: Exit of unknown pid 28187 seen some request failed - no idea which one though! socket error = Bad file descriptor (9) Before this patch: $ sample/https-client -retries 1 -url https://libevent.org [warn] Epoll ADD(1) on fd 6 failed. Old events were 0; read change was 1 (add); write change was 0 (none); close change was 0 (none): Bad file descriptor [warn] Epoll ADD(4) on fd 6 failed. Old events were 0; read change was 0 (none); write change was 1 (add); close change was 0 (none): Bad file descriptor some request failed - no idea which one though! socket error = Bad file descriptor (9) After this patch: $ sample/https-client -retries 1 -url https://libevent.org Response line: 0 (null) Reported-by: gerkenjohannes@web.de
Joakim Soderberg e212c548 2014-01-22T13:19:49 Check for OSX when checking for clang.
Nick Mathewson 4cb44fdf 2014-01-21T14:26:01 Merge remote-tracking branch 'joakimsoderberg/new_cmake' Conflicts: sample/https-client.c
Joakim Soderberg 0ef1d04e 2013-12-17T14:32:07 Get rid of unknown pragma warnings.
Joakim Söderberg 69c3516b 2013-12-17T13:28:23 Get rid of deprecation warnings for OpenSSL on OSX 10.7+
Ondřej Kuzník a7384c78 2013-12-03T23:01:54 Add an option to trigger bufferevent event callbacks
Ondřej Kuzník 61ee18b8 2013-12-03T22:49:57 Add an option to trigger bufferevent I/O callbacks
Nick Mathewson a800b913 2013-04-26T11:36:43 More documentation for finalization feature
Nick Mathewson 02fbf687 2013-04-09T18:16:13 Use finalization feature so bufferevents can avoid deadlocks Since the bufferevents' events are now EV_FINALIZE (name pending), they won't deadlock. To clean up properly, though, we must use the finalization feature. This patch also split bufferevent deallocation into an "unlink" step that happens fast, and a "destruct" step that happens after finalization. More work is needed: there needs to be a way to specify a finalizer for the bufferevent's argument itself. Also, this finalizer business makes lots of the reference counting we were doing unnecessary. Also, more testing is needed.
Nick Mathewson 9dee36bc 2012-11-16T18:34:43 Make bufferevent_set_timeouts(bev, NULL, NULL) have plausible semantics
Nick Mathewson 09a8d23a 2012-11-16T10:44:57 Merge remote-tracking branch 'origin/patches-2.0'
Patrick Pelletier ac356502 2012-11-07T19:48:22 remove stray 'x' so print_err will compile when uncommented
Nick Mathewson cda69d0d 2012-10-24T22:55:17 Merge remote-tracking branch 'origin/patches-2.0' Conflicts: bufferevent_openssl.c
Nick Mathewson 1ff2c249 2012-10-24T22:48:59 Merge remote-tracking branch 'public/20_bev_timeout_semantics' into patches-2.0
Nick Mathewson f2050e79 2012-09-22T19:21:21 Merge remote-tracking branch 'origin/patches-2.0' Conflicts: bufferevent_openssl.c
Joachim Bauch 1acf2ebc 2012-09-06T10:01:10 No need to reserve space if reading is suspended. Conflicts: bufferevent_openssl.c
Joachim Bauch f719b8a9 2012-09-03T21:42:15 Stop looping in "consider_reading" if reading is suspended.
Nick Mathewson 576b29f2 2012-09-07T15:53:02 Don't discard SSL read event when timeout and read come close together
Nick Mathewson e3d010c8 2012-08-23T10:13:26 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 606ac43b 2012-08-22T12:30:42 Correctly invoke callbacks when a SSL bufferevent reads some and then blocks. Based on a patch by Andrew Hochhaus, who correctly diagnosed this bug.
Nick Mathewson b98624ef 2012-04-30T21:33:56 Merge remote-tracking branch 'origin/patches-2.0' Conflicts: bufferevent_openssl.c
Mark Ellzey 4e62cd16 2012-03-30T15:08:40 Fixed potential double-readcb execution with openssl bufferevents. the function do_read() will call SSL_read(), and if successful, will call _bufferevent_run_readcb() before returning to consider_reading(). consider_reading() will then check SSL_pending() to make sure all pending data has also been read. If it does not, do_read() is called again. The issue with this is the possibility that the function that is executed by _bufferevent_run_readcb() called bufferevent_disable(ssl_bev, EV_READ) before the second do_read(); In this case, the users read callback is executed a second time. This is potentially bad for applications that expect the bufferevent to stay disabled until further notice. (this is why running openssl bufferevents without DEFER_CALLBACKS has always been troublesome).
Nick Mathewson 8ac3c4c2 2012-02-29T15:07:33 Have all visible internal function names end with an underscore. We haven't had a convention for naming internal functions in -internal.h versus naming visible functions in include/**.h. This patch changes every function declared in a -internal.h file to be named ending with an underscore. Static function names are unaffected, since there's no risk of calling them from outside Libevent. This is an automatic conversion. The script that produced was made by running the following script over the output of ctags --c-kinds=pf -o - *-internal.h | cut -f 1 | sort| uniq (GNU ctags was required.) ===== #!/usr/bin/perl -w -n use strict; BEGIN { print "#!/usr/bin/perl -w -i -p\n\n"; } chomp; my $ident = $_; next if ($ident =~ /_$/); next if ($ident =~ /^TAILQ/); my $better = "${ident}_"; print "s/(?<![A-Za-z0-9_])$ident(?![A-Za-z0-9_])/$better/g;\n"; === And then running the script below that it generated over all === the .c and .h files again #!/usr/bin/perl -w -i -p s/(?<![A-Za-z0-9_])bufferevent_async_can_connect(?![A-Za-z0-9_])/bufferevent_async_can_connect_/g; s/(?<![A-Za-z0-9_])bufferevent_async_connect(?![A-Za-z0-9_])/bufferevent_async_connect_/g; s/(?<![A-Za-z0-9_])bufferevent_async_new(?![A-Za-z0-9_])/bufferevent_async_new_/g; s/(?<![A-Za-z0-9_])bufferevent_async_set_connected(?![A-Za-z0-9_])/bufferevent_async_set_connected_/g; s/(?<![A-Za-z0-9_])bufferevent_decref(?![A-Za-z0-9_])/bufferevent_decref_/g; s/(?<![A-Za-z0-9_])bufferevent_disable_hard(?![A-Za-z0-9_])/bufferevent_disable_hard_/g; s/(?<![A-Za-z0-9_])bufferevent_enable_locking(?![A-Za-z0-9_])/bufferevent_enable_locking_/g; s/(?<![A-Za-z0-9_])bufferevent_incref(?![A-Za-z0-9_])/bufferevent_incref_/g; s/(?<![A-Za-z0-9_])bufferevent_init_common(?![A-Za-z0-9_])/bufferevent_init_common_/g; s/(?<![A-Za-z0-9_])bufferevent_remove_from_rate_limit_group_internal(?![A-Za-z0-9_])/bufferevent_remove_from_rate_limit_group_internal_/g; s/(?<![A-Za-z0-9_])bufferevent_suspend_read(?![A-Za-z0-9_])/bufferevent_suspend_read_/g; s/(?<![A-Za-z0-9_])bufferevent_suspend_write(?![A-Za-z0-9_])/bufferevent_suspend_write_/g; s/(?<![A-Za-z0-9_])bufferevent_unsuspend_read(?![A-Za-z0-9_])/bufferevent_unsuspend_read_/g; s/(?<![A-Za-z0-9_])bufferevent_unsuspend_write(?![A-Za-z0-9_])/bufferevent_unsuspend_write_/g; s/(?<![A-Za-z0-9_])evbuffer_commit_read(?![A-Za-z0-9_])/evbuffer_commit_read_/g; s/(?<![A-Za-z0-9_])evbuffer_commit_write(?![A-Za-z0-9_])/evbuffer_commit_write_/g; s/(?<![A-Za-z0-9_])evbuffer_invoke_callbacks(?![A-Za-z0-9_])/evbuffer_invoke_callbacks_/g; s/(?<![A-Za-z0-9_])evbuffer_launch_read(?![A-Za-z0-9_])/evbuffer_launch_read_/g; s/(?<![A-Za-z0-9_])evbuffer_launch_write(?![A-Za-z0-9_])/evbuffer_launch_write_/g; s/(?<![A-Za-z0-9_])evbuffer_overlapped_new(?![A-Za-z0-9_])/evbuffer_overlapped_new_/g; s/(?<![A-Za-z0-9_])evbuffer_set_parent(?![A-Za-z0-9_])/evbuffer_set_parent_/g; s/(?<![A-Za-z0-9_])event_active_nolock(?![A-Za-z0-9_])/event_active_nolock_/g; s/(?<![A-Za-z0-9_])event_base_add_virtual(?![A-Za-z0-9_])/event_base_add_virtual_/g; s/(?<![A-Za-z0-9_])event_base_assert_ok(?![A-Za-z0-9_])/event_base_assert_ok_/g; s/(?<![A-Za-z0-9_])event_base_del_virtual(?![A-Za-z0-9_])/event_base_del_virtual_/g; s/(?<![A-Za-z0-9_])event_base_get_deferred_cb_queue(?![A-Za-z0-9_])/event_base_get_deferred_cb_queue_/g; s/(?<![A-Za-z0-9_])event_base_get_iocp(?![A-Za-z0-9_])/event_base_get_iocp_/g; s/(?<![A-Za-z0-9_])event_base_start_iocp(?![A-Za-z0-9_])/event_base_start_iocp_/g; s/(?<![A-Za-z0-9_])event_base_stop_iocp(?![A-Za-z0-9_])/event_base_stop_iocp_/g; s/(?<![A-Za-z0-9_])event_changelist_add(?![A-Za-z0-9_])/event_changelist_add_/g; s/(?<![A-Za-z0-9_])event_changelist_del(?![A-Za-z0-9_])/event_changelist_del_/g; s/(?<![A-Za-z0-9_])event_changelist_freemem(?![A-Za-z0-9_])/event_changelist_freemem_/g; s/(?<![A-Za-z0-9_])event_changelist_init(?![A-Za-z0-9_])/event_changelist_init_/g; s/(?<![A-Za-z0-9_])event_changelist_remove_all(?![A-Za-z0-9_])/event_changelist_remove_all_/g; s/(?<![A-Za-z0-9_])event_deferred_cb_cancel(?![A-Za-z0-9_])/event_deferred_cb_cancel_/g; s/(?<![A-Za-z0-9_])event_deferred_cb_init(?![A-Za-z0-9_])/event_deferred_cb_init_/g; s/(?<![A-Za-z0-9_])event_deferred_cb_queue_init(?![A-Za-z0-9_])/event_deferred_cb_queue_init_/g; s/(?<![A-Za-z0-9_])event_deferred_cb_schedule(?![A-Za-z0-9_])/event_deferred_cb_schedule_/g; s/(?<![A-Za-z0-9_])event_get_win32_extension_fns(?![A-Za-z0-9_])/event_get_win32_extension_fns_/g; s/(?<![A-Za-z0-9_])event_iocp_activate_overlapped(?![A-Za-z0-9_])/event_iocp_activate_overlapped_/g; s/(?<![A-Za-z0-9_])event_iocp_port_associate(?![A-Za-z0-9_])/event_iocp_port_associate_/g; s/(?<![A-Za-z0-9_])event_iocp_port_launch(?![A-Za-z0-9_])/event_iocp_port_launch_/g; s/(?<![A-Za-z0-9_])event_iocp_shutdown(?![A-Za-z0-9_])/event_iocp_shutdown_/g; s/(?<![A-Za-z0-9_])event_overlapped_init(?![A-Za-z0-9_])/event_overlapped_init_/g; s/(?<![A-Za-z0-9_])evhttp_connection_connect(?![A-Za-z0-9_])/evhttp_connection_connect_/g; s/(?<![A-Za-z0-9_])evhttp_connection_fail(?![A-Za-z0-9_])/evhttp_connection_fail_/g; s/(?<![A-Za-z0-9_])evhttp_connection_reset(?![A-Za-z0-9_])/evhttp_connection_reset_/g; s/(?<![A-Za-z0-9_])evhttp_parse_firstline(?![A-Za-z0-9_])/evhttp_parse_firstline_/g; s/(?<![A-Za-z0-9_])evhttp_parse_headers(?![A-Za-z0-9_])/evhttp_parse_headers_/g; s/(?<![A-Za-z0-9_])evhttp_response_code(?![A-Za-z0-9_])/evhttp_response_code_/g; s/(?<![A-Za-z0-9_])evhttp_send_page(?![A-Za-z0-9_])/evhttp_send_page_/g; s/(?<![A-Za-z0-9_])evhttp_start_read(?![A-Za-z0-9_])/evhttp_start_read_/g; s/(?<![A-Za-z0-9_])EVLOCK_TRY_LOCK(?![A-Za-z0-9_])/EVLOCK_TRY_LOCK_/g; s/(?<![A-Za-z0-9_])evmap_check_integrity(?![A-Za-z0-9_])/evmap_check_integrity_/g; s/(?<![A-Za-z0-9_])evmap_delete_all(?![A-Za-z0-9_])/evmap_delete_all_/g; s/(?<![A-Za-z0-9_])evmap_foreach_event(?![A-Za-z0-9_])/evmap_foreach_event_/g; s/(?<![A-Za-z0-9_])evmap_io_active(?![A-Za-z0-9_])/evmap_io_active_/g; s/(?<![A-Za-z0-9_])evmap_io_add(?![A-Za-z0-9_])/evmap_io_add_/g; s/(?<![A-Za-z0-9_])evmap_io_clear(?![A-Za-z0-9_])/evmap_io_clear_/g; s/(?<![A-Za-z0-9_])evmap_io_del(?![A-Za-z0-9_])/evmap_io_del_/g; s/(?<![A-Za-z0-9_])evmap_io_get_fdinfo(?![A-Za-z0-9_])/evmap_io_get_fdinfo_/g; s/(?<![A-Za-z0-9_])evmap_io_initmap(?![A-Za-z0-9_])/evmap_io_initmap_/g; s/(?<![A-Za-z0-9_])evmap_reinit(?![A-Za-z0-9_])/evmap_reinit_/g; s/(?<![A-Za-z0-9_])evmap_signal_active(?![A-Za-z0-9_])/evmap_signal_active_/g; s/(?<![A-Za-z0-9_])evmap_signal_add(?![A-Za-z0-9_])/evmap_signal_add_/g; s/(?<![A-Za-z0-9_])evmap_signal_clear(?![A-Za-z0-9_])/evmap_signal_clear_/g; s/(?<![A-Za-z0-9_])evmap_signal_del(?![A-Za-z0-9_])/evmap_signal_del_/g; s/(?<![A-Za-z0-9_])evmap_signal_initmap(?![A-Za-z0-9_])/evmap_signal_initmap_/g; s/(?<![A-Za-z0-9_])evrpc_hook_associate_meta(?![A-Za-z0-9_])/evrpc_hook_associate_meta_/g; s/(?<![A-Za-z0-9_])evrpc_hook_context_free(?![A-Za-z0-9_])/evrpc_hook_context_free_/g; s/(?<![A-Za-z0-9_])evrpc_hook_meta_new(?![A-Za-z0-9_])/evrpc_hook_meta_new_/g; s/(?<![A-Za-z0-9_])evrpc_reqstate_free(?![A-Za-z0-9_])/evrpc_reqstate_free_/g; s/(?<![A-Za-z0-9_])evsig_dealloc(?![A-Za-z0-9_])/evsig_dealloc_/g; s/(?<![A-Za-z0-9_])evsig_init(?![A-Za-z0-9_])/evsig_init_/g; s/(?<![A-Za-z0-9_])evsig_set_base(?![A-Za-z0-9_])/evsig_set_base_/g; s/(?<![A-Za-z0-9_])ev_token_bucket_get_tick(?![A-Za-z0-9_])/ev_token_bucket_get_tick_/g; s/(?<![A-Za-z0-9_])ev_token_bucket_init(?![A-Za-z0-9_])/ev_token_bucket_init_/g; s/(?<![A-Za-z0-9_])ev_token_bucket_update(?![A-Za-z0-9_])/ev_token_bucket_update_/g; s/(?<![A-Za-z0-9_])evutil_accept4(?![A-Za-z0-9_])/evutil_accept4_/g; s/(?<![A-Za-z0-9_])evutil_addrinfo_append(?![A-Za-z0-9_])/evutil_addrinfo_append_/g; s/(?<![A-Za-z0-9_])evutil_adjust_hints_for_addrconfig(?![A-Za-z0-9_])/evutil_adjust_hints_for_addrconfig_/g; s/(?<![A-Za-z0-9_])evutil_ersatz_socketpair(?![A-Za-z0-9_])/evutil_ersatz_socketpair_/g; s/(?<![A-Za-z0-9_])evutil_eventfd(?![A-Za-z0-9_])/evutil_eventfd_/g; s/(?<![A-Za-z0-9_])evutil_format_sockaddr_port(?![A-Za-z0-9_])/evutil_format_sockaddr_port_/g; s/(?<![A-Za-z0-9_])evutil_getaddrinfo_async(?![A-Za-z0-9_])/evutil_getaddrinfo_async_/g; s/(?<![A-Za-z0-9_])evutil_getaddrinfo_common(?![A-Za-z0-9_])/evutil_getaddrinfo_common_/g; s/(?<![A-Za-z0-9_])evutil_getenv(?![A-Za-z0-9_])/evutil_getenv_/g; s/(?<![A-Za-z0-9_])evutil_hex_char_to_int(?![A-Za-z0-9_])/evutil_hex_char_to_int_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISALNUM(?![A-Za-z0-9_])/EVUTIL_ISALNUM_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISALPHA(?![A-Za-z0-9_])/EVUTIL_ISALPHA_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISDIGIT(?![A-Za-z0-9_])/EVUTIL_ISDIGIT_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISLOWER(?![A-Za-z0-9_])/EVUTIL_ISLOWER_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISPRINT(?![A-Za-z0-9_])/EVUTIL_ISPRINT_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISSPACE(?![A-Za-z0-9_])/EVUTIL_ISSPACE_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISUPPER(?![A-Za-z0-9_])/EVUTIL_ISUPPER_/g; s/(?<![A-Za-z0-9_])EVUTIL_ISXDIGIT(?![A-Za-z0-9_])/EVUTIL_ISXDIGIT_/g; s/(?<![A-Za-z0-9_])evutil_load_windows_system_library(?![A-Za-z0-9_])/evutil_load_windows_system_library_/g; s/(?<![A-Za-z0-9_])evutil_make_internal_pipe(?![A-Za-z0-9_])/evutil_make_internal_pipe_/g; s/(?<![A-Za-z0-9_])evutil_new_addrinfo(?![A-Za-z0-9_])/evutil_new_addrinfo_/g; s/(?<![A-Za-z0-9_])evutil_open_closeonexec(?![A-Za-z0-9_])/evutil_open_closeonexec_/g; s/(?<![A-Za-z0-9_])evutil_read_file(?![A-Za-z0-9_])/evutil_read_file_/g; s/(?<![A-Za-z0-9_])evutil_resolve(?![A-Za-z0-9_])/evutil_resolve_/g; s/(?<![A-Za-z0-9_])evutil_set_evdns_getaddrinfo_fn(?![A-Za-z0-9_])/evutil_set_evdns_getaddrinfo_fn_/g; s/(?<![A-Za-z0-9_])evutil_sockaddr_is_loopback(?![A-Za-z0-9_])/evutil_sockaddr_is_loopback_/g; s/(?<![A-Za-z0-9_])evutil_socket(?![A-Za-z0-9_])/evutil_socket_/g; s/(?<![A-Za-z0-9_])evutil_socket_connect(?![A-Za-z0-9_])/evutil_socket_connect_/g; s/(?<![A-Za-z0-9_])evutil_socket_finished_connecting(?![A-Za-z0-9_])/evutil_socket_finished_connecting_/g; s/(?<![A-Za-z0-9_])EVUTIL_TOLOWER(?![A-Za-z0-9_])/EVUTIL_TOLOWER_/g; s/(?<![A-Za-z0-9_])EVUTIL_TOUPPER(?![A-Za-z0-9_])/EVUTIL_TOUPPER_/g; s/(?<![A-Za-z0-9_])evutil_tv_to_msec(?![A-Za-z0-9_])/evutil_tv_to_msec_/g; s/(?<![A-Za-z0-9_])evutil_usleep(?![A-Za-z0-9_])/evutil_usleep_/g; s/(?<![A-Za-z0-9_])ht_improve_hash(?![A-Za-z0-9_])/ht_improve_hash_/g; s/(?<![A-Za-z0-9_])ht_string_hash(?![A-Za-z0-9_])/ht_string_hash_/g; s/(?<![A-Za-z0-9_])min_heap_adjust(?![A-Za-z0-9_])/min_heap_adjust_/g; s/(?<![A-Za-z0-9_])min_heap_ctor(?![A-Za-z0-9_])/min_heap_ctor_/g; s/(?<![A-Za-z0-9_])min_heap_dtor(?![A-Za-z0-9_])/min_heap_dtor_/g; s/(?<![A-Za-z0-9_])min_heap_elem_init(?![A-Za-z0-9_])/min_heap_elem_init_/g; s/(?<![A-Za-z0-9_])min_heap_elt_is_top(?![A-Za-z0-9_])/min_heap_elt_is_top_/g; s/(?<![A-Za-z0-9_])min_heap_empty(?![A-Za-z0-9_])/min_heap_empty_/g; s/(?<![A-Za-z0-9_])min_heap_erase(?![A-Za-z0-9_])/min_heap_erase_/g; s/(?<![A-Za-z0-9_])min_heap_pop(?![A-Za-z0-9_])/min_heap_pop_/g; s/(?<![A-Za-z0-9_])min_heap_push(?![A-Za-z0-9_])/min_heap_push_/g; s/(?<![A-Za-z0-9_])min_heap_reserve(?![A-Za-z0-9_])/min_heap_reserve_/g; s/(?<![A-Za-z0-9_])min_heap_size(?![A-Za-z0-9_])/min_heap_size_/g; s/(?<![A-Za-z0-9_])min_heap_top(?![A-Za-z0-9_])/min_heap_top_/g;
Nick Mathewson cb9da0bf 2012-02-29T15:07:32 Fix all identifiers with names beginning with underscore. These are reserved in C. We'd been erroneously using them to indicate internal use. Instead, we now use a trailing underscore whenever we'd been using a leading underscore. This is an automatic conversion. The script that produced was made by running the following script over the output of git ls-tree -r --name-only HEAD | grep '\.[ch]$' | \ xargs ctags --c-kinds=defglmpstuvx -o - | grep '^_' | \ cut -f 1 | sort| uniq (GNU ctags was required.) ===== #!/usr/bin/perl -w -n use strict; BEGIN { print "#!/usr/bin/perl -w -i -p\n\n"; } chomp; next if (/^__func__/ or /^_FILE_OFFSET_BITS/ or /^_FORTIFY_SOURCE/ or /^_GNU_SOURCE/ or /^_WIN32/ or /^_DARWIN_UNLIMITED/ or /^_FILE_OFFSET_BITS/ or /^_LARGEFILE64_SOURCE/ or /^_LFS64_LARGEFILE/ or /^__cdecl/ or /^__attribute__/ or /^__func__/ or /^_SYS_TREE_H_/); my $ident = $_; my $better = $ident; $better =~ s/^_//; if ($ident !~ /EVENT_LOG_/) { $better = "${better}_"; } print "s/(?<![A-Za-z0-9_])$ident(?![A-Za-z0-9_])/$better/g;\n"; === And then running the script below that it generated over all === the .c and .h files again #!/usr/bin/perl -w -i -p s/(?<![A-Za-z0-9_])_ARC4_LOCK(?![A-Za-z0-9_])/ARC4_LOCK_/g; s/(?<![A-Za-z0-9_])_ARC4_UNLOCK(?![A-Za-z0-9_])/ARC4_UNLOCK_/g; s/(?<![A-Za-z0-9_])_bev_group_random_element(?![A-Za-z0-9_])/bev_group_random_element_/g; s/(?<![A-Za-z0-9_])_bev_group_refill_callback(?![A-Za-z0-9_])/bev_group_refill_callback_/g; s/(?<![A-Za-z0-9_])_bev_group_suspend_reading(?![A-Za-z0-9_])/bev_group_suspend_reading_/g; s/(?<![A-Za-z0-9_])_bev_group_suspend_writing(?![A-Za-z0-9_])/bev_group_suspend_writing_/g; s/(?<![A-Za-z0-9_])_bev_group_unsuspend_reading(?![A-Za-z0-9_])/bev_group_unsuspend_reading_/g; s/(?<![A-Za-z0-9_])_bev_group_unsuspend_writing(?![A-Za-z0-9_])/bev_group_unsuspend_writing_/g; s/(?<![A-Za-z0-9_])_bev_refill_callback(?![A-Za-z0-9_])/bev_refill_callback_/g; s/(?<![A-Za-z0-9_])_bufferevent_add_event(?![A-Za-z0-9_])/bufferevent_add_event_/g; s/(?<![A-Za-z0-9_])_bufferevent_cancel_all(?![A-Za-z0-9_])/bufferevent_cancel_all_/g; s/(?<![A-Za-z0-9_])_bufferevent_decref_and_unlock(?![A-Za-z0-9_])/bufferevent_decref_and_unlock_/g; s/(?<![A-Za-z0-9_])_bufferevent_decrement_read_buckets(?![A-Za-z0-9_])/bufferevent_decrement_read_buckets_/g; s/(?<![A-Za-z0-9_])_bufferevent_decrement_write_buckets(?![A-Za-z0-9_])/bufferevent_decrement_write_buckets_/g; s/(?<![A-Za-z0-9_])_bufferevent_del_generic_timeout_cbs(?![A-Za-z0-9_])/bufferevent_del_generic_timeout_cbs_/g; s/(?<![A-Za-z0-9_])_bufferevent_generic_adj_timeouts(?![A-Za-z0-9_])/bufferevent_generic_adj_timeouts_/g; s/(?<![A-Za-z0-9_])_bufferevent_get_read_max(?![A-Za-z0-9_])/bufferevent_get_read_max_/g; s/(?<![A-Za-z0-9_])_bufferevent_get_rlim_max(?![A-Za-z0-9_])/bufferevent_get_rlim_max_/g; s/(?<![A-Za-z0-9_])_bufferevent_get_write_max(?![A-Za-z0-9_])/bufferevent_get_write_max_/g; s/(?<![A-Za-z0-9_])_bufferevent_incref_and_lock(?![A-Za-z0-9_])/bufferevent_incref_and_lock_/g; s/(?<![A-Za-z0-9_])_bufferevent_init_generic_timeout_cbs(?![A-Za-z0-9_])/bufferevent_init_generic_timeout_cbs_/g; s/(?<![A-Za-z0-9_])_bufferevent_ratelim_init(?![A-Za-z0-9_])/bufferevent_ratelim_init_/g; s/(?<![A-Za-z0-9_])_bufferevent_run_eventcb(?![A-Za-z0-9_])/bufferevent_run_eventcb_/g; s/(?<![A-Za-z0-9_])_bufferevent_run_readcb(?![A-Za-z0-9_])/bufferevent_run_readcb_/g; s/(?<![A-Za-z0-9_])_bufferevent_run_writecb(?![A-Za-z0-9_])/bufferevent_run_writecb_/g; s/(?<![A-Za-z0-9_])_ev(?![A-Za-z0-9_])/ev_/g; s/(?<![A-Za-z0-9_])_evbuffer_chain_pin(?![A-Za-z0-9_])/evbuffer_chain_pin_/g; s/(?<![A-Za-z0-9_])_evbuffer_chain_unpin(?![A-Za-z0-9_])/evbuffer_chain_unpin_/g; s/(?<![A-Za-z0-9_])_evbuffer_decref_and_unlock(?![A-Za-z0-9_])/evbuffer_decref_and_unlock_/g; s/(?<![A-Za-z0-9_])_evbuffer_expand_fast(?![A-Za-z0-9_])/evbuffer_expand_fast_/g; s/(?<![A-Za-z0-9_])_evbuffer_incref(?![A-Za-z0-9_])/evbuffer_incref_/g; s/(?<![A-Za-z0-9_])_evbuffer_incref_and_lock(?![A-Za-z0-9_])/evbuffer_incref_and_lock_/g; s/(?<![A-Za-z0-9_])_EVBUFFER_IOVEC_IS_NATIVE(?![A-Za-z0-9_])/EVBUFFER_IOVEC_IS_NATIVE_/g; s/(?<![A-Za-z0-9_])_evbuffer_overlapped_get_fd(?![A-Za-z0-9_])/evbuffer_overlapped_get_fd_/g; s/(?<![A-Za-z0-9_])_evbuffer_overlapped_set_fd(?![A-Za-z0-9_])/evbuffer_overlapped_set_fd_/g; s/(?<![A-Za-z0-9_])_evbuffer_read_setup_vecs(?![A-Za-z0-9_])/evbuffer_read_setup_vecs_/g; s/(?<![A-Za-z0-9_])_evbuffer_validate(?![A-Za-z0-9_])/evbuffer_validate_/g; s/(?<![A-Za-z0-9_])_evdns_log(?![A-Za-z0-9_])/evdns_log_/g; s/(?<![A-Za-z0-9_])_evdns_nameserver_add_impl(?![A-Za-z0-9_])/evdns_nameserver_add_impl_/g; s/(?<![A-Za-z0-9_])_EVENT_CONFIG_H_(?![A-Za-z0-9_])/EVENT_CONFIG_H__/g; s/(?<![A-Za-z0-9_])_event_debug_assert_is_setup(?![A-Za-z0-9_])/event_debug_assert_is_setup_/g; s/(?<![A-Za-z0-9_])_event_debug_assert_not_added(?![A-Za-z0-9_])/event_debug_assert_not_added_/g; s/(?<![A-Za-z0-9_])_event_debug_get_logging_mask(?![A-Za-z0-9_])/event_debug_get_logging_mask_/g; s/(?<![A-Za-z0-9_])_event_debug_logging_mask(?![A-Za-z0-9_])/event_debug_logging_mask_/g; s/(?<![A-Za-z0-9_])_event_debug_map_lock(?![A-Za-z0-9_])/event_debug_map_lock_/g; s/(?<![A-Za-z0-9_])_event_debug_mode_on(?![A-Za-z0-9_])/event_debug_mode_on_/g; s/(?<![A-Za-z0-9_])_event_debug_note_add(?![A-Za-z0-9_])/event_debug_note_add_/g; s/(?<![A-Za-z0-9_])_event_debug_note_del(?![A-Za-z0-9_])/event_debug_note_del_/g; s/(?<![A-Za-z0-9_])_event_debug_note_setup(?![A-Za-z0-9_])/event_debug_note_setup_/g; s/(?<![A-Za-z0-9_])_event_debug_note_teardown(?![A-Za-z0-9_])/event_debug_note_teardown_/g; s/(?<![A-Za-z0-9_])_event_debugx(?![A-Za-z0-9_])/event_debugx_/g; s/(?<![A-Za-z0-9_])_EVENT_DEFINED_LISTENTRY(?![A-Za-z0-9_])/EVENT_DEFINED_LISTENTRY_/g; s/(?<![A-Za-z0-9_])_EVENT_DEFINED_TQENTRY(?![A-Za-z0-9_])/EVENT_DEFINED_TQENTRY_/g; s/(?<![A-Za-z0-9_])_EVENT_DEFINED_TQHEAD(?![A-Za-z0-9_])/EVENT_DEFINED_TQHEAD_/g; s/(?<![A-Za-z0-9_])_EVENT_DNS_USE_FTIME_FOR_ID(?![A-Za-z0-9_])/EVENT_DNS_USE_FTIME_FOR_ID_/g; s/(?<![A-Za-z0-9_])_EVENT_ERR_ABORT(?![A-Za-z0-9_])/EVENT_ERR_ABORT_/g; s/(?<![A-Za-z0-9_])_EVENT_EVCONFIG__PRIVATE_H(?![A-Za-z0-9_])/EVENT_EVCONFIG__PRIVATE_H_/g; s/(?<![A-Za-z0-9_])_event_iocp_port_unlock_and_free(?![A-Za-z0-9_])/event_iocp_port_unlock_and_free_/g; s/(?<![A-Za-z0-9_])_EVENT_LOG_DEBUG(?![A-Za-z0-9_])/EVENT_LOG_DEBUG/g; s/(?<![A-Za-z0-9_])_EVENT_LOG_ERR(?![A-Za-z0-9_])/EVENT_LOG_ERR/g; s/(?<![A-Za-z0-9_])_EVENT_LOG_MSG(?![A-Za-z0-9_])/EVENT_LOG_MSG/g; s/(?<![A-Za-z0-9_])_EVENT_LOG_WARN(?![A-Za-z0-9_])/EVENT_LOG_WARN/g; s/(?<![A-Za-z0-9_])_event_strlcpy(?![A-Za-z0-9_])/event_strlcpy_/g; s/(?<![A-Za-z0-9_])_EVHTTP_REQ_UNKNOWN(?![A-Za-z0-9_])/EVHTTP_REQ_UNKNOWN_/g; s/(?<![A-Za-z0-9_])_EVLOCK_SORTLOCKS(?![A-Za-z0-9_])/EVLOCK_SORTLOCKS_/g; s/(?<![A-Za-z0-9_])_evrpc_hooks(?![A-Za-z0-9_])/evrpc_hooks_/g; s/(?<![A-Za-z0-9_])_evsig_restore_handler(?![A-Za-z0-9_])/evsig_restore_handler_/g; s/(?<![A-Za-z0-9_])_evsig_set_handler(?![A-Za-z0-9_])/evsig_set_handler_/g; s/(?<![A-Za-z0-9_])_evthread_cond_fns(?![A-Za-z0-9_])/evthread_cond_fns_/g; s/(?<![A-Za-z0-9_])_evthread_debug_get_real_lock(?![A-Za-z0-9_])/evthread_debug_get_real_lock_/g; s/(?<![A-Za-z0-9_])_evthread_id_fn(?![A-Za-z0-9_])/evthread_id_fn_/g; s/(?<![A-Za-z0-9_])_evthreadimpl_cond_alloc(?![A-Za-z0-9_])/evthreadimpl_cond_alloc_/g; s/(?<![A-Za-z0-9_])_evthreadimpl_cond_free(?![A-Za-z0-9_])/evthreadimpl_cond_free_/g; s/(?<![A-Za-z0-9_])_evthreadimpl_cond_signal(?![A-Za-z0-9_])/evthreadimpl_cond_signal_/g; s/(?<![A-Za-z0-9_])_evthreadimpl_cond_wait(?![A-Za-z0-9_])/evthreadimpl_cond_wait_/g; s/(?<![A-Za-z0-9_])_evthreadimpl_get_id(?![A-Za-z0-9_])/evthreadimpl_get_id_/g; s/(?<![A-Za-z0-9_])_evthreadimpl_is_lock_debugging_enabled(?![A-Za-z0-9_])/evthreadimpl_is_lock_debugging_enabled_/g; s/(?<![A-Za-z0-9_])_evthreadimpl_lock_alloc(?![A-Za-z0-9_])/evthreadimpl_lock_alloc_/g; s/(?<![A-Za-z0-9_])_evthreadimpl_lock_free(?![A-Za-z0-9_])/evthreadimpl_lock_free_/g; s/(?<![A-Za-z0-9_])_evthreadimpl_locking_enabled(?![A-Za-z0-9_])/evthreadimpl_locking_enabled_/g; s/(?<![A-Za-z0-9_])_evthreadimpl_lock_lock(?![A-Za-z0-9_])/evthreadimpl_lock_lock_/g; s/(?<![A-Za-z0-9_])_evthreadimpl_lock_unlock(?![A-Za-z0-9_])/evthreadimpl_lock_unlock_/g; s/(?<![A-Za-z0-9_])_evthread_is_debug_lock_held(?![A-Za-z0-9_])/evthread_is_debug_lock_held_/g; s/(?<![A-Za-z0-9_])_evthread_lock_debugging_enabled(?![A-Za-z0-9_])/evthread_lock_debugging_enabled_/g; s/(?<![A-Za-z0-9_])_evthread_lock_fns(?![A-Za-z0-9_])/evthread_lock_fns_/g; s/(?<![A-Za-z0-9_])_EVUTIL_NIL_CONDITION(?![A-Za-z0-9_])/EVUTIL_NIL_CONDITION_/g; s/(?<![A-Za-z0-9_])_EVUTIL_NIL_STMT(?![A-Za-z0-9_])/EVUTIL_NIL_STMT_/g; s/(?<![A-Za-z0-9_])_evutil_weakrand(?![A-Za-z0-9_])/evutil_weakrand_/g; s/(?<![A-Za-z0-9_])_http_close_detection(?![A-Za-z0-9_])/http_close_detection_/g; s/(?<![A-Za-z0-9_])_http_connection_test(?![A-Za-z0-9_])/http_connection_test_/g; s/(?<![A-Za-z0-9_])_http_incomplete_test(?![A-Za-z0-9_])/http_incomplete_test_/g; s/(?<![A-Za-z0-9_])_http_stream_in_test(?![A-Za-z0-9_])/http_stream_in_test_/g; s/(?<![A-Za-z0-9_])_internal(?![A-Za-z0-9_])/internal_/g; s/(?<![A-Za-z0-9_])_mm_free_fn(?![A-Za-z0-9_])/mm_free_fn_/g; s/(?<![A-Za-z0-9_])_mm_malloc_fn(?![A-Za-z0-9_])/mm_malloc_fn_/g; s/(?<![A-Za-z0-9_])_mm_realloc_fn(?![A-Za-z0-9_])/mm_realloc_fn_/g; s/(?<![A-Za-z0-9_])_original_cond_fns(?![A-Za-z0-9_])/original_cond_fns_/g; s/(?<![A-Za-z0-9_])_original_lock_fns(?![A-Za-z0-9_])/original_lock_fns_/g; s/(?<![A-Za-z0-9_])_rpc_hook_ctx(?![A-Za-z0-9_])/rpc_hook_ctx_/g; s/(?<![A-Za-z0-9_])_SYS_QUEUE_H_(?![A-Za-z0-9_])/SYS_QUEUE_H__/g; s/(?<![A-Za-z0-9_])_t(?![A-Za-z0-9_])/t_/g; s/(?<![A-Za-z0-9_])_t32(?![A-Za-z0-9_])/t32_/g; s/(?<![A-Za-z0-9_])_test_ai_eq(?![A-Za-z0-9_])/test_ai_eq_/g; s/(?<![A-Za-z0-9_])_URI_ADD(?![A-Za-z0-9_])/URI_ADD_/g; s/(?<![A-Za-z0-9_])_URI_FREE_STR(?![A-Za-z0-9_])/URI_FREE_STR_/g; s/(?<![A-Za-z0-9_])_URI_SET_STR(?![A-Za-z0-9_])/URI_SET_STR_/g; s/(?<![A-Za-z0-9_])_warn_helper(?![A-Za-z0-9_])/warn_helper_/g;
Nick Mathewson 68120d9b 2012-02-29T15:07:31 Convert event-config.h macros to avoid reserved identifiers C reserves all identifiers beginning with an underscore for system use. But we had been mangling our autoconf identifiers with the prefix "_EVENT_" to avoid conflict with other programs. Instead, we will now use the prefix "EVENT__". With any luck, the double-underscore will still hint "here be dragons" to anybody tempted to think that event-config.h is a stable api. This is an automatically generated patch. The script that produced it was made by running this script over config.h.in: ===== #!/usr/bin/perl -w # Run this on config.h.in use strict; my %macros = (); while (<>) { if (/^# *undef +([A-Za-z0-9_]+)/) { $macros{$1} = 1; } } print "#!/usr/bin/perl -w -i -p\n\n"; for my $k (sort keys %macros) { print "s/(?<![A-Za-z0-9_])_EVENT_$k(?![A-Za-z0-9_])/EVENT__$k/g;\n"; } == And the script that it generated was then run over all .c and .h files: #!/usr/bin/perl -w -i -p s/(?<![A-Za-z0-9_])_EVENT_DISABLE_DEBUG_MODE(?![A-Za-z0-9_])/EVENT__DISABLE_DEBUG_MODE/g; s/(?<![A-Za-z0-9_])_EVENT_DISABLE_MM_REPLACEMENT(?![A-Za-z0-9_])/EVENT__DISABLE_MM_REPLACEMENT/g; s/(?<![A-Za-z0-9_])_EVENT_DISABLE_THREAD_SUPPORT(?![A-Za-z0-9_])/EVENT__DISABLE_THREAD_SUPPORT/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_ACCEPT4(?![A-Za-z0-9_])/EVENT__HAVE_ACCEPT4/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_ARC4RANDOM(?![A-Za-z0-9_])/EVENT__HAVE_ARC4RANDOM/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_ARC4RANDOM_BUF(?![A-Za-z0-9_])/EVENT__HAVE_ARC4RANDOM_BUF/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_ARPA_INET_H(?![A-Za-z0-9_])/EVENT__HAVE_ARPA_INET_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_CLOCK_GETTIME(?![A-Za-z0-9_])/EVENT__HAVE_CLOCK_GETTIME/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_DECL_CTL_KERN(?![A-Za-z0-9_])/EVENT__HAVE_DECL_CTL_KERN/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_DECL_KERN_ARND(?![A-Za-z0-9_])/EVENT__HAVE_DECL_KERN_ARND/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_DECL_KERN_RANDOM(?![A-Za-z0-9_])/EVENT__HAVE_DECL_KERN_RANDOM/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_DECL_RANDOM_UUID(?![A-Za-z0-9_])/EVENT__HAVE_DECL_RANDOM_UUID/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_DEVPOLL(?![A-Za-z0-9_])/EVENT__HAVE_DEVPOLL/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_DLFCN_H(?![A-Za-z0-9_])/EVENT__HAVE_DLFCN_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_EPOLL(?![A-Za-z0-9_])/EVENT__HAVE_EPOLL/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_EPOLL_CREATE1(?![A-Za-z0-9_])/EVENT__HAVE_EPOLL_CREATE1/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_EPOLL_CTL(?![A-Za-z0-9_])/EVENT__HAVE_EPOLL_CTL/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_EVENTFD(?![A-Za-z0-9_])/EVENT__HAVE_EVENTFD/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_EVENT_PORTS(?![A-Za-z0-9_])/EVENT__HAVE_EVENT_PORTS/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_FCNTL(?![A-Za-z0-9_])/EVENT__HAVE_FCNTL/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_FCNTL_H(?![A-Za-z0-9_])/EVENT__HAVE_FCNTL_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_FD_MASK(?![A-Za-z0-9_])/EVENT__HAVE_FD_MASK/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_GETADDRINFO(?![A-Za-z0-9_])/EVENT__HAVE_GETADDRINFO/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_GETEGID(?![A-Za-z0-9_])/EVENT__HAVE_GETEGID/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_GETEUID(?![A-Za-z0-9_])/EVENT__HAVE_GETEUID/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_GETHOSTBYNAME_R(?![A-Za-z0-9_])/EVENT__HAVE_GETHOSTBYNAME_R/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_GETHOSTBYNAME_R_3_ARG(?![A-Za-z0-9_])/EVENT__HAVE_GETHOSTBYNAME_R_3_ARG/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_GETHOSTBYNAME_R_5_ARG(?![A-Za-z0-9_])/EVENT__HAVE_GETHOSTBYNAME_R_5_ARG/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_GETHOSTBYNAME_R_6_ARG(?![A-Za-z0-9_])/EVENT__HAVE_GETHOSTBYNAME_R_6_ARG/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_GETIFADDRS(?![A-Za-z0-9_])/EVENT__HAVE_GETIFADDRS/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_GETNAMEINFO(?![A-Za-z0-9_])/EVENT__HAVE_GETNAMEINFO/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_GETPROTOBYNUMBER(?![A-Za-z0-9_])/EVENT__HAVE_GETPROTOBYNUMBER/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_GETSERVBYNAME(?![A-Za-z0-9_])/EVENT__HAVE_GETSERVBYNAME/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_GETTIMEOFDAY(?![A-Za-z0-9_])/EVENT__HAVE_GETTIMEOFDAY/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_IFADDRS_H(?![A-Za-z0-9_])/EVENT__HAVE_IFADDRS_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_INET_ATON(?![A-Za-z0-9_])/EVENT__HAVE_INET_ATON/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_INET_NTOP(?![A-Za-z0-9_])/EVENT__HAVE_INET_NTOP/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_INET_PTON(?![A-Za-z0-9_])/EVENT__HAVE_INET_PTON/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_INTTYPES_H(?![A-Za-z0-9_])/EVENT__HAVE_INTTYPES_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_ISSETUGID(?![A-Za-z0-9_])/EVENT__HAVE_ISSETUGID/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_KQUEUE(?![A-Za-z0-9_])/EVENT__HAVE_KQUEUE/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_LIBZ(?![A-Za-z0-9_])/EVENT__HAVE_LIBZ/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_MEMORY_H(?![A-Za-z0-9_])/EVENT__HAVE_MEMORY_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_MMAP(?![A-Za-z0-9_])/EVENT__HAVE_MMAP/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_NANOSLEEP(?![A-Za-z0-9_])/EVENT__HAVE_NANOSLEEP/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_NETDB_H(?![A-Za-z0-9_])/EVENT__HAVE_NETDB_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_NETINET_IN6_H(?![A-Za-z0-9_])/EVENT__HAVE_NETINET_IN6_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_NETINET_IN_H(?![A-Za-z0-9_])/EVENT__HAVE_NETINET_IN_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_NETINET_TCP_H(?![A-Za-z0-9_])/EVENT__HAVE_NETINET_TCP_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_OPENSSL(?![A-Za-z0-9_])/EVENT__HAVE_OPENSSL/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_PIPE(?![A-Za-z0-9_])/EVENT__HAVE_PIPE/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_PIPE2(?![A-Za-z0-9_])/EVENT__HAVE_PIPE2/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_POLL(?![A-Za-z0-9_])/EVENT__HAVE_POLL/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_POLL_H(?![A-Za-z0-9_])/EVENT__HAVE_POLL_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_PORT_CREATE(?![A-Za-z0-9_])/EVENT__HAVE_PORT_CREATE/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_PORT_H(?![A-Za-z0-9_])/EVENT__HAVE_PORT_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_PTHREAD(?![A-Za-z0-9_])/EVENT__HAVE_PTHREAD/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_PTHREADS(?![A-Za-z0-9_])/EVENT__HAVE_PTHREADS/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_PUTENV(?![A-Za-z0-9_])/EVENT__HAVE_PUTENV/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SA_FAMILY_T(?![A-Za-z0-9_])/EVENT__HAVE_SA_FAMILY_T/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SELECT(?![A-Za-z0-9_])/EVENT__HAVE_SELECT/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SENDFILE(?![A-Za-z0-9_])/EVENT__HAVE_SENDFILE/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SETENV(?![A-Za-z0-9_])/EVENT__HAVE_SETENV/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SETFD(?![A-Za-z0-9_])/EVENT__HAVE_SETFD/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SETRLIMIT(?![A-Za-z0-9_])/EVENT__HAVE_SETRLIMIT/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SIGACTION(?![A-Za-z0-9_])/EVENT__HAVE_SIGACTION/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SIGNAL(?![A-Za-z0-9_])/EVENT__HAVE_SIGNAL/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SPLICE(?![A-Za-z0-9_])/EVENT__HAVE_SPLICE/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STDARG_H(?![A-Za-z0-9_])/EVENT__HAVE_STDARG_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STDDEF_H(?![A-Za-z0-9_])/EVENT__HAVE_STDDEF_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STDINT_H(?![A-Za-z0-9_])/EVENT__HAVE_STDINT_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STDLIB_H(?![A-Za-z0-9_])/EVENT__HAVE_STDLIB_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRINGS_H(?![A-Za-z0-9_])/EVENT__HAVE_STRINGS_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRING_H(?![A-Za-z0-9_])/EVENT__HAVE_STRING_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRLCPY(?![A-Za-z0-9_])/EVENT__HAVE_STRLCPY/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRSEP(?![A-Za-z0-9_])/EVENT__HAVE_STRSEP/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRTOK_R(?![A-Za-z0-9_])/EVENT__HAVE_STRTOK_R/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRTOLL(?![A-Za-z0-9_])/EVENT__HAVE_STRTOLL/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRUCT_ADDRINFO(?![A-Za-z0-9_])/EVENT__HAVE_STRUCT_ADDRINFO/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRUCT_IN6_ADDR(?![A-Za-z0-9_])/EVENT__HAVE_STRUCT_IN6_ADDR/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRUCT_IN6_ADDR_S6_ADDR16(?![A-Za-z0-9_])/EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRUCT_IN6_ADDR_S6_ADDR32(?![A-Za-z0-9_])/EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRUCT_SOCKADDR_IN6(?![A-Za-z0-9_])/EVENT__HAVE_STRUCT_SOCKADDR_IN6/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN(?![A-Za-z0-9_])/EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRUCT_SOCKADDR_IN_SIN_LEN(?![A-Za-z0-9_])/EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRUCT_SOCKADDR_STORAGE(?![A-Za-z0-9_])/EVENT__HAVE_STRUCT_SOCKADDR_STORAGE/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY(?![A-Za-z0-9_])/EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY(?![A-Za-z0-9_])/EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYSCTL(?![A-Za-z0-9_])/EVENT__HAVE_SYSCTL/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_DEVPOLL_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_DEVPOLL_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_EPOLL_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_EPOLL_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_EVENTFD_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_EVENTFD_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_EVENT_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_EVENT_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_IOCTL_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_IOCTL_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_MMAN_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_MMAN_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_PARAM_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_PARAM_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_QUEUE_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_QUEUE_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_RESOURCE_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_RESOURCE_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_SELECT_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_SELECT_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_SENDFILE_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_SENDFILE_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_SOCKET_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_SOCKET_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_STAT_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_STAT_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_SYSCTL_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_SYSCTL_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_TIME_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_TIME_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_TYPES_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_TYPES_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_UIO_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_UIO_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_SYS_WAIT_H(?![A-Za-z0-9_])/EVENT__HAVE_SYS_WAIT_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_TAILQFOREACH(?![A-Za-z0-9_])/EVENT__HAVE_TAILQFOREACH/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_TIMERADD(?![A-Za-z0-9_])/EVENT__HAVE_TIMERADD/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_TIMERCLEAR(?![A-Za-z0-9_])/EVENT__HAVE_TIMERCLEAR/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_TIMERCMP(?![A-Za-z0-9_])/EVENT__HAVE_TIMERCMP/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_TIMERISSET(?![A-Za-z0-9_])/EVENT__HAVE_TIMERISSET/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_UINT16_T(?![A-Za-z0-9_])/EVENT__HAVE_UINT16_T/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_UINT32_T(?![A-Za-z0-9_])/EVENT__HAVE_UINT32_T/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_UINT64_T(?![A-Za-z0-9_])/EVENT__HAVE_UINT64_T/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_UINT8_T(?![A-Za-z0-9_])/EVENT__HAVE_UINT8_T/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_UINTPTR_T(?![A-Za-z0-9_])/EVENT__HAVE_UINTPTR_T/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_UNISTD_H(?![A-Za-z0-9_])/EVENT__HAVE_UNISTD_H/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_UNSETENV(?![A-Za-z0-9_])/EVENT__HAVE_UNSETENV/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_USLEEP(?![A-Za-z0-9_])/EVENT__HAVE_USLEEP/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_VASPRINTF(?![A-Za-z0-9_])/EVENT__HAVE_VASPRINTF/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_WORKING_KQUEUE(?![A-Za-z0-9_])/EVENT__HAVE_WORKING_KQUEUE/g; s/(?<![A-Za-z0-9_])_EVENT_HAVE_ZLIB_H(?![A-Za-z0-9_])/EVENT__HAVE_ZLIB_H/g; s/(?<![A-Za-z0-9_])_EVENT_LT_OBJDIR(?![A-Za-z0-9_])/EVENT__LT_OBJDIR/g; s/(?<![A-Za-z0-9_])_EVENT_NO_MINUS_C_MINUS_O(?![A-Za-z0-9_])/EVENT__NO_MINUS_C_MINUS_O/g; s/(?<![A-Za-z0-9_])_EVENT_NUMERIC_VERSION(?![A-Za-z0-9_])/EVENT__NUMERIC_VERSION/g; s/(?<![A-Za-z0-9_])_EVENT_PACKAGE(?![A-Za-z0-9_])/EVENT__PACKAGE/g; s/(?<![A-Za-z0-9_])_EVENT_PACKAGE_BUGREPORT(?![A-Za-z0-9_])/EVENT__PACKAGE_BUGREPORT/g; s/(?<![A-Za-z0-9_])_EVENT_PACKAGE_NAME(?![A-Za-z0-9_])/EVENT__PACKAGE_NAME/g; s/(?<![A-Za-z0-9_])_EVENT_PACKAGE_STRING(?![A-Za-z0-9_])/EVENT__PACKAGE_STRING/g; s/(?<![A-Za-z0-9_])_EVENT_PACKAGE_TARNAME(?![A-Za-z0-9_])/EVENT__PACKAGE_TARNAME/g; s/(?<![A-Za-z0-9_])_EVENT_PACKAGE_URL(?![A-Za-z0-9_])/EVENT__PACKAGE_URL/g; s/(?<![A-Za-z0-9_])_EVENT_PACKAGE_VERSION(?![A-Za-z0-9_])/EVENT__PACKAGE_VERSION/g; s/(?<![A-Za-z0-9_])_EVENT_PTHREAD_CREATE_JOINABLE(?![A-Za-z0-9_])/EVENT__PTHREAD_CREATE_JOINABLE/g; s/(?<![A-Za-z0-9_])_EVENT_SIZEOF_INT(?![A-Za-z0-9_])/EVENT__SIZEOF_INT/g; s/(?<![A-Za-z0-9_])_EVENT_SIZEOF_LONG(?![A-Za-z0-9_])/EVENT__SIZEOF_LONG/g; s/(?<![A-Za-z0-9_])_EVENT_SIZEOF_LONG_LONG(?![A-Za-z0-9_])/EVENT__SIZEOF_LONG_LONG/g; s/(?<![A-Za-z0-9_])_EVENT_SIZEOF_OFF_T(?![A-Za-z0-9_])/EVENT__SIZEOF_OFF_T/g; s/(?<![A-Za-z0-9_])_EVENT_SIZEOF_PTHREAD_T(?![A-Za-z0-9_])/EVENT__SIZEOF_PTHREAD_T/g; s/(?<![A-Za-z0-9_])_EVENT_SIZEOF_SHORT(?![A-Za-z0-9_])/EVENT__SIZEOF_SHORT/g; s/(?<![A-Za-z0-9_])_EVENT_SIZEOF_SIZE_T(?![A-Za-z0-9_])/EVENT__SIZEOF_SIZE_T/g; s/(?<![A-Za-z0-9_])_EVENT_SIZEOF_VOID_P(?![A-Za-z0-9_])/EVENT__SIZEOF_VOID_P/g; s/(?<![A-Za-z0-9_])_EVENT_STDC_HEADERS(?![A-Za-z0-9_])/EVENT__STDC_HEADERS/g; s/(?<![A-Za-z0-9_])_EVENT_TIME_WITH_SYS_TIME(?![A-Za-z0-9_])/EVENT__TIME_WITH_SYS_TIME/g; s/(?<![A-Za-z0-9_])_EVENT_VERSION(?![A-Za-z0-9_])/EVENT__VERSION/g; s/(?<![A-Za-z0-9_])_EVENT__ALL_SOURCE(?![A-Za-z0-9_])/EVENT___ALL_SOURCE/g; s/(?<![A-Za-z0-9_])_EVENT__FILE_OFFSET_BITS(?![A-Za-z0-9_])/EVENT___FILE_OFFSET_BITS/g; s/(?<![A-Za-z0-9_])_EVENT__GNU_SOURCE(?![A-Za-z0-9_])/EVENT___GNU_SOURCE/g; s/(?<![A-Za-z0-9_])_EVENT__LARGE_FILES(?![A-Za-z0-9_])/EVENT___LARGE_FILES/g; s/(?<![A-Za-z0-9_])_EVENT__MINIX(?![A-Za-z0-9_])/EVENT___MINIX/g; s/(?<![A-Za-z0-9_])_EVENT__POSIX_1_SOURCE(?![A-Za-z0-9_])/EVENT___POSIX_1_SOURCE/g; s/(?<![A-Za-z0-9_])_EVENT__POSIX_PTHREAD_SEMANTICS(?![A-Za-z0-9_])/EVENT___POSIX_PTHREAD_SEMANTICS/g; s/(?<![A-Za-z0-9_])_EVENT__POSIX_SOURCE(?![A-Za-z0-9_])/EVENT___POSIX_SOURCE/g; s/(?<![A-Za-z0-9_])_EVENT__TANDEM_SOURCE(?![A-Za-z0-9_])/EVENT___TANDEM_SOURCE/g; s/(?<![A-Za-z0-9_])_EVENT___EXTENSIONS__(?![A-Za-z0-9_])/EVENT____EXTENSIONS__/g; s/(?<![A-Za-z0-9_])_EVENT___func__(?![A-Za-z0-9_])/EVENT____func__/g; s/(?<![A-Za-z0-9_])_EVENT_const(?![A-Za-z0-9_])/EVENT__const/g; s/(?<![A-Za-z0-9_])_EVENT_inline(?![A-Za-z0-9_])/EVENT__inline/g; s/(?<![A-Za-z0-9_])_EVENT_pid_t(?![A-Za-z0-9_])/EVENT__pid_t/g; s/(?<![A-Za-z0-9_])_EVENT_size_t(?![A-Za-z0-9_])/EVENT__size_t/g; s/(?<![A-Za-z0-9_])_EVENT_socklen_t(?![A-Za-z0-9_])/EVENT__socklen_t/g; s/(?<![A-Za-z0-9_])_EVENT_ssize_t(?![A-Za-z0-9_])/EVENT__ssize_t/g;
Nick Mathewson 539466e5 2012-02-10T17:33:50 Merge remote-tracking branch 'origin/patches-2.0' Conflicts: Makefile.am WIN32-Code/event2/event-config.h configure.in
Nick Mathewson e49e2891 2012-02-10T17:29:53 Update copyright notices to 2012
Nick Mathewson c00416f7 2012-02-06T12:39:09 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 5b4b8126 2012-02-06T12:24:49 Loop on filtering SSL reads until we are blocked or exhausted. This is not a perfect fix, but it's much much better than the current buggy behavior, which could lead to filtering SSL connections that just stopped reading. Based on ideas by Maseeb Abdul Qadir and Mark Ellzey.
Nick Mathewson f3b89dec 2011-11-24T12:31:50 Fix two issues in the allow_dirty_shutdown code. First, it shouldn't crash when it's passed a non-ssl bufferevent. Second, it should behave correctly when it gets a true argument other than 1.
Catalin Patulea 099d27df 2011-11-21T19:57:19 Allow users to set allow_dirty_shutdown
Catalin Patulea f7eb69ac 2011-11-21T19:24:50 bev_ssl: Be more specific in event callbacks. evhttp in particular gets confused without at least one of BEV_EVENT_{READING|WRITING}.
Nick Mathewson 9ee9e943 2011-11-18T14:23:13 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson ebf82199 2011-11-17T17:42:45 add comment to new consider_reading code
Mark Ellzey 2aa036fa 2011-11-17T11:59:41 Avoid spinning on OpenSSL reads Previously, if some sender were generating data to read on an OpenSSL connection as fast as we could process it, we could easily wind up looping on an openssl do_read operation without ever considering other sockets. The difference between this and the original method in consider_reading() is that it only loops for a single completed *frame* instead of looping until fd is drained or an error condition was triggered. {Patch split out by nickm}
Nick Mathewson 96c562fa 2011-11-17T11:54:07 Move SSL rate-limit enforcement into bytes_to_read()
Mark Ellzey a186e732 2011-11-17T11:45:49 Refactor amount-to-read calculations in buffervent_ssl consider_reading() Split up consider_reading()'s conditional checks into another function can_read() for simplicity sake. {Split into a separate patch by nickm}
Nick Mathewson 6660c9a3 2011-11-15T18:34:24 Revert "Avoid potential SSL read spinlocks" This reverts commit fc52dbac87f4937f8306759506d6a2ad15ca244c.
Nick Mathewson a62346de 2011-11-15T18:33:50 Revert "openssl bufferevent has the same issue with writing as prior commit." This reverts commit 7353663eb7c0b2a1caaaa5acd818515f156cf2ca.
Nick Mathewson 2ebc8c80 2011-11-14T11:55:37 Merge remote-tracking branch 'origin/patches-2.0'
Mark Ellzey 7353663e 2011-11-14T10:57:15 openssl bufferevent has the same issue with writing as prior commit.
Mark Ellzey fc52dbac 2011-11-14T10:24:07 Avoid potential SSL read spinlocks OpenSSL bufferevents with deferred callbacks enabled under high load will spinlock in the function consider_reading(). This loop continues until all data has been read. Because of this condition; openssl bufferevents will never return back into event_base_loop() until SSL_read has determined data is no longer ready. As of yet I have not found a reason why this while loop exists, so this patch just swaps out while for if. If needed I can write same code which would trigger this effect; optionally libevhtp has a test.c program which can be run with the following flags: ./test -s <keyfile.pem> curl -vvvv -k -d@<HUGE_ASS_FILE> https://127.0.0.1:8081/ The return data will include the number of times the readcb got data and the length of that read. Without this patch, you are likely to see a small amount of "bytes read....", otherwise the "bytes read..." return data should show much more reasonable numbers.
Nick Mathewson 0cb70e33 2011-10-26T10:17:21 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 3c824bd3 2011-10-24T13:18:09 Update copyright dates to 2011.
Nick Mathewson e9cccce6 2011-08-29T17:51:45 Merge remote-tracking branch 'origin/patches-2.0'
Joachim Bauch 54f7e61b 2011-08-29T23:39:26 clear read watermark on underlying bufferevent when creating filtering bev to fix potentially failing fragmented ssl handshakes
Nick Mathewson 904254f9 2011-08-28T14:51:36 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson e6af35d7 2011-08-24T21:39:28 Correctly terminate IO on an async bufferevent on bufferevent_free
Nick Mathewson 909c40e5 2011-08-03T12:12:47 Merge remote-tracking branch 'origin/patches-2.0'
Joachim Bauch 4a343943 2011-07-26T10:31:18 Propagate errors on the underlying bufferevent to the user.
Nick Mathewson c116d960 2011-07-04T11:37:52 Merge remote-tracking branch 'origin/patches-2.0'
Joachim Bauch e050703d 2011-07-04T11:36:14 Fix bug in SSL bufferevents backed by a bev with a write high-watermarks Original mail: the logic that handles write watermarks in "bio_bufferevent_write" is not working. It currently doesn't write any data if the high watermark is *above* the amount of data to write (i.e. when there is actually enough room available).
Nick Mathewson 9f560bfa 2011-05-25T19:50:56 Use "_WIN32", not WIN32: it's standard and we don't need to fake it This patch was automatically generated with perl. Based on a patch by Peter Rosin.
Nick Mathewson 614a1712 2011-04-22T23:46:25 Merge remote-tracking branch 'origin/patches-2.0' Conflicts: evthread.c
Sebastian Hahn 65707d7c 2011-04-11T17:40:14 add some (void) casts for unused variables All these places already have an XXX marker, so we know we need to fix them later. Let's not clutter the static analysis results with them.
Kevin Bowling 0915ca0a 2011-01-02T08:43:45 Include evconfig-private.h in internal files for great good.
Nick Mathewson 29f7623c 2010-11-29T22:14:54 Possible crash fix when freeing an underlying bufferevent of an openssl bufferevent
Nick Mathewson 4f228a1f 2010-11-14T19:52:18 Fix bug in bufferevent_connect on an openssl bufferevent that already had an fd The problem was that we were using openssl's BIO code's shutdown flag whenever BEV_OPT_CLOSE_ON_FREE was set. This made the BIO close the socket when it was freed... but it would be freed whenever we did a setfd on the bufferevent_openssl, even the no-op setfd in bufferevent_connect. So instead, we just set the shutdown flag to 0, and handle closing the fd ourselves. Spotted by Linus Nordberg
Nick Mathewson 1ac5b230 2010-11-09T15:18:59 Only clear underlying callbacks when the user hasn't reset them.
Nick Mathewson fc7b1b00 2010-11-09T11:43:47 When closing a filtering bufferevent, clear callbacks on the underlying bufferevent Previously, if BEV_OPT_CLOSE_ON_FREE wasn't set on a bufferevent_filter or a filtering bufferevent_openssl, when we went to free the filtering bufferevent, we'd leave the underlying bufferevent unchanged. That's not so good, since the callbacks are set to activate stuff in the filtering bufferevent that we're about to free. Instead, set all the callbacks to NULL.
Nick Mathewson 1213d3dd 2010-10-20T13:41:02 Fix a 100%-CPU bug where an SSL connection would sometimes never stop trying to write If an SSL connection becamse disabled or suspended before became open, it could (under the right circumstances) wind up without ever getting its write callback disabled. The most correct fix is probably more subtle, and involves checking all caseswhen a write callback is enabled or disabled. This fix is more blunt, and explicitly checks whether the callback should have been disabled at the end of the callback to prevent infinite looping. Diagnosed with help from Sebastian Hahn
Nick Mathewson 93bb7d8e 2010-10-14T11:41:10 Fix a case where an ssl bufferevent with CLOSE_ON_FREE didn't close its fd This could happen when we got an SSL with a BIO already set on it.