Fixes: 630f077c296de61c7b99ed83bf30de11e75e2740 ("Simple unit tests for
monotonic timers")
(cherry picked from commit 6cce7458d0f94e320f201eb5be94866e6918d66c)
Fixes: #577
* evconnlistener-do-not-close-client-fd:
listener: cover closing of fd in case evconnlistener_free() called from acceptcb
Revert "Fix potential fd leak in listener_read_cb()"
(cherry picked from commit bc65ffc14c62c10feffefe6c3d9975ce1d1a8cd8)
'LIBEVENT_INCLUDE_DIRS' is properly initialized in 'LibeventConfig.cmake' as
'LibeventConfig.cmake.in' contains usage of 'LIBEVENT_CMAKE_DIR' and
'EVENT_INSTALL_INCLUDE_DIR' variables but not 'EVENT_CMAKE_DIR' and
'EVENT__INCLUDE_DIRS'.
Related typos are fixed.
(cherry picked from commit 6ee73ea9b0b15a9f4909c51e171b7799210ec26c)
Before it depends from the caller #include appropriate headers (at least
for OPENSSL_VERSION_NUMBER), but let's make it independent.
Fixes: #574
(cherry picked from commit c2c08e0203da93938fe35234fa3a1be4d1c3c2e1)
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.
(cherry picked from commit b49c70cc2ed54f511e2b41f7ed61d357c88300be)
This is the second hunk of the first patch
5ff8eb26371c4dc56f384b2de35bea2d87814779 ("Fix crashing http server when
callback do not reply in place")
Fixes: #567
(cherry picked from commit 306747e51c1f0de679a3b165b9429418c89f8d6a)
I checked with nginx, and via it's lua bindings it allows body for all
this methods. Also everybody knows that some of web-servers allows body
for GET even though this is not RFC conformant.
Refs: #408
(cherry picked from commit db483e3b002b33890fc88cadd77f6fd1fccad2d2)
This fixes the crash reported in issue #509. The "would be nice"
items discussed in #509 can be addressed separately.
(cherry picked from commit 99d0a952dada771b91acf63f5208b994e80a2986)
General http callback looks like:
static void http_cb(struct evhttp_request *req, void *arg)
{
evhttp_send_reply(req, HTTP_OK, "Everything is fine", NULL);
}
And they will work fine becuase in this case http will write request
first, and during write preparation it will disable *read callback* (in
evhttp_write_buffer()), but if we don't reply immediately, for example:
static void http_cb(struct evhttp_request *req, void *arg)
{
return;
}
This will leave connection in incorrect state, and if another request
will be written to the same connection libevent will abort with:
[err] ../http.c: illegal connection state 7
Because it thinks that read for now is not possible, since there were no
write.
Fix this by disabling EV_READ entirely. We couldn't just reset callbacks
because this will leave EOF detection, which we don't need, since user
hasn't replied to callback yet.
Reported-by: Cory Fields <cory@coryfields.com>
(cherry picked from commit 5ff8eb26371c4dc56f384b2de35bea2d87814779)
Since it can arrive after we disabled events in that bufferevent and
reseted fd, hence evhttp_error_cb() could be called after
SSL_RECEIVED_SHUTDOWN.
Closes: #557
(cherry picked from commit da3f2ba22adcabaf7355a90d537b4928d0c168d2)
Because it is mauvais ton to use binaries instead of normal packages
(like apt-get in debian, pacman in arch, and others).
Plus that link was borken and according to [1] OpenSSL do not ship
binaries officially.
And personally I don't think that this is not obvious that you need
openssl libraries to build libevent with it's support, and BTW you need
headers too (of course).
[1]: https://www.openssl.org/community/binaries.htmlFixes: #562
(cherry picked from commit 62866f98a5979e3b9ee8db0287be79749fcf7d6a)
In function ‘send_a_byte_cb’:
test/regress.c:1853:2: warning: ignoring return value of ‘write’, declared with
attribute warn_unused_result [-Wunused-result]
(void) write(*sockp, "A", 1);
(cherry picked from commit 56010f37ae5b49881f7fd255d5c8a936e1c36909)
by default, the max buffer size is 16K and histeresis is at 50%, so
a bigger read is needed to unlock writes than you would expect from
other BSD (512 bytes)
this doesn't introduce any regression on FreeBSD 11.1, OpenBSD 6.1, NetBSD 7.1,
macOS 10.12.6 and of course DragonFlyBSD 4.8.1, and most of them show
a max pipe size of 64K, so the read call should drain them all regardless
of how conservative they are on the free pipe space they will require
(usually 512 bytes) before kevent reports the fd as ready for write.
I couldn't find a reference to which bug this code was trying to look for
and it seems to be there from the beginning of git history so it might be
no longer relevant.
Issue: #548
(cherry picked from commit 1dfec8a97094a26317eac9b3d8a1c16eb1a7dbea)
latest versions of macOS provide pkg-config and libraries for an ancient
version of openssl as part of the system, but no headers
(cherry picked from commit 506df426dbeb0187bbd3654bd286b4100628fb16)
if OpenSSL is in a non standard location, need to pass that information
to any sample that needs it
Closes: #550
(cherry picked from commit 0ec5edde503096a81831f36441a4115574ac45f0)
Detected using ThreadSanitizer, resolved by capturing the value
of ev_res in a local variable while the event is locked, then
passing that captured variable to the callback.
TSAN report:
I0728 14:35:09.822118 WARNING: ThreadSanitizer: data race (pid=815501)
I0728 14:35:09.822186 Write of size 2 at 0x7b2c00001bf2 by thread T80 (mutexes: write M1110835549570434736):
I0728 14:35:09.822248 #0 event_active_nolock_ libevent/event.c:2893:14 (0a2b90577e830d775300664df77d0b91+0x1fdab28)
I0728 14:35:09.822316 #1 event_active libevent/event.c:2858:2 (0a2b90577e830d775300664df77d0b91+0x1fdd10e)
I0728 14:35:09.822379 #2 Envoy::Event::TimerImpl::enableTimer(std::chrono::duration<long, std::ratio<1l, 1000l> > const&) envoy/source/common/event/timer_impl.cc:24:5 (0a2b90577e830d775300664df77d0b91+0x459fa0)
...
I0728 14:35:09.824146 Previous read of size 2 at 0x7b2c00001bf2 by main thread:
I0728 14:35:09.824232 #0 event_process_active_single_queue libevent/event.c:1646:33 (0a2b90577e830d775300664df77d0b91+0x1fdf83d)
I0728 14:35:09.824350 #1 event_process_active libevent/event.c (0a2b90577e830d775300664df77d0b91+0x1fd9ad8)
I0728 14:35:09.824445 #2 event_base_loop libevent/event.c:1961 (0a2b90577e830d775300664df77d0b91+0x1fd9ad8)
I0728 14:35:09.824550 #3 Envoy::Event::DispatcherImpl::run(Envoy::Event::Dispatcher::RunType) envoy/source/common/event/dispatcher_impl.cc:166:3 (0a2b90577e830d775300664df77d0b91+0x4576d9)
...
Fixes: #543 (pull-request)
(cherry picked from commit 27934f0b39991172dcfdad23faea9874dd386f10)
It is a bit confusing to check against the result of EVUTIL_UPCAST(),
because it can return not NULL for NULL pointers, but for even though
with bufferevent we are fine (because bufferevent is the first field in
bufferevent_private), there are no checks for "bufev" in bufferevent's
API, so just remove it to make it generic.
Fixes: #542
Signed-off-by: Ivan Maidanski <i.maidanski@samsung.com>
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
(cherry picked from commit a10a6f4ed918ea1432820d99e9373f37f906d6f0)
"chain" cannot be NULL here because we have at least one chain (we
handle empty buffer separatelly) and hence loop will be executed at
least once.
Link: 841ecbd961 (commitcomment-23631347)
Signed-off-by: Ivan Maidanski <i.maidanski@samsung.com>
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
(cherry picked from commit b26996a05d9e7aad32e78a7bfab6454d5c11500a)
==> win: CMake Warning (dev) at CMakeLists.txt:782 (elseif):
==> win: Policy CMP0054 is not set: Only interpret if() arguments as variables or
==> win: keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
==> win: details. Use the cmake_policy command to set the policy and suppress this
==> win: warning.
==> win:
==> win: Quoted variables like "MSVC" will no longer be dereferenced when the policy
==> win: is set to NEW. Since the policy is not set the OLD behavior will be used.
==> win: This warning is for project developers. Use -Wno-dev to suppress it.
(cherry picked from commit 2773a5ed5e75540d43500e054581ea1fab2132ac)
Because of typo in cmake, now rewrote to make it less error prone (since even
for non-win32 there are variables overlap).
(cherry picked from commit 8b29b136793f3bfdb22fba117527763434363a3f)
Delete the event from the queue before blocking for the current
event callback termination.
Ensures that no callback is being executed when event_del() returns,
hence making this function a secure mechanism to access data which is
handled in the event callack.
Fixes: #236Fixes: #225
Refs: 6b4b77a
Fixes: del_wait
(cherry picked from commit 0b4b0efdb8ee710ccae5bad320fc24843fd428e5)
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
(cherry picked from commit c6c74ce2652fd02527a1212e36cbfd788962132a)
But this is kind of hot-fix, we definitelly need more sane arc4random
compat layer.
Fixes: #488
Introduced-in: 6541168 ("Detect arch4random_addrandom() existence")
(cherry picked from commit 266f43af7798befa3d27bfabaa9ae699259c3924)