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>
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>
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>
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>
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>
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>
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>
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>
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
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
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.
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.
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.
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
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).
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.
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
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.
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
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)
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.
* 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
Azat Khuzhin [Sun, 5 Jan 2020 16:02:22 +0000 (19:02 +0300)]
Fix compilation without OPENSSL_API_COMPAT
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
Azat Khuzhin [Tue, 10 Dec 2019 06:25:39 +0000 (09:25 +0300)]
appveyor: switch to Previous Visual Studio 2019 (VS issues after update)
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.
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>
yuangongji [Tue, 22 Oct 2019 14:29:12 +0000 (22:29 +0800)]
appveyor: fix openssl version mismatch warning
yuangongji:
"Many warnings appear when building and running with Visual Studio 2019 in Appveyor:
WARN C:\projects\libevent\test\regress_ssl.c:210: Version mismatch for openssl: compiled with 1000214f but running with 1000212f
Simply add the openssl binary to the "PATH" environment variable to fix it.
I wrote a simple demo to reproduce it: https://github.com/ygj6/verify
I see there are dozens of openssl libraries in the system of appveyor: https://ci.appveyor.com/project/ygj6/verify/builds/28290688
If you do not specify which openssl to use, the system cannot find the correct library."
Azat Khuzhin [Mon, 21 Oct 2019 19:21:19 +0000 (22:21 +0300)]
Merge pull request #915 from ygj6 -- evutil_socketpair win32 fixes
* upstream/pr/915:
appveyor: add vs2019 os to test some new features brought by Win10
test: add testcase for evutil_socketpair()
evutil: make evutil_socketpair() have the same behavior on Windows with build number lower and higher than 17063