1305 Commits

Author SHA1 Message Date
Azat Khuzhin
53e53b018b test/regress_buffer.c: fix -Wbad-function-cast (in some specific env)
Fixes: #1054
2020-07-23 00:22:45 +03:00
Azat Khuzhin
1bfbbdf2b4 test: rename ssl/* -> openssl/* 2020-07-22 23:10:26 +03:00
okhowang(王沛文)
028385f685 fix build system and add test and cleanup code 2020-07-22 22:53:23 +03:00
Azat Khuzhin
90bcf2d660 test: fix leak in dns/getaddrinfo_cancel_stress
Some requests may get response (evutil_addrinfo) from gaic_server_cb,
in case of cancel_event (10000ms) will not be fast enough.
2020-07-05 12:16:52 +03:00
Azat Khuzhin
ba19b356bf test: fix UB in evbuffer/empty_reference_prepend_buffer
UBSAN reports:
  test/regress_buffer.c:2360:2: runtime error: null pointer passed as argument 1, which is declared to never be null
  /usr/include/string.h:140:33: note: nonnull attribute specified here
2020-07-05 11:46:22 +03:00
Azat Khuzhin
7b9ba3b717 test: really disable bufferevent_pair_release_lock under ASAN (and fix gcc) 2020-07-05 11:19:10 +03:00
Azat Khuzhin
e2f938c04f test-closed: fix leak 2020-07-05 11:08:05 +03:00
Azat Khuzhin
0ac3cfc0b7 test: add getaddrinfo(AI_ADDRCONFIG) test (off by default) 2020-06-26 11:32:59 +03:00
Azat Khuzhin
ec94a6bb3f test: fix memory leaks for https (add BEV_OPT_CLOSE_ON_FREE)
- http/https_filter_basic
- http/https_filter_chunk_out
2020-06-25 22:57:53 +03:00
Azat Khuzhin
cdbb2373f4 test: "fix" (with a quirk) leak in ssl/bufferevent_wm (w/o defer callbacks) 2020-06-25 22:57:40 +03:00
Azat Khuzhin
3b13a64789 test: disable bufferevent/bufferevent_pair_release_lock under ASAN (too tricky)
And cannot be suppressed with suppressions due to setup routines.
2020-06-25 22:57:40 +03:00
Azat Khuzhin
6754740f15 test: detect test failures if atexit handler calls _exit(!0) (sanitizers)
tinytest uses another way of detecting test failures, it uses pipe
between child and parent, and if the test function in child returns OK
it writes OK flag into pipe, and reads it in parent.

However sanitizers uses atexit handlers to detect leaks, and this will
not detect failures in case of exit() will be called from the atexit
handlers, fix this by checking status after waitpid().
2020-06-25 22:57:40 +03:00
Azat Khuzhin
a0c642ac04 buffer: do not pass NULL to memcpy() from evbuffer_pullup()
UBSAN reports:

  evbuffer/remove_buffer_with_empty3: ../buffer.c:1443:3: runtime error: null pointer passed as argument 2, which is declared to never be null
      #0 0x7ffff6cd0410 in evbuffer_pullup ../buffer.c:1443
      #1 0x5555556d68b9 in test_evbuffer_remove_buffer_with_empty3 ../test/regress_buffer.c:408
      #2 0x5555557b95ee in testcase_run_bare_ ../test/tinytest.c:173
      #3 0x5555557ba048 in testcase_run_one ../test/tinytest.c:333
      #4 0x5555557bc0f8 in tinytest_main ../test/tinytest.c:527
      #5 0x555555787702 in main ../test/regress_main.c:528
      #6 0x7ffff606c001 in __libc_start_main (/usr/lib/libc.so.6+0x27001)
      #7 0x55555569436d in _start (/src/le/libevent/.cmake-debug/bin/regress+0x14036d)
2020-06-25 10:15:01 +03:00
Azat Khuzhin
6f152befb4 test: do not pass NULL to memcmp() in evbuffer_datacmp() helper
Fixes:
  runtime error: null pointer passed as argument 2, which is declared to never be null
2020-06-25 09:59:35 +03:00
Azat Khuzhin
37dbb35080 http: fix undefined-shift in EVUTIL_IS*_ helpers
evutil.c:2559:1: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
    #0 0x4f2be0 in EVUTIL_ISXDIGIT_ libevent/evutil.c:2559:1
    #1 0x4bd689 in regname_ok libevent/http.c:4838:7
    #2 0x4bc16b in parse_authority libevent/http.c:4958:9
    #3 0x4bb8b5 in evhttp_uri_parse_with_flags libevent/http.c:5103:7
    #4 0x4bb762 in evhttp_uri_parse libevent/http.c:5050:9
    #5 0x4b8f41 in evhttp_parse_query_impl libevent/http.c:3505:9
    #6 0x4b8ed7 in evhttp_parse_query libevent/http.c:3569:9

Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23291
Report: https://oss-fuzz.com/testcase-detail/5670743106125824
2020-06-25 09:51:20 +03:00
Azat Khuzhin
2aaa7358a1 test/regress_http: remove second ARRAY_SIZE macros 2020-06-02 10:12:20 +03:00
Azat Khuzhin
8b5a4d61f6 test/regress_testutils: use inet_addr() 2020-06-02 10:01:31 +03:00
Azat Khuzhin
271c5aaa81 test/regress_dns: use tt_int_op() over tt_assert() in assert_request_results() 2020-06-02 10:00:38 +03:00
seleznevae
83c58d4985 evdns: Add support for setting maximum UDP DNS message size.
Added new option `edns-udp-size` for evdns_base which allows
to control maximum allowed size of UDP DNS messages. This
maximum size is passed to the DNS server via edns mechanism.
2020-05-31 19:59:49 +03:00
Azat Khuzhin
7426a568d0 http: Merge branch 'http-max_connections-pr-592'
@jcoffland:

  "When the max connection limit is enabled and the limit is reached, the
   server will respond immediately with 503 Service Unavailable. This can
   be used to prevent servers from running out of file descriptors. This is
   better than request limiting because clients may make more than one
   request over a single connection. Blocking a request does not
   necessarily close the connection and free up a socket."

* http-max_connections-pr-592:
  test: cover evhttp max connections
  Added evhttp max simultaneous connection limiting
2020-05-25 11:25:18 +03:00
Azat Khuzhin
95c1c200c1 test: cover evhttp max connections 2020-05-25 11:24:29 +03:00
Azat Khuzhin
028842aacb Merge branch 'evdns-tcp-pr-1004'
@seleznevae:

  "Added support for DNS requests via TCP. By default, requests are done
   via UDP. In case truncated response is received new attempt is done
   via TCP connection. Added 2 new macros DNS_QUERY_USEVC and
   DNS_QUERY_IGNTC to force all requests to be done via TCP and to disable
   switch to TCP in case of truncated responses.

   Also added possibility for DNS server to listen and receive requests on
   TCP port. Current implementation of TCP support in DNS server seems
   rather preliminary and maybe changes after discussion and code review.

   Fallback to TCP in case of truncated DNS requests is done automatically.
   To imitate the old behaviour macros DNS_QUERY_IGNTC should be used. To
   force all DNS requests to be done via TCP one should use the flag
   DNS_QUERY_USEVC. Names DNS_QUERY_IGNTC, DNS_QUERY_USEVC were chosen to
   imitate similar flags in c-ares and glibc."

Ok, interfaces looks good, merging to avoid stalling it for too long.

* evdns-tcp-pr-1004:
  evdns: fix coding style issues
  evdns: fix trailing whitespaces
  evdns: bufferevent_setcb before bufferevent_free is redundant
  evdns: Implement dns requests via tcp
2020-05-25 03:14:26 +03:00
Azat Khuzhin
e8c8951029 test: http/autofree_connection cleanup 2020-05-25 02:07:44 +03:00
ayuseleznev
0f6ee89a39 evdns: Implement dns requests via tcp 2020-05-21 12:46:20 +03:00
Azat Khuzhin
70f69194eb test: cleanup http/autofree_connection 2020-05-19 01:06:12 +03:00
Azat Khuzhin
1cc94feab8 test: fix http/autofree_connection
Refs: #182
2020-05-19 01:06:02 +03:00
ayuseleznev
8fe35c7614 evdns: Add additional validation for values of dns options 2020-05-18 14:31:49 +03:00
Nick Grifka
83ef3216e4 Add wepoll support to light up the epoll backend on Windows
libevent is lacking a scalable backend on Windows. Let's leverage the wepoll
library until Windows comes up with an epoll/kqueue compete user mode API.

- All regress tests pass for standard wepoll
- These 2 tests fail intermittently for changelist wepoll, so disabling
  changelist wepoll for now
     http/cancel_inactive_server
     http/stream_in
- verify target on Windows runs tests for both wepoll and win32 backends
- wepoll backend preferred over win32 backend
- wepoll version 1.5.6

v2: cleaner backend abstraction. Disallow wepoll on MinGW/Cygwin.
v3: Add wepoll.h to dist
v4: Make sure wepoll source files are excluded from cygwin/mingw builds
v5: Keep win32 as default backend on windows.
v6: Include wepoll in mingw builds. Verified that regress tests pass w/ WEPOLL backend.
v7: Enable wepoll on mingw when building with cmake
v8: Add wepoll testrunner for autotools test target
2020-05-08 23:27:04 +03:00
Nick Grifka
06a1192951 test: Fix test_simpleclose for Windows platform
Replace close with evutil_closesocket
Caught with PR #1006
2020-05-07 21:14:13 -07:00
Azat Khuzhin
972b456bf6 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
2020-05-05 00:25:23 +03:00
Azat Khuzhin
ecb67f6189 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
2020-05-04 23:58:28 +03:00
Azat Khuzhin
c81362b2ec test: rename simpleclose to simpleclose_rw (since it works via write/read) 2020-05-04 23:58:28 +03:00
Nick Grifka
5caffa7a5b bench: Allow backend method selection
-l         list available methods
-m <name>  use method
2020-04-27 10:03:28 -07:00
Azat Khuzhin
4e5a41ca0f 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
2020-03-01 16:42:16 +03:00
Azat Khuzhin
a11edbfa36 test-time: enable debug mode if EVENT_DEBUG_LOGGING_ALL env set 2020-03-01 14:54:36 +03:00
ayuseleznev
4da9f87ccb 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.
2020-02-28 15:06:24 +03:00
yuangongji
5fbe6313ae test-ratelim: add missing free 2020-02-12 22:10:31 +08:00
Azat Khuzhin
f6d7992b05 test: mark common_timeout as retriable
Refs: https://github.com/libevent/libevent/pull/951#issuecomment-576711224
2020-01-24 07:52:06 +03:00
Azat Khuzhin
ca2b72c546 test: move thread into realtime class even on EVENT__DISABLE_THREAD_SUPPORT 2020-01-14 21:58:16 +03:00
Azat Khuzhin
d0adbc0565 test: fix compilation without thread support (EVENT__DISABLE_THREAD_SUPPORT=ON) 2020-01-14 10:20:27 +03:00
Azat Khuzhin
30fe125041 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().
2020-01-14 02:36:39 +03:00
Azat Khuzhin
10504fcab9 test: fix dst thread in move_pthread_to_realtime_scheduling_class (osx)
Fixes the following tests on osx:
- del_wait
- no_events

Refs: #940
2020-01-14 02:07:22 +03:00
Azat Khuzhin
34d51e1bc9 test: fix compilation under win32 (rearrange thread_setup() code) 2020-01-14 01:44:06 +03:00
Azat Khuzhin
391003e9b7 test: use THREAD_* wrappers over pthread* in del_notify 2020-01-14 00:42:13 +03:00
Azat Khuzhin
4b72024b7f test: Use THREAD_* wrappers in del_notify/del_wait 2020-01-13 23:36:19 +03:00
Azat Khuzhin
e6285eed62 test: move threads created with THREAD_START() to realtime scheduling class too 2020-01-13 23:36:19 +03:00
Azat Khuzhin
b1e46c32db test: put thread into real time scheduling class on osx for better latencies 2020-01-13 23:36:19 +03:00
nntrab
02905413fd 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)
2020-01-13 00:50:14 +03:00
Azat Khuzhin
08981f8d75 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

Refs: openssl/openssl@0b7347effe
2020-01-07 22:15:08 +03:00
Andre Pereira Azevedo Pinto
f76456b0dc Add support for priority inheritance
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>
2019-12-09 14:55:31 -08:00