4139 Commits

Author SHA1 Message Date
Azat Khuzhin
991f0ed3d8
evdns: do not check server_req twice
Reported by µchex:
  "In evdns.c, pointer server_req is null checked on line 1289 after it
is dereferenced above. Since server_req was already null checked above
on line 1243, there is no risk of crashing and the only bug is the
redundant null check (and indentation) on line 1289.
"
2019-04-01 02:42:30 +03:00
Azat Khuzhin
7a8cc11406
evrpc: do not check req twice
reported by µchex:
  "In evrpc.c, pointer req is dereferenced on line 881 before it is null
checked on line 894."
2019-04-01 02:42:07 +03:00
Azat Khuzhin
e5b8f4c192
evdns: add DNS_OPTION_NAMESERVERS_NO_DEFAULT/EVDNS_BASE_NAMESERVERS_NO_DEFAULT
- DNS_OPTION_NAMESERVERS_NO_DEFAULT
  Do not "default" nameserver (i.e. "127.0.0.1:53") if there is no nameservers
  in resolv.conf, (iff DNS_OPTION_NAMESERVERS is set)

- EVDNS_BASE_NAMESERVERS_NO_DEFAULT
  If EVDNS_BASE_INITIALIZE_NAMESERVERS isset, do not add default
  nameserver if there are no nameservers in resolv.conf (just set
  DNS_OPTION_NAMESERVERS_NO_DEFAULT internally)

Fixes: #569
2019-04-01 02:18:59 +03:00
Azat Khuzhin
3e0dc1a6ab
evdns: add descriptions for DNS_OPTION_*/DNS_OPTIONS_ALL 2019-04-01 01:41:10 +03:00
Azat Khuzhin
2ae875ed12
Link test/regress with event_core/event_extra over event
Due to regress linked with event and event_core (both of them includes
evthread.c) there will be two different evthread_id_fn_ variables under
mingw64:
  evthread_id_fn_: &0x5294f20a8
  evthread_id_fn_: &0x4ba0030a8

And because of this evthread_use_pthreads() can/will set one copy of
variables while evthread*() functions will access another, which will
break a lot of things (for example main/del_notify test).

Fixes: #792
2019-03-25 09:54:32 +03:00
Azat Khuzhin
b8e2f01690
signal: guard __cdecl definition with #ifdef
Under mingw64:
  ../signal.c:88:0: warning: "__cdecl" redefined
   #define __cdecl

  <built-in>: note: this is the location of the previous definition

https://ci.appveyor.com/project/azat/libevent/builds/23321613#L427
2019-03-25 09:48:40 +03:00
Azat Khuzhin
8a674243b4
tinytest: fix parsing --timeout argument
Fixes: 15b2f41d ("tinytest: implement per-test timeout (via alarm() under !win32 only)")
2019-03-24 20:39:20 +03:00
Azat Khuzhin
15b2f41d74
tinytest: implement per-test timeout (via alarm() under !win32 only) 2019-03-24 16:56:01 +03:00
Azat Khuzhin
1f4f8769c4
Merge branch 'buffer-read-size'
And after this patch set default evbuffer max read via bufferevent is
16K not 4K.

Here is some numbers for the single max read in evbuffer impact:
  function client() { becat "$@" | pv > /dev/null; }
  function server() { cat /dev/zero | becat -l "$@"; }

Plain bufferevent:

- 40K
  $ server -R $((40<<10)) & client -R $((40<<10))
  700MiB/s

- 16K *default now*
  $ server & client
  1.81GiB/s

- 4K
  $ server -R $((4<<10)) & client -R $((4<<10))
  1.05GiB/s

With OpenSSL (-S):

- 40K *default now*
  $ server -S -R $((40<<10)) & client -S -R $((40<<10))
  900MiB/s

- 16K *default now*
  $ server -S & client -S
  745MiB/s

- 4K
  $ server -S -R $((4<<10)) & client -S -R $((4<<10))
  593MiB/s

So as you can see without openssl 16K is faster then 40K/4K, while for
openssl 40K is still faster then 16K (I guess that this is due to with
openssl SSL_read() more at at time, while with plain we have some
allocations splits in evbuffer and maybe due to some buffer in openssl)

* buffer-read-size:
  sample/becat: bufferevent cat, ncat/nc/telnet analog
  Adjust evbuffer max read for bufferevents
  Maximum evbuffer read configuration
  Fix leaks in error path of the bufferevent_init_common_()
2019-03-16 17:55:27 +03:00
Azat Khuzhin
d5b24cc0c8
sample/becat: bufferevent cat, ncat/nc/telnet analog 2019-03-16 17:40:20 +03:00
Azat Khuzhin
5357c3d62a
Adjust evbuffer max read for bufferevents 2019-03-16 17:33:27 +03:00
Azat Khuzhin
8c2001e92a
Maximum evbuffer read configuration
Before this patch evbuffer always reads 4K at a time, while this is fine
most of time you can find an example when this will decrease throughput.

So add an API to change default limit:
- evbuffer_set_max_read()
- evbuffer_get_max_read()

And a notice that most of time default is sane.
2019-03-16 17:30:15 +03:00
Azat Khuzhin
6995b9a864
Fix leaks in error path of the bufferevent_init_common_() 2019-03-16 17:30:15 +03:00
Azat Khuzhin
efcc18442b
bench: suppress int conversion warnings 2019-03-16 16:52:05 +03:00
Azat Khuzhin
61e4a651d7
Suppress int conversion warnings in getopt_long compatibility 2019-03-16 16:37:56 +03:00
Alexander Drozdov
68eb526d7b http: add WebDAV methods support
WebDAV introduced new HTTP methods (RFC4918):
PROPFIND, PROPPATCH, MKCOL, LOCK, UNLOCK, COPY, MOVE.

Add support of the methods.
2019-03-14 11:12:46 +03:00
Azat Khuzhin
bf19462a55
http: suppress -Wwrite-string in evhttp_parse_query_impl() 2019-03-13 00:21:38 +03:00
Azat Khuzhin
42d5a36bd8
cmake: sync warnings with autotools v2
By some reason gcc reports next error:
  ../http.c:3330:11: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
       value = "";

Only under -Wwrite-strings, well this is logical, but this information
does not reflected in any documentation.

Follow-up: 8348b413 ("cmake: add various warning flags like autotools has")

f
2019-03-13 00:21:38 +03:00
Sayan Nandan
42cc731b1a
Update documentation [ci skip]
The documentation for building and installing has been moved into a new
Documentation section

Closes: #788 (cherry-picked)
2019-03-11 20:11:44 +03:00
Sayan Nandan
56c9551e2d
Move list of contributors into separate file
Closes: #786 (cherry-picked)
2019-03-08 15:13:19 +03:00
Azat Khuzhin
5ee507c889
http: implement separate timeouts for read/write/connect phase
This patch allows to change timeout for next events read/write/connect
separatelly, using new API:

- client:
  evhttp_connection_set_connect_timeout_tv() -- for connect
  evhttp_connection_set_read_timeout_tv()    -- for read
  evhttp_connection_set_write_timeout_tv()   -- for write

- server:
  evhttp_set_read_timeout_tv()  -- for read
  evhttp_set_write_timeout_tv() -- for write

It also changes a logic a little, before there was next fallbacks which
does not handled in new API:
- HTTP_CONNECT_TIMEOUT
- HTTP_WRITE_TIMEOUT
- HTTP_READ_TIMEOUT

And introduce another internal flag (EVHTTP_CON_TIMEOUT_ADJUSTED) that
will be used in evrpc, which adjust evhttp_connection timeout only if it
is not default.

Fixes: #692
Fixes: #715
2019-03-05 00:33:46 +03:00
John Ohl
62df1301ca
Add support for EV_TIMEOUT to event_base_active_by_fd
Closes: #194 (cherry-pick)
2019-03-03 23:42:03 +03:00
Azat Khuzhin
c4fbae3ae6
buffer: make evbuffer_prepend() of zero-length array no-op
Refs: #774
2019-03-03 19:05:54 +03:00
Azat Khuzhin
b69524c004
Merge branch 'evbuffer-empty-chain-handling'
* evbuffer-empty-chain-handling:
  buffer: do not rely on ->off in advance_last_with_data()
  buffer: fix evbuffer_remove_buffer() with empty chain in front
  test: verify content of the buffer in evbuffer/remove_buffer_with_empty*
2019-03-03 18:58:57 +03:00
Azat Khuzhin
5b19c9f62b
buffer: do not rely on ->off in advance_last_with_data()
advance_last_with_data() adjusts evbuffer.last_with_datap, and if we
will have empty chain in the middle advance_last_with_data() will stop,
while it should not, since while empty chains is not regular thing they
can pops up in various places like, and while I did not look through all
of them the most tricky I would say is:
  evbuffer_reverse_space()/evbuffer_commit_space()
  evbuffer_add_reference()

Test case from:
  https://github.com/envoyproxy/envoy/pull/6062

Fixes: #778

v2: keep last_with_datap really last with data, i.e. update only if
chain has data in it
2019-03-03 18:55:25 +03:00
Azat Khuzhin
fdfabbec00
buffer: fix evbuffer_remove_buffer() with empty chain in front
In case we have empty chain (chain that do not have any data, i.e. ->off
== 0) at the beginning of the buffer, and no more full chains to move to
the dst, we will skip moving of this empty chain, and hence
last_with_datap will not be adjusted, and things will be broken after.

Fix this by not relying on ->off, just count if we have something to
move that's it.

Test case from:
  https://github.com/envoyproxy/envoy/pull/6062

Fixes: #774
2019-03-03 18:00:37 +03:00
Azat Khuzhin
91acedcc97
test: verify content of the buffer in evbuffer/remove_buffer_with_empty*
And replace spaces with tab in remove_buffer_with_empty
2019-03-03 17:54:23 +03:00
Seong-Joong Kim
16a151df5c Remove needless check for arc4_seeded_ok 2019-03-01 18:06:29 +00:00
Enji Cooper
91dad75f7d Fix typos: warnigns -> warnings
Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
2019-02-28 17:48:10 -08:00
Enji Cooper
0b468bb07e Fix typos in a comment describing the purpose of VersionViaGit.cmake
Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
2019-02-28 17:35:02 -08:00
Enji Cooper
5f87be42f0
Define _GNU_SOURCE properly/consistently per autoconf
Although `_GNU_SOURCE` can be defined as an arbitrary #define per the
glibc docs [1], it's best to define it in a manner consistent with the way
that autoconf defines it, i.e., `1`.

While this shouldn't matter in most cases, it does when the headers from
other projects follow the poorly defined GNU convention implemented by
autoconf and are included after the libevent's util.h header. An example
failure with clang, similar to the failure I encountered, is as follows:
```
$ printf "#define _GNU_SOURCE\n#define _GNU_SOURCE 1" | clang -c -x c -
<stdin>:2:9: warning: '_GNU_SOURCE' macro redefined [-Wmacro-redefined]
        ^
<stdin>:1:9: note: previous definition is here
        ^
1 warning generated.
```

This happened when compiling python [2] with a stale homebrew util.h file from
libevent (which admittedly would not happen in a correct libevent install, as the
header should be installed under /usr/local/include/event2/util.h). However, if
both headers had been combined (which is more likely), it would have failed as
shown above.

Removing the ad hoc definition unbreaks compiling python's pyconfig.h.in header
when included after util.h from libevent.

1. http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
2. https://github.com/python/cpython/blob/master/configure.ac#L126

Closes: #773 (cherry-picked)

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
2019-02-27 23:18:12 +03:00
Yury Korzhetsky
a30d6d8521
Don't loose top error in SSL
Closes: #775 (cherry-picked)
2019-02-26 22:30:26 +03:00
Azat Khuzhin
b34192bae6
Ignore bitrise branches for travis-ci/appvyeor [ci skip] 2019-02-25 00:28:18 +03:00
Azat Khuzhin
2fccb967c5
Update link to the appveyor project
Since the migration request has been hanged for a while, let's switch it
for now without beauty API URL.

Fixes: #555
2019-02-24 23:04:24 +03:00
Azat Khuzhin
5722e13b87
Match definition with prototype for bufferevent_socket_set_conn_address_fd_()
Fixes: #772
Fixes: b29207dc ("Eliminate fd conversion warnings and introduce EVUTIL_INVALID_SOCKET (windows)")
2019-02-24 19:54:33 +03:00
Azat Khuzhin
14eb903ba3
Revert "test: avoid regress hanging in macOS"
After we started to use kill() over raise() everything should work just
fine.

This reverts commit a86f89d333d870e6714bd28c695ba1774df3d7f5.

Fixed-in: 728c5dc1 ("Use kill() over raise() for raising the signal (fixes osx 10.14 with kqueue)")
Fixes: #747
2019-02-24 17:28:36 +03:00
Azat Khuzhin
728c5dc11f
Use kill() over raise() for raising the signal (fixes osx 10.14 with kqueue)
On OSX 10.14+ the raise() uses pthread_kill() (verified with dtruss) and
by some reason signals that has been raised with pthread_kill() do not
received by kqueue EVFILT_SIGNAL.

While on OSX 10.11 the raise()/pthread_kill() uses plain kill() and
everything work just fine (linux also does the same, but instead of
kill() it uses tgkill())

Here is a simple reproducer that installs alarm to show that the signal
does not received by the kqueue backend:
  https://gist.github.com/azat/73638b8e3b0fa563a20dadcca9e652a1

Refs: #747
Fixes: #765
2019-02-24 17:18:11 +03:00
Nathan French
8d5b14d428
Merge pull request #769 from sungjungk/fix-return-handling
Add error-handling routine for arc4_seed()
2019-02-21 10:21:02 -05:00
Seong-Joong Kim
493a1da993 Add error-handling routine for arc4_seed() 2019-02-21 18:13:05 +09:00
Nathan French
fb13493916
Added DNS header mask definitions.
Currently, we do a lot of data munging with manual hex. This is ugly
and can lead to bugs. I defined the following:

_QR_MASK    0x8000U
_OP_MASK    0x7800U
_AA_MASK    0x0400U
_TC_MASK    0x0200U
_RD_MASK    0x0100U
_RA_MASK    0x0080U
_Z_MASK     0x0040U
_AD_MASK    0x0020U
_CD_MASK    0x0010U
_RCODE_MASK 0x000fU

So that we can more easily twiddle flags.

v2: make evdns flag masks unsigned literal
Closes: #756 (cherry-picked)
2019-02-12 11:15:52 +03:00
Azat Khuzhin
63c6669fd8
Use the logo from the libevent.org 2019-02-06 00:12:46 +03:00
Azat Khuzhin
6dbad0f671
test/dns: in solaris under EMFILE devpoll does not dispatch (due DP_POLL failure) 2019-02-04 22:43:47 +03:00
Azat Khuzhin
8e87de3c24
cmake: fix checking of devpoll backend (like in autotools, by devpoll.h existence) 2019-02-04 22:21:28 +03:00
Azat Khuzhin
d234902da7
test/dns: in solaris under EMFILE the error is EAI_FAIL 2019-02-03 18:56:01 +03:00
Azat Khuzhin
ae9b285d2d
test/ssl/bufferevent_wm: explicitly break the loop once client/server received enough
There can be tricky cases (that can be reproduced by reducing
SO_RCVBUF/SO_SNDBUF to 6144, on linux, and be aware, since linux doubles
this const), when there is still write event pending, although we read
enough.

This should be fixed in a more sophisticated way, but to backport the
patch, let's simply break the loop manually.

The ssl/bufferevent_wm originally failed on solaris.
2019-02-03 18:51:28 +03:00
Azat Khuzhin
b29207dcee
Eliminate fd conversion warnings and introduce EVUTIL_INVALID_SOCKET (windows)
windows has intptr_t instead of regular int.

Also tt_fd_op() had been introduced, since we cannot use tt_int_op() for
comparing fd, since it is not always int.
2019-01-29 22:03:08 +03:00
Azat Khuzhin
74c1089411
evmap: use approparite type for changes to avoid warnings under windows 2019-01-29 21:31:48 +03:00
Azat Khuzhin
0791a17204
test/et/et: use evutil_socket_t* over int* for pointer to the pair
Next code will not work correctly under win x64:
  evutil_socket_t very_long_pair_name[2];
  int *pair = very_long_pair_name; // <-- accessing the second word of the first element

Because sizeof(evutil_socket_t) == sizeof(intptr_t) == 8

P.S. in the 5334762f another test had been fixed instead of the one that
really fails.

Fixes: 5334762f ("test/et/et: fix it by using appropriate type for the SOCKET (evutil_socket_t)")
Refs: #750
2019-01-29 21:11:27 +03:00
Azat Khuzhin
e2e82241d1
appveyor: disable verbosity of MSBuild 2019-01-29 20:58:01 +03:00
Azat Khuzhin
97a3e7f580
Merge branch 'win64-fixes'
* win64-fixes:
  test/et/et: fix it by using appropriate type for the SOCKET (evutil_socket_t)
  test/et/et: verify return codes
  appveyor: switch to new VS/MinGW and x64
2019-01-29 10:54:39 +03:00