1383 Commits

Author SHA1 Message Date
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
Azat Khuzhin
8a34869984 test-ratelim: calculate timers bias (for slow CPUs) to avoid false-positive
This can be/should be done for regression tests too.

Refs: https://ci.appveyor.com/project/libevent/libevent/builds/28916689/job/kg621aa194a0qbym
Refs: https://github.com/libevent/libevent/pull/917#issuecomment-553811834
v2: EVENT_BASE_FLAG_PRECISE_TIMER
2019-11-17 20:52:28 +03:00
Philip Homburg
9fecb59a94 Parse IPv6 scope IDs. 2019-11-06 21:07:16 +03:00
Azat Khuzhin
4436287d12 Relax bufferevent_connect_hostname_emfile
Do not do any assumptions on the error for the EMFILE from
getaddrinfo(), expect just any error.

Fixes: #924
2019-10-31 09:20:49 +03:00
yuangongji
55d60c9258 test: add testcase for evutil_socketpair() 2019-10-19 13:07:04 +08:00
yuangongji
8d5c5650d2 tinytest: support timeout on Windows 2019-09-26 21:54:33 +08:00
yuangongji
6769f692d7 regress_buffer: improve testcase for evbuffer_freeze() 2019-09-22 22:57:21 +08:00
yuangongji
6f970267b6 eliminate some C4267 warnings in Windows 2019-08-28 11:41:53 +08:00
Jan Kasiak
445027a5dc Fix memory corruption in EV_CLOSURE_EVENT_FINALIZE with debug enabled
Call event_debug_note_teardown_ before evcb_evfinalize to avoid possible
UAF (if finalizer free's event).
2019-08-28 01:15:39 +03:00
Jan Kasiak
70daa93a51 test: prevent duplicate event_enable_debug_mode() for TT_ENABLE_DEBUG_MODE 2019-08-28 01:05:03 +03:00
Azat Khuzhin
6186d3126f
test: introduce TT_ENABLE_DEBUG_MODE flag 2019-08-26 22:43:51 +03:00
dota17
9c151f3c34
Fix typos in comments (sample/test/event-internal.h) 2019-08-09 12:34:46 +03:00
Azat Khuzhin
bdcade4722
buffer: fix possible NULL dereference in evbuffer_setcb() on ENOMEM
[ @azat:

  - add return heredoc for evbuffer_setcb()
  - add unit test with event_set_mem_functions()
  - look through the report from abi-compliance-checker/abi-dumper
]

Closes: #855
2019-07-31 10:43:57 +03:00
Azat Khuzhin
538141eb7e
evdns: add new options -- so-rcvbuf/so-sndbuf
This will allow to customize SO_RCVBUF/SO_SNDBUF for nameservers in this
evdns_base, you may want to adjust them if the kernel starts dropping
udp packages.
2019-06-15 23:32:39 +03:00
Azat Khuzhin
51ac04ac62
test: mark bev_connect_hostname() as static (to avoid prototype requirement) 2019-05-25 17:29:55 +03:00
Azat Khuzhin
244cacaf8c
test: regression for evbuffer_expand_fast_() with invalid last_with_datap
Before the fix:
  $ regress --no-fork evbuffer/reserve_invalid_last_with_datap
  evbuffer/empty_chain_expand: [err] ../buffer.c:2138: Assertion chain == buf->first failed in evbuffer_expand_fast_
  Aborted (core dumped)

This is the a shorter version of test from the #806 (with some
comments).
2019-05-16 10:16:21 +03:00
Azat Khuzhin
98ca307749
test: cover adjusting of last_with_datap in evbuffer_prepend()
Before the fix:
  $ regress evbuffer/empty_reference_prepend..
  evbuffer/empty_reference_prepend: [forking]
    FAIL ../test/regress_buffer.c:104: assert(chain == buf->first)
    FAIL ../test/regress_buffer.c:2291: Buffer format invalid
    [empty_reference_prepend FAILED]
  evbuffer/empty_reference_prepend_buffer: [forking] OK
  1/2 TESTS FAILED. (0 skipped)
2019-05-16 10:05:07 +03:00
Joseph Spadavecchia
5e137f3776
Implement bufferevent_socket_connect_hostname_hints()
So that ai_flags (such as AI_ADDRCONFIG) can be specified.

Closes: #193 (cherry-picked with conflicts resolved)
2019-05-13 11:13:04 +03:00
Tobias Stoeckmann
9b2060c97a Added test for evmap slot validations.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2019-04-27 11:47:23 +02:00
Thomas Bernard
8dcb94a4ca
Added http method extending
User can define his own response method by calling
evhttp_set_ext_method_cmp() on the struct http, or
evhttp_connection_set_ext_method_cmp() on the connection.

We expose a new stucture `evhttp_ext_method` which is passed to the
callback if it's set. So any field can be modified, with some exceptions
(in evhttp_method_):

If the cmp function is set, it has the ability to modify method, and
flags. Other fields will be ignored. Flags returned are OR'd with the
current flags.

Based on changes to the #282 from: Mark Ellzey <socket@gmail.com>
2019-04-11 22:48:01 +03:00
Dan Rosen
2f184f8bbf evwatch: Add "prepare" and "check" watchers.
Adds two new callbacks: "prepare" watchers, which fire immediately
before we poll for I/O, and "check" watchers, which fire immediately
after we finish polling and before we process events. This allows other
event loops to be embedded into libevent's, and enables certain
performance monitoring.

Closes: #710
2019-04-03 12:44:50 -04:00
Azat Khuzhin
47d348a631
Disable logging for tests that assume printing warnings
To avoid possible confusion

But there is still one test that has some messages on windows:
  main/methods

Because this test needs >1 of avaiable methods, otherwise it will warn.
2019-04-03 08:00:12 +03:00
Azat Khuzhin
d4c7545017
Remove manually written nmake makefiles (cmake should be used instead)
This nmake stuff is out dated, and nobody wants to support it anyway.
2019-04-03 07:33:09 +03:00