4018 Commits

Author SHA1 Message Date
Azat Khuzhin
f3aa6a47fc
regress_http: basic evhttp_parse_query_str() coverage
(cherry picked from commit d161ec3842259f2896fc9b15a1e4d5a1ed178bb2)
2019-02-02 15:18:00 +03:00
Azat Khuzhin
acf4821d7c
cmake: add various warning flags like autotools has
This is mostly to match autotools and reduce amount mixiing declarations
and code.

Added:
- -Wextra (the same as -W), -Wno-unused-parameter -Wstrict-aliasing
- -fno-strict-aliasing (gcc 2.9.5+)
- -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement (4.0+)
- -Waddress -Wno-unused-function -Wnormalized=id -Woverride-init (4.2+)
- -Wlogical-op (4.5+)

Removed:
- -Wformat (include in -Wall)

Plus use CMAKE_C_COMPILER_ID over CMAKE_COMPILER_IS_GNUCC, as
cmake-variables(7) suggesting, and add common GNUC/CLANG variables.

v2: drop checks for flags, since add_compiler_flags() will check if such
flags exists anyway (but just to note, gcc ignores non existing warning
flags by default).

(cherry picked from commit 8348b41308a7126d009bb6e0b33aa5f465e1dc33)
2019-02-02 15:18:00 +03:00
Azat Khuzhin
bff1423d79
autotools: do not add warnings that is included into -Wall already
Plus remove duplicates

(cherry picked from commit 006c528a21f8beec8993134c12610bd16cde7fff)
2019-02-02 15:18:00 +03:00
Murat Demirten
ba14879661
listener: ipv6only socket bind support
According to RFC3493 and most Linux distributions, default value is to
work in IPv4-mapped mode. If there is a requirement to bind same port
on same ip addresses but different handlers for both IPv4 and IPv6,
it is required to set IPV6_V6ONLY socket option to be sure that the
code works as expected without affected by bindv6only sysctl setting
in system.

See an example working with this patch:
https://gist.github.com/demirten/023008a63cd966e48b0ebcf9af7fc113

Closes: #640 (cherry-pick)
(cherry picked from commit 387d91f9ab95df8ac3d7bb58493310ad4a377dcf)
2019-02-02 15:18:00 +03:00
Azat Khuzhin
b07e43e607
Merge branch 'evutil_found_ifaddr-dev'
* evutil_found_ifaddr-dev:
  Cover evutil_v4addr_is_local_()/evutil_v6addr_is_local_()
  Split evutil_found_ifaddr() into helpers (evutil_v{4,6}addr_is_local())
  Use INADDR_ANY over 0 in evutil_found_ifaddr()
  Replace EVUTIL_V4ADDR_IS_*() macroses with static inline functions
  Filter link-local IPv4 addresses in evutil_found_ifaddr()

(cherry picked from commit b2667b76969c2ea382373f885062b45e82d0ac59)
2019-02-02 15:18:00 +03:00
Azat Khuzhin
cdcfbafe40
Merge branch 'http-request-line-parsing'
* http-request-line-parsing:
  Fix http https_basic/https_filter_basic under valgrind (increase timeout)
  http: cover various non RFC3986 conformant URIs
  http: allow non RFC3986 conformant during parsing request-line (http server)
  http: do not try to parse request-line if we do not have enough bytes
  http: allow trailing spaces (and only them) in request-line (like nginx)
  http: cleanup of the request-line parsing

(cherry picked from commit 0ec12bc84cf09307e01dc3b00d08ac1f816b6ff7)
2019-02-02 15:18:00 +03:00
Azat Khuzhin
698ebed67a
Disable parallel jobs for the osx (due to CPU time deficit) in travis-ci
As you can see right now linux workers has zero failed tests, while osx
workers has 18 failed tests:
  [bufferevent_connect_hostname_emfile FAILED]
  [bufferevent_pair_release_lock FAILED]
  [bufferevent_timeout FAILED]
  [bufferevent_timeout_filter FAILED]
  [bufferevent_timeout_pair FAILED]
  [common_timeout FAILED]
  [del_wait FAILED]
  [immediatesignal FAILED]
  [loopexit FAILED]
  [loopexit_multiple FAILED]
  [monotonic_res FAILED]
  [no_events FAILED]
  [persistent_active_timeout FAILED]
  [persistent_timeout_jump FAILED]
  [signal_switchbase FAILED]
  [signal_while_processing FAILED]
  [simpletimeout FAILED]
  [usleep FAILED]

And this patch should remove from this list time related failures
(though maybe not all of them).

(cherry picked from commit 2f43d1d4091f4f87b8679de4b4967561861141de)
2019-02-02 15:17:59 +03:00
Azat Khuzhin
dd472e7d71
Use matrix.fast_finish for the travis-ci to mark the build ASAP
AFAIR there is shortage of osx workers on travis-ci, IOW builds that
requires them can wait fair amount of time in the queue by just waiting.

Plus linux workers AFAICS can run multiple jobs in parallel (4-5), while
osx does not.

Hence if we do allow failures for osx (and right now they have a lot of
failed tests) let's mark build result based on tests under linux only.

So in a nut shell this will reduce build time from 5 hours to 20-30
minutes.

(cherry picked from commit 5d3e8c15e7482c35ae7c9768f6f61a5e6850c035)
2019-02-02 15:17:59 +03:00
Azat Khuzhin
731053b069
Simplify bufferevent timeout tests to reduce CPU usage in between start/compare
Between start (setting "started_at") and comparing the time when
timeouts triggered with the start (test_timeval_diff_eq), there is too
much various things that can introduce extra delays and eventually could
fail the test on machine with shortage of CPU.

And this is exactly what happend on:
- travis-ci
- #262

Here is a simple reproducer that I came up with for this issue:
  docker run --cpus=0.01 -e LD_LIBRARY_PATH=$PWD/lib -e PATH=/usr/bin:/bin:$PWD/bin -v $PWD:$PWD --rm -it debian:testing regress --no-fork --verbose bufferevent/bufferevent_timeout

Under limited CPU (see reproducer) the test almost always has problems
with that "write_timeout_at" exceed default timeval diff tolerance
(test_timeval_diff_eq() has 50 tolerance), i.e.:
  FAIL ../test/regress_bufferevent.c:1040: assert(labs(timeval_msec_diff(((&started_at)), ((&res1.write_timeout_at))) - (100)) <= 50): 101 vs 50

But under some setup write timeout can even not triggered, and the
reason for this is that we write to the bufferevent 1024*1024 bytes, and
hence if evbuffer_write_iovec() will has some delay after writev() and
not send more then one vector at a time [1], it is pretty simple to
trigger, i.e.:
  FAIL ../test/regress_bufferevent.c:1040: assert(labs(timeval_msec_diff(((&started_at)), ((&res1.write_timeout_at))) - (100)) <= 50): 1540155888478 vs 50

  [1]: https://gist.github.com/azat/b72773dfe7549fed865d439e03de05c1

So this patch just send static small payload for all cases (plus a few
more asserts added).

The outcome of this patch is that all regression tests passed on
travis-ci for linux box [2]. While before it fails almost always [3].
Also reproducer with CPU limiting via docker also survive some
iterations (and strictly speaking it should has less CPU then travis-ci
workers I guess).

  [2]: https://travis-ci.org/azat/libevent/builds/444391481
  [3]: https://travis-ci.org/libevent/libevent/builds/444336505

(cherry picked from commit 6ac8e775bb3cba49c276c90e288554635d38b466)
2019-02-02 15:17:59 +03:00
Bogdan Harjoc
0033f5cc49
evdns: handle NULL filename explicitly
Otherwise we will try to open NULL filename and got EFAULT and anyway
will got the same return code from evdns_base_resolv_conf_parse_impl()

Closes: #680 (cherry-picked)
(cherry picked from commit 3e6553a1808989c15b8dd1945b4707b7d35667ad)
2019-02-02 15:17:59 +03:00
Azat Khuzhin
6e759975b5
Merge branch 'regress-dns-fixes'
* regress-dns-fixes:
  Do not rely on getservbyname() for most of the dns regression tests
  Turn off dns/getaddrinfo_race_gotresolve by default
  Fix an error for debug locking in dns/getaddrinfo_race_gotresolve

(cherry picked from commit bd2184d8d42f721fa523d01b9a9250c75fedb855)
2019-02-02 15:17:59 +03:00
Jiri Luznicky
cdd52e7f81
Fix missing LIST_HEAD
Despite the presence of 'sys/queue.h' in some stdlib implementations
(i.e. uclibc) 'LIST_HEAD' macro can be missing.  This fix defines this
macro in the same manner as was done previously for 'TAILQ_'.

Fixes: #539
Closes: #639 (cherry-picked)
Backport: 2.1.9
(cherry picked from commit 95918754d2ba7e6bffe0fc74bebed60bd917c10c)
2019-02-02 15:17:59 +03:00
Azat Khuzhin
235b55215b
Make cmake's check_const_exists() rely on cache
(cherry picked from commit 4c61a04cd5207f2140b65f955559aa4ffc848e9c)
2019-02-02 15:17:59 +03:00
Azat Khuzhin
3f692fff32
Merge branch 'be-wm-overrun-v2'
* be-wm-overrun-v2:
  Fix hangs due to watermarks overruns in bufferevents implementations
  test: cover watermarks (with some corner cases) in ssl bufferevent

Fixes: #690
(cherry picked from commit 878bb2d3b9484b27594308da1d0d6a7c9bdf6647)
2019-02-02 15:17:59 +03:00
Azat Khuzhin
2594a96ff6
Add -fdiagnostics-color=always for Ninja
(cherry picked from commit cec4a37120b7fe07525018e4415db8adcfba9299)
2019-02-02 15:17:59 +03:00
Azat Khuzhin
e05136c76a
evrpc: avoid NULL dereference on request is not EVHTTP_REQ_POST
Fixes: #660
(cherry picked from commit 8483c5351abdd18766232de8431290165717bd57)
2019-02-02 15:17:59 +03:00
Carlo Marcelo Arenas Belón
7d6c88dd11
test: make sure pthread is defined
avoid warnings with any modern C99 compiler due to implicit function
declaration for pthread_create, as shown by the following :

test/regress_dns.c:2226:2: warning: implicit declaration of function
      'pthread_create' is invalid in C99 [-Wimplicit-function-declaration]
        THREAD_START(thread[0], race_base_run, &rp);
        ^
test/regress_thread.h:35:2: note: expanded from macro 'THREAD_START'
        pthread_create(&(threadvar), NULL, fn, arg)
        ^
test/regress_dns.c:2226:2: warning: this function declaration is not a prototype
      [-Wstrict-prototypes]
test/regress_thread.h:35:2: note: expanded from macro 'THREAD_START'
        pthread_create(&(threadvar), NULL, fn, arg)
        ^

$ clang --version
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Closes: #686 (cherry-picked)
(cherry picked from commit 7af974eeaa7e5cf2f73e3176782c5a788a74f08e)
2019-02-02 15:17:58 +03:00
Azat Khuzhin
6e81eaf235
appveyor: add all build tree into artifacts in case of failure
This will help in investigations of win32 failures...

P.S. looks like there is no better way, since
"artifacts.*.publish_on_failure" hadn't been implemented yet (while was
requiested in 2015).

(cherry picked from commit 29cc8386a2f7911eaa9336692a2c5544d8b4734f)
2019-02-02 15:17:58 +03:00
Bogdan Harjoc
d0cde45477
dns-example: free result in getaddrinfo callback
According to evdns.c, the result not freed by libevent after
the callback runs:

evdns_getaddrinfo_gotresolve()
{
    ...
    data->user_cb(0, data->pending_result, data->user_data);
    data->pending_result = NULL;
    ...
}

To reproduce, build with -fsanitize=address, add -g to the getopt
list in dns-example.c like in the current commit and run

  dns-example -g google.com

Closes: #681 # cherry-picked
(cherry picked from commit 855f0804305a545da6880850d16809969ce72edd)
2019-02-02 15:17:58 +03:00
Philip Prindeville
d6c293af00
Eliminate compiler warnings (at least for gcc/linux)
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Closes: #646 # cherry-picked from the PR
(cherry picked from commit be371163027d3988a30620537bf3fcb81fb7f077)
2019-02-02 15:17:58 +03:00
Azat Khuzhin
3237d6972d
Merge branch 'evdns_getaddrinfo-race-fix'
* evdns_getaddrinfo-race-fix:
  evdns: add regress test for getaddrinfo race
  evdns: fix race condition in evdns_getaddrinfo()

Merges: #673
(cherry picked from commit ee12c516cf5766b2c32203dcc20c32b8691a8ebb)
2019-02-02 15:17:58 +03:00
Azat Khuzhin
b3af7bdde3
Cleanup __func__ detection
First of all __func__ is not a macro, it is char[] array, so the code
that we had before in cmake, was incorrect, i.e.:
  #if defined (__func__)
  #define EVENT____func__ __func__
  #elif defined(__FUNCTION__)
  #define EVENT____func__  __FUNCTION__
  #else
  #define EVENT____func__ __FILE__
  #endif

So just detect do we have __func__/__FUNCTION__ in configure/cmake
before build and define EVENT__HAVE___func__/EVENT__HAVE___FUNCTION__
to use the later to choose which should be used as a __func__ (if it is
not presented).

Closes: #644
(cherry picked from commit e85818d24850540d220e6d7bc0a30653ba2135f2)
2019-02-02 15:17:58 +03:00
Azat Khuzhin
21bfaa702f
Merge branch 'official/pr/671' -- README cleanup
* official/pr/671:
  Capitalise project names consistently in README.md
  Indent configure flag section to make markdown format them as code
  Use https for resources that support it
  Rewords awkward sentences in README.md
  Fix typos in README.md

(cherry picked from commit c3a6fe75e1511a4c7a7a6ef0a5954b1918902933)
2019-02-02 15:17:58 +03:00
Azat Khuzhin
d7579fb958
autotools: include win32 specific headers for socklen_t detection on win32/mingw
The [1] removes EVENT__ prefix, and now if we will incorrectly detect
that "foobar" (or socklen_t in our case) type is not available, but
somewhere later it will be available then we will get next error [2]:
  error: two or more data types in declaration specifiers

According to [3]:
- Compile something in Cygwin and you are compiling it for Cygwin.
- Compile something in MinGW and you are compiling it for Windows.
  And I can confirm this, since there is _WIN32 defined (according to [4])

And since according to [5] our image in appveyour (Visual Studion 2015)
has mingw (and we use it, not cygwin) we need ws2tcpip.h (over
sys/socket.h -- which does not exist in win32) header to detect
socklen_t existence.

[1]: 587e9f5828c4eb3c6e79e9eb29f174e4ae0c05bd ("config.h can't be prefixed unconditionally")
[2]: https://ci.appveyor.com/project/nmathewson/libevent/build/job/yonukoc5q3tr3e5e#L372
[3]: https://stackoverflow.com/questions/771756/what-is-the-difference-between-cygwin-and-mingw
[4]: https://www.appveyor.com/docs/build-environment/#mingw-msys-cygwin
[5]: https://ci.appveyor.com/project/nmathewson/libevent/build/job/yonukoc5q3tr3e5e#L164

Fixes: #649
(cherry picked from commit 4728ffed865985ab663b2e067afb904d124fc1db)
2019-02-02 15:17:58 +03:00
Azat Khuzhin
9bcfcbda95
appveyor: disable almost all configurations (except autotools/cmake basic)
Since we have FREE plan, we have a lot of limits on our builds, so let's
reduce their amount to make them run/start faster (I hope).

(cherry picked from commit bdd531288affe9fa46184bb9b492defbcf379c63)
2019-02-02 15:17:58 +03:00
Xiaozhou Liu
aade513b4e
Fix typo
Closes: #658
(cherry picked from commit 30d77f1b59bcd1433a89e803b9fa045c50883868)
2019-02-02 15:17:58 +03:00
Nathan French
0d5dde5357
[http] fix C90 warnings
(cherry picked from commit 514dc7579c43e673bdf613e01690371438661260)
2019-02-02 15:17:57 +03:00
Philip Prindeville
061823b147
Tell Travis to use quiet git clone
Otherwise the logs show a bunch of pointless progress, which is
really only useful for interactive sessions.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Closes: #651 (cherry-picked)
(cherry picked from commit 24236aed01798303745470e6c498bf606e88724a)
2019-02-02 15:17:57 +03:00
Leo Zhang
780eaac827
test: make regress_dns C89 compatible
Closes: #635 (cherry-picked)
(cherry picked from commit d9ffd2213702bc22c467bd83c230a1a5e97e9e67)
2019-02-02 15:17:57 +03:00
Azat Khuzhin
37423849e6
Ignore evconfig-private.h for autotools
Fixes: e2874d95af584b3657eb5dc1d2e5404811dce117 ("Adopt ignore rules for
cmake + ninja")

(cherry picked from commit 064a598716e69a1ac3937dd1bbc74194d0f3d3cf)
2019-02-02 15:17:57 +03:00
Azat Khuzhin
85fed75f7e
Replace all EVENT_HAVE with EVENT__HAVE (EVENT__HAVE_USLEEP)
(cherry picked from commit 35258a1f4e09d9e7fcb003cd0572343670180495)
2019-02-02 15:17:57 +03:00
Philip Prindeville
06ec5de615
Add convenience macros for user-triggered events
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Closes: #647 (picked)
(cherry picked from commit d2acf67ec3ad2916236396992f094c0c65016028)
2019-02-02 15:17:57 +03:00
Philip Prindeville
8ab60087c3
Get rid of macros which are never used
There are no expansions of these macros or tests for their existence.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
(cherry picked from commit 755896efe25e5caecd498c08cce072c713720783)
2019-02-02 15:17:57 +03:00
an-tao
00761b436d
fix spelling mistakes
Closes: nmathewson/Libevent#162
(cherry picked from commit 0789bc5220af6eaa9b483afcd1405be6f01d2187)
2019-02-02 15:17:57 +03:00
Philip Prindeville
63a054f8c6
config.h can't be prefixed unconditionally
The script make-event-config.sed was mangling all the symbols by
prefixing them with "EVENT__".  The problem here is that some
symbols aren't for local consumption within libevent, but rather
influence other system header files (ex: __USE_FILE_OFFSET64 is
used by dozens of header files including <sys/sendfile.h>).

As a workaround, all symbols starting with a capital letter only
(with the exception of STDC_HEADERS which must also be left
untouched) will be mangled.

Future contributors will need to be aware of this distinction.

(cherry picked from commit 587e9f5828c4eb3c6e79e9eb29f174e4ae0c05bd)
2019-02-02 15:17:57 +03:00
Azat Khuzhin
e2732c9063
Make rpc headers self-compilable
Fixes: #633
(cherry picked from commit c57f5c34903b02c6e7378865f71a2b83a5befb96)
2019-02-02 15:17:57 +03:00
Azat Khuzhin
d9d1c09e25
Notify event base if there are no more events, so it can exit without delay
Fixes: #623
(cherry picked from commit 23c2914f6b430f2c2d74c267c13ffab3dda1b325)
2019-02-02 15:17:56 +03:00
Azat Khuzhin
44fa5b19f7
Fix CheckFunctionExistsEx() cmake macro on win32
For example under mingw64 it could not detect that strtok_r() exists,
because it checks with:
  void *p = func_name;

And for this you need the function to be defined, so just sync our
CheckFunctionExistsEx.c with CheckFunctionExists.c from cmake (and later
we should drop them out) since it does correct things to detech
functions existence.

Also for WIN32 there is -FIwinsock2.h -FIws2tcpip.h, and I guess that is
not works for mingw gcc (since -F in gcc is framework, and in windows
-FI is like -include in gcc). But looks like we do not need them
already (due to fixed CheckFunctionExistsEx()).

Refs: #605
(cherry picked from commit accf383e044257ecdef002ea255056a5d15a4811)
2019-02-02 15:17:56 +03:00
Azat Khuzhin
0d194c4e49
test/dns: install correct RLIMIT_NOFILE in bufferevent_connect_hostname_emfile
Otherwise poll() will fail with EINVAL:
       EINVAL The nfds value exceeds the RLIMIT_NOFILE value.

P.S. and cleanup this test a little, with early-return.

CI: https://travis-ci.org/libevent/libevent/jobs/370350426
(cherry picked from commit d1c8993c3c34030b68ecb6079bd9dce8cb3d3604)
2019-02-02 15:17:56 +03:00
Azat Khuzhin
dfb5fc1675
travis-ci: allow tests under osx to fail (temporary, until we will fix them)
(cherry picked from commit da028dec497722793ada3ce1a0358c1bf68161de)
2019-02-02 15:17:56 +03:00
Azat Khuzhin
61b95600a0
test/http: cover evhttp_connection_get_addr() for incomming connections
Refs: #510
(cherry picked from commit e4edc7fc27bb96b4811f1c24d591f5c5bca69bdd)
2019-02-02 15:17:56 +03:00
Greg Hazel
4215c003f1
Fix evhttp_connection_get_addr() fox incomming http connections
Install conn_address of the bufferevent on incomping http connections
(even though this is kind of subsytem violation, so let's fix it in a
simplest way and thinkg about long-term solution).

Fixes: #510
Closes: #595 (pick)
(cherry picked from commit 367cd9e5c2b8e3f9b8dbed40bfe8a0ed79285c36)
2019-02-02 15:17:56 +03:00
Azat Khuzhin
f3eb294f79
test/dns: verify bufferevent_socket_connect() errorcb invoking if socket() fails
Refs: #600
(cherry picked from commit a3d8f2e09302536c6c0ffc3ccb1fc6f43b51dc4f)
2019-02-02 15:17:56 +03:00
Jesse Fang
1dde74efa8
bufferevent_socket_connect{,_hostname}() missing event callback and use ret code
- When socket() failed in bufferevent_socket_connect() , the event
  callback should be called also in
  bufferevent_socket_connect_hostname().  eg. when use
  bufferevent_socket_connect_hostname() to resolve and connect an IP
  address but process have a smaller ulimit open files, socket() fails
  always but caller is not notified.

- Make bufferevent_socket_connect()'s behavior more consistent: function
  return error then no callback, function return ok then error passed by
  event callback.

Fixes: #597
Closes: #599
Closes: #600
(cherry picked from commit f7bc1337977553f5f966f13840a5f7feba2d0bd5)
2019-02-02 15:17:56 +03:00
Azat Khuzhin
442c7d947f
test/dns: cleanup test_bufferevent_connect_hostname()
(cherry picked from commit 623ef3ccdc0aafac7ae77a723cbad6d552ff9a01)
2019-02-02 15:17:56 +03:00
Azat Khuzhin
7e56c8b2da
Merge branch 'pull-628'
* pull-628:
  Give priority to the build directory headers
  Do not ship evconfig-private.h in dist archive

Closes: #628
(cherry picked from commit a5f19422fdc91cf1e645fc318a174f33f132b9ac)
2019-02-02 15:17:55 +03:00
Azat Khuzhin
3ffa3ca7f7
Adopt ignore rules for cmake + ninja
In case we have build directory differs from source directory there will be
bunch of files we should ignore, so just remove leading "/" for some or rules.
And fix others.

(cherry picked from commit e2874d95af584b3657eb5dc1d2e5404811dce117)
2019-02-02 15:17:55 +03:00
SuckShit
d632610468
Fix assert() condition in evbuffer_drain() for IOCP
In the case of iocp, in the for loop above, there is a situation where:
  remaining == chain->off == 0

And this happens due to CHAIN_PINNED_R() case (that is used only in
buffer_iocp.c)

Closes: #630 (picked)
(cherry picked from commit ab3224c3e66cf92779f8bd91ffe90445e636fa50)
2019-02-02 15:17:55 +03:00
The Gitter Badger
8886eed498
Add Gitter badge
(cherry picked from commit ba78ba9e8ba4c964dd5d14a281d7421c95d37937)
2019-02-02 15:17:55 +03:00
Philip Herron
29590718cf
cmake: ensure windows dll's are installed as well as lib files
Closes: #621
(cherry picked from commit 0fa43c99fbba6f3b1827ada98302f548206a358f)
2019-02-02 15:17:55 +03:00