4098 Commits

Author SHA1 Message Date
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
Azat Khuzhin
5334762fcf
test/et/et: fix it by using appropriate type for the SOCKET (evutil_socket_t)
Fixes: #750
2019-01-29 10:54:22 +03:00
Azat Khuzhin
3e37fcd43c
test/et/et: verify return codes 2019-01-29 10:54:07 +03:00
Azat Khuzhin
588ee6dfa1
appveyor: switch to new VS/MinGW and x64
The cache had been reseted with the following REST API requests:
  DELETE https://ci.appveyor.com/api/projects/nmathewson/libevent/buildCache
  DELETE https://ci.appveyor.com/api/projects/libevent/libevent/buildCache
  DELETE https://ci.appveyor.com/api/projects/azat/libevent/buildCache
2019-01-29 10:54:07 +03:00
Azat Khuzhin
8882f4fd60
win32select: print an error in case of failure 2019-01-29 10:53:55 +03:00
Azat Khuzhin
f88b8946f3
Add OS-specific exclude patterns of the branch names for the CI 2019-01-29 10:11:17 +03:00
Azat Khuzhin
afdccee9b3
s/http-server: fix cleanup routines
Fixes: bdd71f18 ("s/http-server: graceful cleanup")
2019-01-29 01:23:02 +03:00
Azat Khuzhin
7bfe93886d
Merge branch 'http-EVHTTP_CON_READ_ON_WRITE_ERROR-fixes-v2'
* http-EVHTTP_CON_READ_ON_WRITE_ERROR-fixes-v2:
  http: try to read existing data in buffer under EVHTTP_CON_READ_ON_WRITE_ERROR
  test: add logging for http/read_on_write_error and rearrange code
  http: do not call deferred readcb if readcb is not set

Refs: #749
2019-01-29 01:18:39 +03:00
Azat Khuzhin
30791eccce
http: try to read existing data in buffer under EVHTTP_CON_READ_ON_WRITE_ERROR
There are two possible ways of getting response from the server:
- processing existing bufferevent buffer
- reading from the socket (even after write() errored with -1, it is
still possible)

But we did not tried the first option, only the second one.

Fixes: http/read_on_write_error (on freebsd/osx)
2019-01-29 01:16:48 +03:00
Azat Khuzhin
b8ca5a6820
test: add logging for http/read_on_write_error and rearrange code 2019-01-29 00:51:46 +03:00
Azat Khuzhin
d3dcb5aca9
http: do not call deferred readcb if readcb is not set
Otherwise evhttp_read_cb can be called with invalid connection state:
    http/read_on_write_error: [forking] [msg] libevent using: kqueue
      FAIL ../test/regress_http.c:4079: assert(req)
      FAIL ../test/regress_http.c:4087: assert(req)[err] evhttp_read_cb: illegal connection state 0
2019-01-28 22:20:47 +03:00
Azat Khuzhin
5613bfb8dc
Merge branch 'travis-ci-osx-fixes'
* travis-ci-osx-fixes:
  travis-ci/osx: switch to xcode 10.1, since 9.4 is not compatible with gcc-8
  travis-ci/osx: install gcc and fix CC
2019-01-28 22:19:20 +03:00
Azat Khuzhin
b35b533666
travis-ci/osx: switch to xcode 10.1, since 9.4 is not compatible with gcc-8
Refs: travis-ci/travis-ci#9640
2019-01-28 21:25:23 +03:00
Azat Khuzhin
9432fa2ec6
travis-ci/osx: install gcc and fix CC
Since there is no gcc in osx_image [1]:
    ls: /usr/local/bin/gcc-?.?: No such file or directory

  [1]: https://travis-ci.org/libevent/libevent/jobs/484794192#L95

And use ls(1) over echo(1) to show an error if there is no such file.
2019-01-28 21:22:25 +03:00
Azat Khuzhin
4ffc711617
test: adjust expecting error for getaddrinfo() under EMFILE
When getaddrinfo() cannot allocate file descriptor glibc/musl-libc on
linux report EAI_SYSTEM error. But this is not true for freebsd libc [1]
(and hence apple libc [2]), they report EAI_NONAME error instead, so
adjust expectation.

  [1]: https://github.com/freebsd/freebsd/blob/master/lib/libc/net/getaddrinfo.c
  [2]: https://opensource.apple.com/source/Libc/

Refs: #749
Refs: https://github.com/libevent/libevent/issues/749#issuecomment-457838159
2019-01-26 19:57:37 +03:00
Azat Khuzhin
91a2f1346e
test/nonpersist_readd: use assert helpers
To debug failure under win32 in appveyor:
  https://ci.appveyor.com/project/nmathewson/libevent/builds/21559140/job/dn16qdo1j6sr497t#L1620
2019-01-12 14:14:51 +03:00
Azat Khuzhin
99b231b0d8
rpc: use *_new_with_arg() to match function prototype
In 755fbf16c ("Add void* arguments to request_new and reply_new
evrpc hooks") this new functions had been introduced, but newer used,
what for? So let's use them.
2019-01-11 21:53:07 +03:00
Luke Dashjr
28d7221b85
http: Preserve socket error from listen across closesocket cleanup
Closes: #738 (cherry-picked)
2019-01-07 15:22:39 +03:00
Azat Khuzhin
246f44041e
cmake: support static runtime (MSVC)
Fixes: #737
2018-12-17 21:49:00 +03:00
Azat Khuzhin
51945fd939
appveyor: cover static libs for MSVC 2018-12-17 21:48:10 +03:00
baixiangcpp
972da7c838
fix a comment error
Closes: #736 (cherry-picked)
2018-12-16 00:51:14 +03:00
Fredrik Strupe
f33c2ce5f8 cmake: Fix some typos in option descriptions 2018-12-15 12:54:31 +01:00
Azat Khuzhin
f3f7aa5aff
http: fix connection retries when there more then one request for connection
We should not attemp to establishe the connection if there is retry
timer active, since otherwise there will be a bug.

Imagine next situation:
  con = evhttp_connection_base_new()
  evhttp_connection_set_retries(con, 2)
  req = evhttp_request_new()
  evhttp_make_request(con, req, ...)
  # failed during connecting, and timer for 2 second scheduler (retry_ev)

Then another request scheduled for this evcon:
  evhttp_make_request(con, req, ...)
  # got request from server,
  # and now it tries to read the response from the server
  # (req.kind == EVHTTP_RESPONSE)
  #
  # but at this point retry_ev scheduled,
  # and it schedules the connect again,
  # and after the connect will succeeed, it will pick request with
  # EVHTTP_RESPONSE for sending and this is completelly wrong and will
  # fail in evhttp_make_header_response() since there is no
  # "http_server" for this evcon

This was a long standing issue, that I came across few years ago
firstly, bad only now I had time to dig into it (but right now it was
pretty simple, by limiting amount of CPU for the process and using rr
for debug to go back and forth).
2018-12-12 21:46:27 +03:00
Azat Khuzhin
9d3a415a99
Do not check O_NONBLOCK for invalid fds
Fixes: 6f988ee1 ("Merge branch 'check-O_NONBLOCK-in-debug'")
2018-12-09 14:48:44 +03:00
Azat Khuzhin
e5ec52d100
test-fdleak: fix memory leaks
Fixes: #726
2018-12-08 17:35:53 +03:00
Azat Khuzhin
3e6bec7c1a
travis-ci: do not run coveralls with clang (SIGSEGV)
This will fix coveralls badge

See: https://travis-ci.org/libevent/libevent/jobs/458590276#L1425
2018-12-05 11:48:03 +03:00
Azat Khuzhin
196e3a7b2b
Add mailmap 2018-12-05 11:48:03 +03:00
Azat Khuzhin
1d2ef90032
test: add TT_RETRIABLE for http/cancel_by_host_no_ns
Could fail from time to time in travis-ci:
  https://travis-ci.org/libevent/libevent/jobs/458554097#L1702

Follow-up-for: fe5b0719 ("Mark a lot of flacky tests with TT_RETRIABLE (for linux/win32 only)")
2018-11-23 00:43:40 +03:00
Azat Khuzhin
1a79fd38aa
appveyor: enable parallel build 2018-11-23 00:41:21 +03:00
Azat Khuzhin
90d80ef416
cmake: do not build both (SHARED and STATIC) for MSVC/win32
MSVC does not support SHARED and STATIC libraries with the same name,
so let's just build SHARED libraries by default instead (yes we can add
prefix but let's stick with this).

The reason for this is that in windows shared libraries requires .lib
file too, but this is not static library it is imported library for
shared (doh...), for more info [1] and [2].

  [1]: https://docs.microsoft.com/en-us/windows/desktop/dlls/dynamic-link-library-creation
  [2]: https://blogs.msdn.microsoft.com/oldnewthing/20091013-00/?p=16403

And when we build both static library can and will override shared
library imported part, let's take a look at event_extra.lib:

- before patch [3]:
  $ less libevent-fail/lib/Debug/event_extra.lib | head
  ==> use library:contained_file to view a file in the archive
  rw-rw-rw- 100666/100666  59568 Nov 21 23:55 2018 event_extra_static.dir/Debug/evrpc.obj
  rw-rw-rw- 100666/100666 252219 Nov 21 23:55 2018 event_extra_static.dir/Debug/evdns.obj
  rw-rw-rw- 100666/100666 203850 Nov 21 23:55 2018 event_extra_static.dir/Debug/http.obj
  rw-rw-rw- 100666/100666  25907 Nov 21 23:55 2018 event_extra_static.dir/Debug/event_tagging.obj

  [3]: https://ci.appveyor.com/project/azat/libevent/builds/20472024/job/t0o93v042jai0dj7

- "after patch" [4] (not after but the same effect):
  $ less libevent-ok/lib/Debug/event_extra.lib | head
  ==> use library:contained_file to view a file in the archive
  --------- 0/0    509 Nov 21 23:38 2018 event_extra.dll
  ...

  [4]: https://ci.appveyor.com/project/azat/libevent/builds/20478998/job/ca9k3c76amc4qr76

Refs: #691
2018-11-23 00:41:18 +03:00
Azat Khuzhin
c9a073eae8
cmake: introduce EVENT__LIBRARY_TYPE option
Long time ago in [1] cmake build was forced to compile both libraries
(SHARED and STATIC), since this is how our autotools build works.

  [1]: 7182c2f561570cd9ceb704623ebe9ae3608c7b43 ("cmake: build SHARED and STATIC libraries (like autoconf does)")

And there is no way to configure this (and indeed you need to do this
for MSVC for example), so let's introduce option for this --
EVENT__LIBRARY_TYPE.

Plus now we have INTERFACE libraries, that we can use internally in
libevent's cmake rules to avoid strict to _shared/_static variant of the
libraries to link with samples/tests (we prefer SHARED over STATIC for
linking).

Also bump minimal cmake required version to 3.1 by the following
reasons:
- 3.1 is required for RPATH configuration under APPLE
- 3.0 is required for add_library(INTERFACE) (did not found it in 2.8.x
documentation)
- remove extra conditions
(anyway 3.1 was release 4 years ago, so I guess that most of the systems
will have it)
2018-11-23 00:02:18 +03:00
Azat Khuzhin
d705e8c0e9
cmake: drop redundant add_dependencies() 2018-11-22 22:58:56 +03:00
Azat Khuzhin
4d2f013b5d
Merge branch 'TT_RETRIABLE'
* TT_RETRIABLE:
  Mark a lot of flacky tests with TT_RETRIABLE (for linux/win32 only)
  regress: introduce TT_RETRIABLE

Fixes: #704
2018-11-21 00:10:43 +03:00
Azat Khuzhin
fe5b07199d
Mark a lot of flacky tests with TT_RETRIABLE (for linux/win32 only)
This patch mark testcases that only fail under travis-ci/appveyor with
TT_RETRIABLE, since otherwise there is too much noise, other issues
(like failures under vagrant boxes) would be investigated separatelly.

linux (from travis-ci only):
- http/cancel_by_host_no_ns
- http/cancel_by_host_inactive_server
- http/cancel_by_host_ns_timeout
- http/cancel_by_host_ns_timeout_inactive_server
- thread/conditions_simple
- util/monotonic_prc_precise
- util/usleep
- main/del_wait

vagrant/ubuntu box (this is the only exception):
- thread/no_events

win32 (from appveyor only):
- main/active_later
- main/persistent_active_timeout

And we should use TT_RETRIABLE over TT_OFF_BY_DEFAULT/TT_SKIP when it
make sense.

But there is still "test-ratelim__group_lim" left.
2018-11-20 23:02:56 +03:00
Azat Khuzhin
63b065be80
regress: introduce TT_RETRIABLE
We have some tests that has false-positive due to real/CPU time bound,
but they are pretty generic and we do not want to skip them by default.

TT_RETRIABLE is the flag that will indicate tinytest to retry the test
in case of failure, use it to avoid next possible false-positives:
- real time-related
- CPU time-related
Since I guess it is better to see/grepping RETRYING messages over
ignoring completely failed builds.

No configuration switch for number of retries was done on purpose (only
3 retries and no more).

And this is how it looks BTW:
  $ gcc ../test/tinytest_demo.c ../test/tinytest.c
  $ ./a.out --verbose --no-fork
  demo/timeout_retry
  demo/timeout_retry:
    FAIL ../test/tinytest_demo.c:201: assert(i != 1): 1 vs 1
    [timeout_retry FAILED]

    [RETRYING timeout_retry (3)]
  demo/timeout_retry:
           OK ../test/tinytest_demo.c:201: assert(i != 1): 2 vs 1
           OK ../test/tinytest_demo.c:213: assert(t2-t1 >= 4): 5 vs 4
           OK ../test/tinytest_demo.c:215: assert(t2-t1 <= 6): 5 vs 6
  1 tests ok.  (0 skipped)
2018-11-20 22:56:28 +03:00
Azat Khuzhin
57765b23c8
bufferevent: add debug messages when .setfd/.getfd/.enable/.disable failed 2018-11-20 06:24:42 +03:00
Azat Khuzhin
b98d32d0c9
http: improve error path for bufferevent_{setfd,enable,disable}()
We have calls to the next functions but do not check return values,
though they can be invalid and it is better to show this somehow.

Also do bufferevent_setfd() first and only after it
bufferevent_enable()/bufferevent_disable() since:
a) it is more natural
b) it will avoid extra operations
c) it will not fail first bufferevent_enable() (this is the case for
   buffbufferevent_async at least)

In this case we could add more information for issues like #709
2018-11-20 06:22:31 +03:00
Azat Khuzhin
3036f15a17
regress_http: fix compilation with !EVENT__HAVE_OPENSSL
Fixes: 811c63f7 ("regress: test for HTTP/HTTPS with IOCP enabled")
2018-11-20 06:22:27 +03:00
Azat Khuzhin
f8d510f617
regress_bufferevent: add TT_IOCP_LEGACY/TT_IOCP 2018-11-13 23:31:16 +03:00
Azat Khuzhin
903c6acea5
t/bench_http: disable buffering (win32 do not show anything otherwise)
Refs: #255
2018-11-13 23:31:16 +03:00
Azat Khuzhin
56f3bdefca
s/http-server: check for EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED 2018-11-13 23:24:26 +03:00
Azat Khuzhin
3d815cf220
Merge branch 'iocp-fixes'
* iocp-fixes:
  regress: test for HTTP/HTTPS with IOCP enabled
  bev_async: trigger/run only deferred callbacks
  bev_async: do not initialize timeouts multiple times
  bev_async: set "ok" on setfd if fd>=0 (like we do during creation)
  bev_async: ignore ERROR_INVALID_PARAMETER on .setfd for iocp

Closes: #709
Refs: nmathewson/Libevent#160
2018-11-13 22:47:43 +03:00