4251 Commits

Author SHA1 Message Date
Azat Khuzhin
c80f6be1e4
Merge branch '21_http_extended_method'
* 21_http_extended_method:
  Added http method extending
  http: Update allowed_methods field from 16 to 32bits.

Fixes: #327
2019-04-11 22:52:10 +03: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
Thomas Bernard
96e56beb94
http: Update allowed_methods field from 16 to 32bits. 2019-04-11 22:47:55 +03:00
Azat Khuzhin
799053db8a
http: replace EVHTTP_REQ_UNKNOWN_ with 0
From the server perspective the evhttp_response_phrase_internal() should
not be called with 0 before this patch, it will be called with
EVHTTP_REQ_UNKNOWN_ hence this patch should not change behavior.

Fixes: 68eb526d7b ("http: add WebDAV methods support")
Fixes: #789
Fixes: #796
Reported-by: Thomas Bernard <miniupnp@free.fr>
2019-04-10 00:51:27 +03:00
Azat Khuzhin
55f9863b18
Remove experimental note for finalizers API 2019-04-07 04:57:32 +03:00
Azat Khuzhin
428f36e5dd
https-client: do not try to free not initialized base
Otherwise:
  $ https-client --help
  Syntax:
     https-client -url <https-url> [-data data-file.bin] [-ignore-cert] [-retries num] [-timeout sec] [-crt crt]
  Example:
     https-client -url https://ip.appspot.com/
  [warn] event_base_free_: no base to free
2019-04-03 23:24:17 +03:00
Azat Khuzhin
35caeff5de
http: drop unused internal macros 2019-04-03 23:21:24 +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
Azat Khuzhin
93a925474d
appveyor: check intermediate powershell commands exit codes and terminate early
Otherwise build errors will be ignored, i.e. if build fails but regress
binary exists (copied from artifacts) it will be runned instead of newly
compiled.
2019-04-02 23:31:43 +03:00
Azat Khuzhin
da33f768e4
Merge branch 'fix-uchex-warnings'
There is one more report that is false positive, see [1]:
  "In bufferevent_openssl.c, pointer wm is dereferenced on line 871
before it is null checked on line 873."

  [1]: https://github.com/libevent/libevent/issues/382#issuecomment-238081938

* fix-uchex-warnings:
  evdns: do not check server_req twice
  evrpc: do not check req twice

Fixes: #382
2019-04-01 02:42:55 +03:00
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