3977 Commits

Author SHA1 Message Date
Azat Khuzhin
b94d913d90
http: allow non RFC3986 conformant during parsing request-line (http server)
Reported-by: lsdyst@163.com
2018-10-23 00:12:03 +03:00
Azat Khuzhin
64ead341a0
http: do not try to parse request-line if we do not have enough bytes 2018-10-22 23:56:50 +03:00
Azat Khuzhin
254fbc81b4
http: allow trailing spaces (and only them) in request-line (like nginx) 2018-10-22 23:56:31 +03:00
Azat Khuzhin
6cf659b0bd
http: cleanup of the request-line parsing 2018-10-22 23:55:35 +03:00
Azat Khuzhin
2f43d1d409
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).
2018-10-22 01:11:03 +03:00
Azat Khuzhin
5d3e8c15e7
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.
2018-10-22 01:10:17 +03:00
Azat Khuzhin
6ac8e775bb
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
2018-10-22 00:53:07 +03:00
Bogdan Harjoc
3e6553a180
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)
2018-10-21 14:28:59 +03:00
Azat Khuzhin
fb090aa622
Revert "travis-ci: use travis_retry to reduce number of problems with flacky tests"
That was a bad idea, because all this patch did is just uses extra CPU
time on travis-ci workers and eventually fail the build anyway.

It also increases time of executing one matrix entry (x3).

This reverts commit 7004ee8e869faabe3a284fb3d7eb859fb50ef90c.
2018-10-21 03:19:53 +03:00
Azat Khuzhin
bd2184d8d4
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
2018-10-21 03:15:34 +03:00
Azat Khuzhin
2cb8eae795
Do not rely on getservbyname() for most of the dns regression tests
There is only one test that uses service name getaddrinfo_async, which
manually check whether it works or not, other should not assume that it
is available and works.

There was already an attempt to overcome some possible limitations, like
lack of "http" in /etc/services in
d6bafbbeb27ff3943d6f3b6783bcded76384c31e ("test/dns: replace servname
since solaris does not have "http"")
2018-10-21 03:12:24 +03:00
Azat Khuzhin
7198bbb8f1
Turn off dns/getaddrinfo_race_gotresolve by default
It is:
- pretty internal regression
- CPU bound
- right now failed on travis-ci machines
2018-10-21 03:11:00 +03:00
Azat Khuzhin
09c74f7121
Fix an error for debug locking in dns/getaddrinfo_race_gotresolve
When there is no /etc/services file evdns_getaddrinfo() will fail (with
service="ssh") and hence it will go to then "end" label with locked
rp.lock which in case of debug locking checks will bail with:
  [err] ../evthread.c:220: Assertion lock->count == 0 failed in debug_lock_free

So add rp.locked flag, and unlock the lock before freeing it if it is in
locked state.

And here is how you can reproduce the issue:
  $ docker run -e LD_LIBRARY_PATH=$PWD/lib -e PATH=/usr/bin:/bin:$PWD/bin -v $PWD:$PWD --rm -it debian:testing regress dns/getaddrinfo_race_gotresolve
(since debian:testing does not have /etc/services)
2018-10-21 03:10:12 +03:00
Jiri Luznicky
95918754d2
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
2018-10-20 03:05:53 +03:00
Azat Khuzhin
4c61a04cd5
Make cmake's check_const_exists() rely on cache 2018-10-18 23:16:05 +03:00
Azat Khuzhin
878bb2d3b9
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
2018-10-17 23:21:32 +03:00
Azat Khuzhin
5a455acd3b
Fix hangs due to watermarks overruns in bufferevents implementations
Some implementations of bufferevents (for example openssl) can overrun
read high watermark.
And after this if user callback will not drain enough data it will be
suspended (i.e. it will not be runned again anymore).
This is not the expecting behaviour as one may guess, since in this case
the data will never be read. Hence once we detected that the watermark
exceeded (even after calling user callback) we will schedule the
callback again.

This also can be fixed in bufferevent openssl implementation (by
strictly limiting how much data is added to the read buffer according to
read high watermark), but since this data is already available (and in
memory) there is no point in doing so.
2018-10-17 23:21:17 +03:00
Azat Khuzhin
a5b2ed56c3
test: cover watermarks (with some corner cases) in ssl bufferevent 2018-10-17 11:23:51 +03:00
Azat Khuzhin
cec4a37120
Add -fdiagnostics-color=always for Ninja 2018-10-17 11:16:16 +03:00
Azat Khuzhin
8483c5351a
evrpc: avoid NULL dereference on request is not EVHTTP_REQ_POST
Fixes: #660
2018-09-14 02:27:13 +03:00
Carlo Marcelo Arenas Belón
7af974eeaa
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)
2018-09-14 02:17:45 +03:00
Azat Khuzhin
29cc8386a2
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).
2018-08-19 00:54:11 +03:00
Bogdan Harjoc
855f080430
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
2018-08-17 03:22:28 +03:00
Philip Prindeville
be37116302
Eliminate compiler warnings (at least for gcc/linux)
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Closes: #646 # cherry-picked from the PR
2018-08-17 03:21:49 +03:00
Azat Khuzhin
ee12c516cf
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
2018-08-02 09:29:29 +03:00
Sergey Fionov
4802c132a2
evdns: add regress test for getaddrinfo race 2018-08-02 09:26:51 +03:00
Sergey Fionov
b59525ece4
evdns: fix race condition in evdns_getaddrinfo()
evdns_getaddrinfo() starts two parallel requests for A and AAAA record.
But if request is created from thread different from dns_base's, request of A record is
started immediately and may result in calling free_getaddrinfo_request() from
evdns_getaddrinfo_gotresolve() because `other_req' doesn't exist yet.

After that, request of AAAA record starts and finishes, and evdns_getaddrinfo_gotresolve()
is called again for structure that is already freed.

This commits adds locking into evdns_getaddrinfo() function.
2018-08-02 09:23:30 +03:00
Azat Khuzhin
e85818d248
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
2018-08-02 02:50:48 +03:00
Azat Khuzhin
c3a6fe75e1
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
2018-08-01 09:48:42 +03:00
Azat Khuzhin
4728ffed86
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
2018-08-01 09:30:54 +03:00
Aapeli
ee0c57993f
Capitalise project names consistently in README.md 2018-08-01 10:29:43 +10:00
Aapeli
72426ff433
Indent configure flag section to make markdown format them as code 2018-08-01 10:24:50 +10:00
Aapeli
a52bd1e37f
Use https for resources that support it 2018-08-01 10:21:57 +10:00
Aapeli
560d4f3296
Rewords awkward sentences in README.md 2018-08-01 10:20:28 +10:00
Aapeli
e5816df59e
Fix typos in README.md 2018-08-01 10:17:42 +10:00
Azat Khuzhin
bdd531288a
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).
2018-08-01 03:05:06 +03:00
Azat Khuzhin
0f04e9a401
vagrant/win32: reduce amount of threads
Otherwise I got:
    win:     855 [main] sh 840 fork: child -1 - CreateProcessW failed for 'C:\tools\cygwin\bin\sh.exe', errno 5
    win: /bin/sh: /usr/bin/sed: Input/output error
    win: /bin/sh: line 1: /bin/sh: Input/output error
    win:   CC       bufferevent_pair.lo
    win: /bin/sh: fork: Input/output error
    win: make[1]: *** [Makefile:1722: buffer.lo] Error 126
    win: make[1]: *** Waiting for unfinished jobs....
    win:   CC       bufferevent_ratelim.lo
    win:     176 [main] sh 2440 fork: child -1 - CreateProcessW failed for 'C:\tools\cygwin\bin\sh.exe', errno 5
    win: /bin/sh: fork: Input/output error
    win:       0 [main] sh 3684 fork: child -1 - CreateProcessW failed for 'C:\tools\cygwin\bin\sh.exe', errno 5
    win: ./libtool: fork: Input/output error
    win: make[1]: *** [Makefile:1722: bufferevent_filter.lo] Error 254
    win:       0 [main] sh 1356 fork: child -1 - CreateProcessW failed for 'C:\tools\cygwin\bin\sh.exe', errno 5
    win: ./libtool: fork: Input/output error
    win:       0 [main] sh 3640 fork: child -1 - CreateProcessW failed for 'C:\tools\cygwin\bin\sh.exe', errno 5
    win: ./libtool: line 922: /usr/bin/sed: Input/output error
    win: ./libtool: fork: Input/output error
    win:       0 [main] sh 3444 fork: child -1 - CreateProcessW failed for 'C:\tools\cygwin\bin\sh.exe', errno 5
    win:       0 [main] sh 3796 fork: child -1 - CreateProcessW failed for 'C:\tools\cygwin\bin\sh.exe', errno 5
    win: ./libtool: fork: Input/output error
    win:     693 [main] sh 304 fork: child -1 - CreateProcessW failed for 'C:\tools\cygwin\bin\sh.exe', errno 5
    win: ./libtool: fork: Input/output error
    win: ./libtool: fork: Input/output error
    win: ./libtool: line 1377: /usr/bin/sed: Input/output error
    win: :   error: Failed to create '.libs'
2018-08-01 00:44:58 +03:00
Azat Khuzhin
9cd279c753
vagrant/win32: add missing aclocal 2018-08-01 00:28:48 +03:00
Xiaozhou Liu
30d77f1b59
Fix typo
Closes: #658
2018-07-30 00:50:32 +03:00
Nathan French
514dc7579c
[http] fix C90 warnings 2018-07-05 12:46:51 -04:00
Philip Prindeville
24236aed01
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)
2018-06-21 10:05:24 +03:00
Leo Zhang
d9ffd22137
test: make regress_dns C89 compatible
Closes: #635 (cherry-picked)
2018-06-21 03:07:55 +03:00
Azat Khuzhin
064a598716
Ignore evconfig-private.h for autotools
Fixes: e2874d95af584b3657eb5dc1d2e5404811dce117 ("Adopt ignore rules for
cmake + ninja")
2018-06-21 02:38:44 +03:00
Azat Khuzhin
35258a1f4e
Replace all EVENT_HAVE with EVENT__HAVE (EVENT__HAVE_USLEEP) 2018-06-19 10:19:40 +03:00
Philip Prindeville
d2acf67ec3
Add convenience macros for user-triggered events
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Closes: #647 (picked)
2018-06-18 03:13:12 +03:00
Philip Prindeville
755896efe2 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>
2018-06-16 17:04:05 -06:00
an-tao
0789bc5220
fix spelling mistakes
Closes: nmathewson/Libevent#162
2018-06-08 02:23:40 +03:00
Philip Prindeville
587e9f5828
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.
2018-06-08 02:14:38 +03:00
Azat Khuzhin
c57f5c3490 Make rpc headers self-compilable
Fixes: #633
2018-05-07 02:40:16 +03:00
Nathan French
1619cc35e4
Merge pull request #632 from NathanFrench/realign_struct_event
Reorder fields in struct event for memory efficiency
2018-05-02 19:34:04 -04:00