Fix undefined behaviour and application crash that might take
place in some rare cases after calling evdns_base_free when
there are requests in the waiting queue.
Current cleanup procedure in evdns_base_free_and_unlock
function includes 2 steps:
1. Finish all inflight requests.
2. Finish all waiting requests.
During the first step we iterate over each list in req_heads
structure and finish all requests in these lists. With current
logic finishing an inflight request (function request_finished)
removes it from the inflight requests container and forces
a wating connection to be sent (by calling
evdns_requests_pump_waiting_queue). When these new requests are
sent it is possible that they will be inserted to the list in
req_heads that we've already cleaned.
So in some cases container of the inflight requests is not empty
after this procedure and some requests are not finished and
deleted. When timeouts for these requests expire
evdns_request_timeout_callback is called but corresponding
evdns_base has been already deleted which causes undefined
behaviour and possible applicaton crash.
It is interesting to note that in old versions of libevent such
situation was not possible. This bug was introduced by the commit
14f84bbdc77d90b1d936076661443cdbf516c593. Before this commit
nameservers were deleted before finishing the requests. Therefore
it was not possible that requests from the waiting queue be sent
while we finish the inflight requests.
supposing if base is null, EVBASE_ACQUIRE_LOCK and EVBASE_RELEASE_LOCK
would get a coredump, so we add a guard for protection.
Signed-off-by: chenguolong <cgl.chenguolong@huawei.com>
* github-actions-v2:
travis: disable doxygen and coveralls, in favor of github actions
github actions: test and coverage
github actions: doxygen
Ignore truthy in yamllint (for github-actions)
test: mark common_timeout as retriable
cmake: set rpath for libraries on linux
test-export: compatible with all versions of visual studio
coverage: 'lcov --remove' need full path
Moves the thread into real-time scheduling class, as recommended in [1], it
fixes the separate test provided by @ygj6 [2] everywhere (github actions,
travis-ci, appveyor) under osx.
[1]: https://developer.apple.com/library/archive/technotes/tn2169/_index.html
[2]: dde1a6e4d0
Although even after this changes the following time-related tests failed
on travis-ci:
- no_events
- del_wait
But anyway I guess #940 can be closed, since this fixes the issue in common.
* osx-clock:
test: Use THREAD_* wrappers in del_notify/del_wait
test: move threads created with THREAD_START() to realtime scheduling class too
test: put thread into real time scheduling class on osx for better latencies
Closes: #940
* ci-improvements:
travis-ci: measure build/tests time
travis-ci: drop travis_wait (does not work with sub processes)
cmake: do not print used method (EVENT_SHOW_METHOD) while running tests
cmake: run regress test quietly like autotools (makes CI logs cleaner)
The existing error pages are very basic and don't allow for
multi-lingual support or for conformity with other pages in a web site.
The aim of the callback functionality is to allow custom error pages to
be supported for calls to evhttp_send_error() by both calling
applications and Libevent itself.
A backward-incompatible change has been made to the title of error pages
sent by evhttp_send_error(). The original version of the function used
the reason argument as part of the title. That might have unforeseen
side-effects if it contains HTML tags. Therefore the title has been
changed to always use the standard status text.
An example of the error callback can be found in this
[version](https://github.com/libevent/libevent/files/123607/http-server.zip)
of the 'http-server' sample. It will output error pages with very bright
backgrounds, the error code using a very large font size and the reason.
Closes: #323 (cherr-picked from PR)
After this patchset http-connect works with pproxy [1]:
$ pproxy -l http://:8000/ -vvv &
$ http-connect //127.1:8000 http://kernel.org:80/
[1]: https://pypi.org/project/pproxy/
* http-connect:
http-connect: do not check connection on GET cb
http-connect: set Host header (for CONNECT and GET) (like curl)
http-connect: cleanup and helpers
http: do not close connection for CONNECT
http: do not assume body for CONNECT
Fixes: #946
Use the following for openssl 1.1+:
- X509_getm_notBefore over X509_get_notBefore
- X509_getm_notAfter over X509_get_notAfter
- use OPENSSL_VERSION_NUMBER over SSLeay()
- add missing headers
Refs: openssl/openssl@0b7347effe
After update [1] of the Visual Studio 2019 image cmake unable to find
path to the c compiler [2]:
cmake : CMake Error at CMakeLists.txt:47 (project):
At line:1 char:1
+ cmake -G 'Visual Studio 16 2019' -A x64 ..
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (CMake Error at ...t:47 (project)::String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
The CMAKE_C_COMPILER:
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
is not a full path to an existing compiler tool.
[1]: https://github.com/appveyor/ci/issues/3231https://www.appveyor.com/updates/2019/12/09/
[2]: https://ci.appveyor.com/project/libevent/libevent/builds/29431286/job/a68h7dn9rcride9g
Add support for posix mutex priority inheritance. This is important to
avoid priority inversion in systems running with threads with different
priorities.
Signed-off-by: Andre Azevedo <andre.azevedo@gmail.com>