]> granicus.if.org Git - libevent/log
libevent
4 years agoInclude details of the ABI compatibility report
Azat Khuzhin [Wed, 6 May 2020 00:03:27 +0000 (03:03 +0300)]
Include details of the ABI compatibility report

4 years agoAdd ABI compatibility report deploy
Azat Khuzhin [Tue, 5 May 2020 23:10:34 +0000 (02:10 +0300)]
Add ABI compatibility report deploy

Closes: #887
4 years agoabi-check: abi-monitor 1.10 does not support -make -j8 (1.12 supports though)
Azat Khuzhin [Tue, 5 May 2020 23:40:49 +0000 (02:40 +0300)]
abi-check: abi-monitor 1.10 does not support -make -j8 (1.12 supports though)

An error for 1.10 on ci:
  https://github.com/azat/libevent/runs/647860649?check_suite_focus=true#step:4:219

4 years agoDo not ignore anything in .github
Azat Khuzhin [Tue, 5 May 2020 23:09:51 +0000 (02:09 +0300)]
Do not ignore anything in .github

Fixes: 28eb0d91 ("github actions looks good - drop travis/appveyor (#951)")
4 years agoAdd API/ABI checker (using LVC)
yuangongji [Wed, 4 Sep 2019 15:09:13 +0000 (23:09 +0800)]
Add API/ABI checker (using LVC)

v2 (by azat):
- drop package installations
- use local .abi-check over $HOME/abi-check for build dir
- drop regex check, simply use default values (too complex otherwise)
- use sub-shell to avoid cd back
- add missing quotes
- make the style uniq across the whole file (no tabs for indent, copy-paste?)
- drop `set -x`, use `bash -x abi-check.sh` over
- drop EVENT_ABI_CHECK
- use /usr/bin/env bash as shebang
- use `find | xargs` over `cp $(grep -v)`
- adjust markdown syntax in abi-check/README.md
- adjust link to the publicly available documentation

v3 (by azat):
- docker image
- git check-ignore
- make -j8
- allow to change defaults

Refs: #887

4 years agoci/linux: add dist check
Azat Khuzhin [Tue, 5 May 2020 12:22:32 +0000 (15:22 +0300)]
ci/linux: add dist check

4 years agoUpdate list of cmake files for autotools dist archive
Azat Khuzhin [Tue, 5 May 2020 13:24:59 +0000 (16:24 +0300)]
Update list of cmake files for autotools dist archive

Fixes: #976
4 years agoci: change cache key for windows/mingw
Azat Khuzhin [Tue, 5 May 2020 11:57:59 +0000 (14:57 +0300)]
ci: change cache key for windows/mingw

Should fix the following current failures:
- 2020-05-04T22:32:02.9490248Z C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(231,5): error MSB6006: "cmd.exe" exited with code 3. [D:\a\libevent\libevent\build\regress.vcxproj]
- cmake : /usr/bin/sh: /C/hostedtoolcache/windows/Python/3.7.6/x64/python.exe: No such file or directory

P.S. I guess python has another path, but on my fork it is the same and
it passes.

4 years agoPass --quiet to the event_rcpgen.py (autotools already does this)
Azat Khuzhin [Tue, 5 May 2020 11:20:09 +0000 (14:20 +0300)]
Pass --quiet to the event_rcpgen.py (autotools already does this)

4 years agoDo not run CI if message contains "ci skip"
Azat Khuzhin [Tue, 5 May 2020 10:57:15 +0000 (13:57 +0300)]
Do not run CI if message contains "ci skip"

https://github.com/marketplace/actions/skip-based-on-commit-message

4 years agoThere is typo in GetAdaptersAddresses windows library. It should be iphlpapi.dll
Aleksandr-Melnikov [Tue, 5 May 2020 09:31:09 +0000 (10:31 +0100)]
There is typo in GetAdaptersAddresses windows library. It should be iphlpapi.dll

4 years agoSupport EV_CLOSED on linux for poll(2)
Azat Khuzhin [Mon, 4 May 2020 22:13:49 +0000 (01:13 +0300)]
Support EV_CLOSED on linux for poll(2)

Refs: #984

4 years agoFix EV_CLOSED detection/reporting (epoll only)
Azat Khuzhin [Mon, 4 May 2020 21:21:18 +0000 (00:21 +0300)]
Fix EV_CLOSED detection/reporting (epoll only)

- EV_CLOSED is EPOLLRDHUP in epoll
- EPOLLRDHUP reported w/o EPOLLHUP if the socket closed with shutdown(SHUT_WR)
- EPOLLRDHUP reported w/  EPOLLHUP if the socket closed with close()
  so in this case epoll backend will detect this event as error
  (EV_READ|EV_WRITE), since the epoll_ctl() will return EPOLLRDHUP with
  EPOLLHUP set, but this is not correct, let's fix this.

Fixes: #984
4 years agoMerge branch 'EV_CLOSED-and-EV_ET-fixes'
Azat Khuzhin [Mon, 4 May 2020 21:05:49 +0000 (00:05 +0300)]
Merge branch 'EV_CLOSED-and-EV_ET-fixes'

* EV_CLOSED-and-EV_ET-fixes:
  Avoid triggering wrong events with EV_ET set
  epoll: handle EV_ET for EV_CLOSED too
  test: cover EV_CLOSED with lots of possible scenarious
  test: rename simpleclose to simpleclose_rw (since it works via write/read)

4 years agoAvoid triggering wrong events with EV_ET set
Azat Khuzhin [Wed, 8 Apr 2020 23:16:15 +0000 (02:16 +0300)]
Avoid triggering wrong events with EV_ET set

For the event at least something except EV_ET should be set, so checking
ev->ev_events with "triggered" events is wrong, because EV_ET is always
passed (see epoll), since it will be filtered out if it is not set in
event.

4 years agoepoll: handle EV_ET for EV_CLOSED too
Azat Khuzhin [Wed, 8 Apr 2020 23:00:17 +0000 (02:00 +0300)]
epoll: handle EV_ET for EV_CLOSED too

4 years agotest: cover EV_CLOSED with lots of possible scenarious
Azat Khuzhin [Wed, 8 Apr 2020 21:30:57 +0000 (00:30 +0300)]
test: cover EV_CLOSED with lots of possible scenarious

- trigger *RDHUP via close() <-- has issues
- trigger *RDHUP via shutdown()
- EV_CLOSED
- EV_CLOSED|EV_PERSIST
- EV_CLOSED|EV_ET <!-- has issues
- EV_CLOSED|EV_ET|EV_PERSIST

4 years agotest: rename simpleclose to simpleclose_rw (since it works via write/read)
Azat Khuzhin [Wed, 8 Apr 2020 21:14:26 +0000 (00:14 +0300)]
test: rename simpleclose to simpleclose_rw (since it works via write/read)

4 years agogithub actions looks good - drop travis/appveyor (#951)
Azat Khuzhin [Mon, 4 May 2020 20:42:22 +0000 (23:42 +0300)]
github actions looks good - drop travis/appveyor (#951)

Actually right now github's VMs is better then travis/appveyor.

4 years agobufferevent: allow setting priority on socket and openssl type
Nicolas J. Bouliane [Sun, 3 May 2020 00:32:10 +0000 (00:32 +0000)]
bufferevent: allow setting priority on socket and openssl type

4 years agocmake: set a default value for LIBEVENT_STATIC_LINK
yuangongji [Fri, 1 May 2020 01:51:29 +0000 (09:51 +0800)]
cmake: set a default value for LIBEVENT_STATIC_LINK

4 years agoevutil_time: improve evutil_gettimeofday on Windows
Nick Grifka [Mon, 27 Apr 2020 22:02:25 +0000 (15:02 -0700)]
evutil_time: improve evutil_gettimeofday on Windows

If present, use GetSystemTimePreciseAsFileTime instead of
GetSystemTimeAsFileTime. Available since Windows 8.

4 years agobench: Allow backend method selection
Nick Grifka [Thu, 16 Apr 2020 19:08:02 +0000 (12:08 -0700)]
bench: Allow backend method selection

-l         list available methods
-m <name>  use method

4 years agocmake: missing test-closed binary
Azat Khuzhin [Tue, 7 Apr 2020 21:29:40 +0000 (00:29 +0300)]
cmake: missing test-closed binary

4 years agoMerge branch 'event_rpcgen.py-cleanup'
Azat Khuzhin [Sat, 28 Mar 2020 13:02:39 +0000 (16:02 +0300)]
Merge branch 'event_rpcgen.py-cleanup'

* event_rpcgen.py-cleanup:
  event_rpcgen.py: fix arguments-differ
  event_rpcgen.py: fix attribute-defined-outside-init
  event_rpcgen: suppress some warnings to make pylint clean
  Don't accumulate arguments in `Entry.GetTranslation`
  Fix improper string concatenations in lists
  Fix warnings regarding unused variables
  Don't override the `type` built-in
  Call `super` to call methods from the parent class
  Address `no-self-use` issues reported by pylint
  Run the code through the black formatter
  Reformat strings to template
  Add `argparse` support
  Precompile regular expressions
  Use bools instead of ints values where possible
  Rename all global variables to match the PEP8 spec
  Handle file pointers with context suite patterns
  Iterate over `tokens` with a for instead of while
  Fix indentation for `RpcGenError`
  Don't override `file` built-in
  Resolve variable name issues per PEP8
  Sort imports per PEP8

4 years agoevent_rpcgen.py: fix arguments-differ
Azat Khuzhin [Sat, 28 Mar 2020 13:01:46 +0000 (16:01 +0300)]
event_rpcgen.py: fix arguments-differ

4 years agoevent_rpcgen.py: fix attribute-defined-outside-init
Azat Khuzhin [Sat, 28 Mar 2020 12:58:57 +0000 (15:58 +0300)]
event_rpcgen.py: fix attribute-defined-outside-init

4 years agoevent_rpcgen: suppress some warnings to make pylint clean
Azat Khuzhin [Sat, 28 Mar 2020 12:58:36 +0000 (15:58 +0300)]
event_rpcgen: suppress some warnings to make pylint clean

4 years agoDon't accumulate arguments in `Entry.GetTranslation`
Enji Cooper [Sat, 28 Mar 2020 00:24:53 +0000 (17:24 -0700)]
Don't accumulate arguments in `Entry.GetTranslation`

Initialize `extradict` safely to avoid accumulating arguments in dict
objects passed in across calls.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoFix improper string concatenations in lists
Enji Cooper [Sat, 28 Mar 2020 00:01:53 +0000 (17:01 -0700)]
Fix improper string concatenations in lists

This change adds commas between elements or explicitly concatenates the
strings, so the values are no longer concatenated by accident.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoFix warnings regarding unused variables
Enji Cooper [Fri, 27 Mar 2020 23:56:16 +0000 (16:56 -0700)]
Fix warnings regarding unused variables

Prefix all unused variables with `_` to mute unused variable warnings
with flake8/pylint.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoDon't override the `type` built-in
Enji Cooper [Fri, 27 Mar 2020 23:45:21 +0000 (16:45 -0700)]
Don't override the `type` built-in

Name the second parameter to `Entry(..)` `ent_type` to avoid overriding
the built-in.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoCall `super` to call methods from the parent class
Enji Cooper [Fri, 27 Mar 2020 23:27:56 +0000 (16:27 -0700)]
Call `super` to call methods from the parent class

Not only does it make it clearer to the reader what the intent is behind
the code, it fixes MRO evaluation of classes if the parent-child
relationship is nonlinear.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoAddress `no-self-use` issues reported by pylint
Enji Cooper [Fri, 27 Mar 2020 23:20:24 +0000 (16:20 -0700)]
Address `no-self-use` issues reported by pylint

Sprinkle around `@staticmethod` where need be and raise
`NotImplementedError` from `Entry.GetInitializer` instead of doing
similar with `assert`. `NotImplementedError` will provide a hint to
static analyzers that there are abstract methods which need to be
implemented, if they aren't, in subclasses.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoRun the code through the black formatter
Enji Cooper [Fri, 27 Mar 2020 23:04:37 +0000 (16:04 -0700)]
Run the code through the black formatter

This resolves a number of flake8 issues as well as pylint issues. Not
all of the changes mesh between flake8/pylint though, so there are some
false positives, but it's better than before.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoReformat strings to template
Enji Cooper [Fri, 27 Mar 2020 22:58:02 +0000 (15:58 -0700)]
Reformat strings to template

This change converts the existing code to use triple-quotes extensively,
in the end-goal of making the code to reformat with black more readable
before and after the change (black messes around with the formatting in
a less than desirable way).

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoAdd `argparse` support
Enji Cooper [Fri, 27 Mar 2020 05:29:43 +0000 (22:29 -0700)]
Add `argparse` support

This change converts raw parsing with `sys.argv` to its equivalent logic
with `argparse`.

It doesn't fully convert over all of the TODO items listed in the
comments, but it does provide some top-level structure which can be used
to drive down further improvements and structure.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoPrecompile regular expressions
Enji Cooper [Fri, 27 Mar 2020 04:02:13 +0000 (21:02 -0700)]
Precompile regular expressions

This change boost performance at scale by pre-compiling regular
expressions in the global space, then reusing them many times within
functions.

This (while not the desired intent of the author) will boost
performance when parsing input.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoUse bools instead of ints values where possible
Enji Cooper [Fri, 27 Mar 2020 02:15:52 +0000 (19:15 -0700)]
Use bools instead of ints values where possible

This is being done to clarify logic and isn't being done for performance
reasons whatsoever, as bools are derived from ints.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoRename all global variables to match the PEP8 spec
Enji Cooper [Fri, 27 Mar 2020 02:05:48 +0000 (19:05 -0700)]
Rename all global variables to match the PEP8 spec

Global variables should be in all caps, as opposed to lowercase.

While here, use named groups for `STRUCT_REF_RE` instead of numbered
groups to make the results and their indented tokens to parse more
intuitive to the end reader.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoHandle file pointers with context suite patterns
Enji Cooper [Fri, 27 Mar 2020 00:37:09 +0000 (17:37 -0700)]
Handle file pointers with context suite patterns

This removes the need for manually calling the file pointer's `.close`
methods directly.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoIterate over `tokens` with a for instead of while
Enji Cooper [Fri, 27 Mar 2020 03:42:40 +0000 (20:42 -0700)]
Iterate over `tokens` with a for instead of while

This simplifies the logic and avoids unnecessary copying/slicing of
array elements in `tokens`.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoFix indentation for `RpcGenError`
Enji Cooper [Fri, 27 Mar 2020 00:28:09 +0000 (17:28 -0700)]
Fix indentation for `RpcGenError`

Indentation for the exception was double what it should have been. This
change normalizes the indentation to a consistent standard with the rest
of the file.

Fix minor flake8 issues while here corresponding to the minimum number
of needed blank lines around the class and its methods.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoDon't override `file` built-in
Enji Cooper [Fri, 27 Mar 2020 00:21:25 +0000 (17:21 -0700)]
Don't override `file` built-in

Use `filep` instead of `file` to clarify the fact that `file` is a file
pointer object.

This mutes warnings on python 2.7 with `pylint`.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoResolve variable name issues per PEP8
Enji Cooper [Fri, 27 Mar 2020 00:13:14 +0000 (17:13 -0700)]
Resolve variable name issues per PEP8

Move all logic under `if __name__ == "__main__"` to a `main(..)`
function.

The purpose of this is to not only address flake8/pylint reported issues
with variable names, but also to enable testing of the function in
isolation to ensure the logic acts as desired.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoSort imports per PEP8
Enji Cooper [Thu, 26 Mar 2020 23:07:17 +0000 (16:07 -0700)]
Sort imports per PEP8

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoMute clang 8 compilation error with gcc pragma
Enji Cooper [Fri, 27 Mar 2020 01:28:07 +0000 (18:28 -0700)]
Mute clang 8 compilation error with gcc pragma

Move the pragma ignoring outside the function to fix the build with gcc.
While here, add equivalent clang pragmas to mute the warning, as well.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
4 years agoMerge #976 -- symbols check build fixes
Azat Khuzhin [Sun, 22 Mar 2020 16:36:45 +0000 (19:36 +0300)]
Merge #976 -- symbols check build fixes

* upstream/pr/976:
  github workflows: ignore previous cache
  github workflows: test for mingw via cmake
  cmake: replace CheckFunctionExists with CheckSymbolExists

4 years agogithub workflows: ignore previous cache
yuangongji [Sun, 22 Mar 2020 10:35:24 +0000 (18:35 +0800)]
github workflows: ignore previous cache

modify the cache key to ignore previous cache
for the changes of configure.ac/CMakeLists.txt
to take effect.

4 years agogithub workflows: test for mingw via cmake
yuangongji [Sun, 22 Mar 2020 05:51:46 +0000 (13:51 +0800)]
github workflows: test for mingw via cmake

4 years agocmake: replace CheckFunctionExists with CheckSymbolExists
yuangongji [Fri, 20 Mar 2020 09:49:37 +0000 (17:49 +0800)]
cmake: replace CheckFunctionExists with CheckSymbolExists

Checking functions with `CheckFunctionExists` may
get wrong results, we should replace it with
`CheckSymbolExists`, which is recommended by the cmake
official documentation.
Before using `CheckSymbolExists`, we use
`CheckIncludeFiles` to check header files and save the
available header files in a variable that guarantees
`CheckSymbolExists` and `CheckTypeSize` to work correctly.
This approach is modeled after the cmake scripts of `curl`.

The following functions or files were not found before
modification, they can now be found:
- msys2 + mingw-8.1.0 on Windows10 or mingw-7.3.0 on Ubuntu-18.04
timerclear
timercmp
timerisset

- windows10
getaddrinfo
getnameinfo
getprotobynumber
getservbyname
putenv
strtoll
timerclear
timercmp
timerisset

- ubuntu-18.04
sys/sysctl.h
timeradd
timerclear
timercmp
timerisset

- MacOS 10.13
sys/random.h
timeradd
timerclear
timercmp
timerisset

4 years agoLibeventConfig.cmake: restore CMAKE_FIND_LIBRARY_SUFFIXES and LIBEVENT_STATIC_LINK...
Mario Emmenlauer [Tue, 3 Mar 2020 18:02:24 +0000 (19:02 +0100)]
LibeventConfig.cmake: restore CMAKE_FIND_LIBRARY_SUFFIXES and LIBEVENT_STATIC_LINK default

The current cmake/LibeventConfig.cmake.in has a few problems and I'm not
sure how cleanly developed it is. It seems rater complex for the little
things I would assume it needs to do.

I found two problems that are fixed in this PR:

- If the downstream user does not explicitly set LIBEVENT_STATIC_LINK
  before calling find_package(libevent) then they will not be able to
  detect the static library, even if its the only one that exists. Since
  this may be rather strict, I've changed the behavior so that
  LIBEVENT_STATIC_LINK can be set to ON or OFF, but if unset, it defaults
  to whatever configuration libevent was built as.

- The other problem is a bug. The package configuration needs to unset
  CMAKE_FIND_LIBRARY_SUFFIXES after use, otherwise all packages that are
  detected after libevent will be "infected" by this setting. This was a
  significant problem for us, and is very hard to detect in downstream
  project, because the order of dependencies will lead to different search
  results.

4 years agoMerge branch 'build-fixes' (#969)
Azat Khuzhin [Tue, 17 Mar 2020 18:45:04 +0000 (21:45 +0300)]
Merge branch 'build-fixes' (#969)

* build-fixes:
  github workflow: fix configure error on mingw-w64
  cmake: fix getaddrinfo checking error
  cmake: remove CheckFunctionExistsEx
  autoconf: fix getaddrinfo checking errors on mingw

4 years agogithub workflow: fix configure error on mingw-w64
yuangongji [Tue, 17 Mar 2020 11:57:10 +0000 (19:57 +0800)]
github workflow: fix configure error on mingw-w64

4 years agocmake: fix getaddrinfo checking error
yuangongji [Mon, 16 Mar 2020 12:11:06 +0000 (20:11 +0800)]
cmake: fix getaddrinfo checking error

Using `CheckFunctionExists` on Windows to check `getaddrinfo`
will get `not found`, but it actually exists. Using `CheckSymbolExists`
with headers will get correct results. Other functions such as
`getnameinfo`,`inet_ntop`,etc. have the same issue.

4 years agocmake: remove CheckFunctionExistsEx
yuangongji [Mon, 16 Mar 2020 10:57:54 +0000 (18:57 +0800)]
cmake: remove CheckFunctionExistsEx

`CheckFunctionExistsEx` is copied from the cmake modules before
3.1.2, which is the minimum required version of libevent.
The internal module `CheckFunctionExists`of cmake can completely
replace it.

4 years agoautoconf: fix getaddrinfo checking errors on mingw
yuangongji [Sat, 14 Mar 2020 03:13:38 +0000 (11:13 +0800)]
autoconf: fix getaddrinfo checking errors on mingw

`AC_CHECK_FUNCS` can not properly check `getaddrinfo` because this
function requires some special headers on mingw.
Using `AC_CHECK_DECL` can effectively solve this issue.

Same for
- getnameinfo
- getprotobynumber
- getservbyname
- inet_ntop
- inet_pton

4 years agoAdd EVENT_BASE_FLAG_EPOLL_DISALLOW_TIMERFD flag (fixes: #958)
Azat Khuzhin [Sun, 1 Mar 2020 13:01:12 +0000 (16:01 +0300)]
Add EVENT_BASE_FLAG_EPOLL_DISALLOW_TIMERFD flag (fixes: #958)

By default we are using CLOCK_MONOTONIC_COARSE, but if
EVENT_BASE_FLAG_PRECISE_TIMER isset, then CLOCK_MONOTONIC will be used,
however this will also enable timerfd, while this is not always what
someone wants, hence add a flag to control this (by default the old
behavior is preserved, set new flag to change it).

4 years agotest-time: do not use deprecated API
Azat Khuzhin [Sun, 1 Mar 2020 12:47:40 +0000 (15:47 +0300)]
test-time: do not use deprecated API

- event_init() -> event_base_new()
- event_set() -> event_new()
- check return value of event_base_dispatch()
- use EXIT_SUCCESS/EXIT_FAILURE

4 years agotest-time: enable debug mode if EVENT_DEBUG_LOGGING_ALL env set
Azat Khuzhin [Sun, 1 Mar 2020 11:54:36 +0000 (14:54 +0300)]
test-time: enable debug mode if EVENT_DEBUG_LOGGING_ALL env set

4 years agoFix typo in thread.h (s/event/evthread)
Azat Khuzhin [Sun, 1 Mar 2020 10:52:32 +0000 (13:52 +0300)]
Fix typo in thread.h (s/event/evthread)

4 years agoincrease segment refcnt only if evbuffer_add_file_segment() succeeds
yuangongji [Sat, 29 Feb 2020 09:47:47 +0000 (17:47 +0800)]
increase segment refcnt only if evbuffer_add_file_segment() succeeds

4 years agoevdns: fix a crash when evdns_base with waiting requests is freed
ayuseleznev [Thu, 27 Feb 2020 13:59:45 +0000 (16:59 +0300)]
evdns: fix a crash when evdns_base with waiting requests is freed

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.

4 years agoevent_base_once: fix potential null pointer threat
chenguolong [Tue, 4 Feb 2020 08:05:02 +0000 (16:05 +0800)]
event_base_once: fix potential null pointer threat

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>
4 years agotest-ratelim: add missing free
yuangongji [Tue, 11 Feb 2020 06:33:15 +0000 (14:33 +0800)]
test-ratelim: add missing free

4 years agomisspelling of output in bufferevent_struct.h
yangyongsheng [Tue, 28 Jan 2020 06:31:39 +0000 (14:31 +0800)]
misspelling of output in bufferevent_struct.h

4 years agoMerge branch 'github-actions-v2' (#951)
Azat Khuzhin [Sun, 26 Jan 2020 22:56:58 +0000 (01:56 +0300)]
Merge branch 'github-actions-v2' (#951)

* 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

4 years agotravis: disable doxygen and coveralls, in favor of github actions
Azat Khuzhin [Sun, 26 Jan 2020 22:53:27 +0000 (01:53 +0300)]
travis: disable doxygen and coveralls, in favor of github actions

4 years agogithub actions: test and coverage
yuangongji [Tue, 21 Jan 2020 11:51:48 +0000 (19:51 +0800)]
github actions: test and coverage

4 years agogithub actions: doxygen
yuangongji [Tue, 21 Jan 2020 02:14:11 +0000 (10:14 +0800)]
github actions: doxygen

4 years agoIgnore truthy in yamllint (for github-actions)
Azat Khuzhin [Sun, 26 Jan 2020 18:30:15 +0000 (21:30 +0300)]
Ignore truthy in yamllint (for github-actions)

4 years agotest: mark common_timeout as retriable
Azat Khuzhin [Thu, 23 Jan 2020 18:34:18 +0000 (21:34 +0300)]
test: mark common_timeout as retriable

Refs: https://github.com/libevent/libevent/pull/951#issuecomment-576711224

4 years agocmake: set rpath for libraries on linux
yuangongji [Mon, 20 Jan 2020 13:17:27 +0000 (21:17 +0800)]
cmake: set rpath for libraries on linux

4 years agotest-export: compatible with all versions of visual studio
yuangongji [Mon, 20 Jan 2020 13:15:26 +0000 (21:15 +0800)]
test-export: compatible with all versions of visual studio

4 years agocoverage: 'lcov --remove' need full path
yuangongji [Tue, 14 Jan 2020 07:54:14 +0000 (15:54 +0800)]
coverage: 'lcov --remove' need full path

4 years agoDo not use shared global structures on CYGWIN
Azat Khuzhin [Tue, 21 Jan 2020 17:10:15 +0000 (20:10 +0300)]
Do not use shared global structures on CYGWIN

Fixes: #950
4 years agoAdd vcpkg installation instructions
JackBoosY [Wed, 22 Jan 2020 06:02:34 +0000 (22:02 -0800)]
Add vcpkg installation instructions

4 years agotest: move thread into realtime class even on EVENT__DISABLE_THREAD_SUPPORT
Azat Khuzhin [Tue, 14 Jan 2020 18:45:01 +0000 (21:45 +0300)]
test: move thread into realtime class even on EVENT__DISABLE_THREAD_SUPPORT

4 years agotest: fix compilation without thread support (EVENT__DISABLE_THREAD_SUPPORT=ON)
Azat Khuzhin [Tue, 14 Jan 2020 07:20:12 +0000 (10:20 +0300)]
test: fix compilation without thread support (EVENT__DISABLE_THREAD_SUPPORT=ON)

4 years agotravis-ci: do not allow failures under osx
Azat Khuzhin [Mon, 13 Jan 2020 23:36:54 +0000 (02:36 +0300)]
travis-ci: do not allow failures under osx

4 years agotest: fix bufferevent/bufferevent_connect_fail_eventcb* under osx/freebsd
Azat Khuzhin [Mon, 13 Jan 2020 23:14:16 +0000 (02:14 +0300)]
test: fix bufferevent/bufferevent_connect_fail_eventcb* under osx/freebsd

For OSX the socket should be closed, otherwise the "connection refused"
will not be triggered.

And freebsd can return error from the connect().

4 years agotest: fix dst thread in move_pthread_to_realtime_scheduling_class (osx)
Azat Khuzhin [Mon, 13 Jan 2020 21:38:06 +0000 (00:38 +0300)]
test: fix dst thread in move_pthread_to_realtime_scheduling_class (osx)

Fixes the following tests on osx:
- del_wait
- no_events

Refs: #940

4 years agotest: fix compilation under win32 (rearrange thread_setup() code)
Azat Khuzhin [Mon, 13 Jan 2020 21:27:21 +0000 (00:27 +0300)]
test: fix compilation under win32 (rearrange thread_setup() code)

4 years agotest: use THREAD_* wrappers over pthread* in del_notify
Azat Khuzhin [Mon, 13 Jan 2020 21:41:48 +0000 (00:41 +0300)]
test: use THREAD_* wrappers over pthread* in del_notify

4 years agoMerge branch 'osx-clock'
Azat Khuzhin [Mon, 13 Jan 2020 20:36:40 +0000 (23:36 +0300)]
Merge branch 'osx-clock'

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]: https://github.com/azat-archive/osx-timers/commit/dde1a6e4d04506d0e0fb193ebb9f49ae25873be6

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
4 years agotest: Use THREAD_* wrappers in del_notify/del_wait
Azat Khuzhin [Mon, 13 Jan 2020 19:24:54 +0000 (22:24 +0300)]
test: Use THREAD_* wrappers in del_notify/del_wait

4 years agotest: move threads created with THREAD_START() to realtime scheduling class too
Azat Khuzhin [Mon, 13 Jan 2020 19:24:54 +0000 (22:24 +0300)]
test: move threads created with THREAD_START() to realtime scheduling class too

4 years agotest: put thread into real time scheduling class on osx for better latencies
Azat Khuzhin [Sun, 12 Jan 2020 21:33:39 +0000 (00:33 +0300)]
test: put thread into real time scheduling class on osx for better latencies

4 years agoMerge branch 'ci-improvements'
Azat Khuzhin [Mon, 13 Jan 2020 19:27:32 +0000 (22:27 +0300)]
Merge branch 'ci-improvements'

* 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)

4 years agotravis-ci: measure build/tests time
Azat Khuzhin [Mon, 13 Jan 2020 19:24:54 +0000 (22:24 +0300)]
travis-ci: measure build/tests time

4 years agotravis-ci: drop travis_wait (does not work with sub processes)
Azat Khuzhin [Mon, 13 Jan 2020 19:24:54 +0000 (22:24 +0300)]
travis-ci: drop travis_wait (does not work with sub processes)

Refs: https://github.com/travis-ci/travis-ci/issues/8526

4 years agocmake: do not print used method (EVENT_SHOW_METHOD) while running tests
Azat Khuzhin [Mon, 13 Jan 2020 19:24:54 +0000 (22:24 +0300)]
cmake: do not print used method (EVENT_SHOW_METHOD) while running tests

autotools don't, plus this will make CI logs cleaner

4 years agocmake: run regress test quietly like autotools (makes CI logs cleaner)
Azat Khuzhin [Mon, 13 Jan 2020 19:24:54 +0000 (22:24 +0300)]
cmake: run regress test quietly like autotools (makes CI logs cleaner)

4 years agoAdd callback support for error pages
nntrab [Tue, 9 Feb 2016 18:01:00 +0000 (18:01 +0000)]
Add callback support for error pages

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)
4 years agoMerge branch 'http-connect'
Azat Khuzhin [Sun, 12 Jan 2020 12:34:51 +0000 (15:34 +0300)]
Merge branch 'http-connect'

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
4 years agohttp-connect: do not check connection on GET cb
Azat Khuzhin [Sun, 12 Jan 2020 12:31:50 +0000 (15:31 +0300)]
http-connect: do not check connection on GET cb

4 years agohttp-connect: set Host header (for CONNECT and GET) (like curl)
Azat Khuzhin [Sun, 12 Jan 2020 12:24:35 +0000 (15:24 +0300)]
http-connect: set Host header (for CONNECT and GET) (like curl)

4 years agohttp-connect: cleanup and helpers
Azat Khuzhin [Sun, 12 Jan 2020 12:14:24 +0000 (15:14 +0300)]
http-connect: cleanup and helpers

4 years agohttp: do not close connection for CONNECT
Azat Khuzhin [Sun, 12 Jan 2020 12:29:48 +0000 (15:29 +0300)]
http: do not close connection for CONNECT

4 years agohttp: do not assume body for CONNECT
Azat Khuzhin [Sun, 12 Jan 2020 10:43:18 +0000 (13:43 +0300)]
http: do not assume body for CONNECT