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>
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>
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>
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>
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>
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>
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>
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>
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>
* upstream/pr/976:
github workflows: ignore previous cache
github workflows: test for mingw via cmake
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
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.
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.
`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.
`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
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).
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