* Use evutil_socket_t instead in http server sample and handle 64 bit Windows
* Update http-server.c
* consistently using EV_SOCK_FMT for Windows compatibility
* code review: fix missing symbol strsignal
* Add evutil_strsignal() helper instead of strsignal() macro
---------
Co-authored-by: Hernan Martinez <hernan.c.martinez@gmail.com>
Co-authored-by: Azat Khuzhin <azat@libevent.org>
DragonFly BSD changed the time unit for TCP keep-alive from milliseconds to seconds since v5.8 and Solaris 11.4 added `TCP_KEEPIDLE`, `TCP_KEEPINTVL`, and `TCP_KEEPCNT` with time units in second while Solaris <11.4 still use `TCP_KEEPALIVE_THRESHOLD` and `TCP_KEEPALIVE_ABORT_THRESHOLD` with time units in millisecond.
Currently, we don't differentiate among DragonFly BSD versions but set the keepalive options with seconds, which will result in unexpected behaviors on DragonFlyBSD <5.8. This PR intends to fix the wrong usage of time units of TCP keepalive options on DragonFly BSD <5.8 and consolidate the logic of time units conversion for TCP keepalive across platforms.
In addition, this PR introduces a new custom macro for determining Solaris 11.4. This macro is expected to help us implement some new features for `libuv` using some abilities that only exist on Solaris 11.4 and other mainstream platforms in the future, considering that Oracle developed and released Solaris 11.4 to replenish plenty of features on Solaris that have already been implemented on other UNIX-like OSs but missing from Solaris <11.4, also bring a good deal of new features.
### References
- [Change tcp keepalive options from ms to seconds (DISRUPTIVE)](https://lists.dragonflybsd.org/pipermail/commits/2019-July/719125.html)
- [DragonFly BSD 5.8 release notes](https://www.dragonflybsd.org/release58/)
- [DragonFly TCP](https://man.dragonflybsd.org/?command=tcp§ion=4)
- [Solaris 11.3 TCP](https://docs.oracle.com/cd/E86824_01/html/E54777/tcp-7p.html)
- [Solaris 11.4 TCP](https://docs.oracle.com/cd/E88353_01/html/E37851/tcp-4p.html)
- [Solaris 11.4 release notes](https://docs.oracle.com/cd/E37838_01/html/E60973/)
Signed-off-by: Andy Pan <i@andypan.me>
This fixes the problematic #define fstat _fstat which would only support files up to 2 GB.
Also refactored it as evutil_fd_filesize to avoid exposing stat when not necessary.
There is one icky in case for windows:
if (sa) {
#ifdef _WIN32
if (bufferevent_async_can_connect_(bev)) {
bufferevent_setfd(bev, fd);
r = bufferevent_async_connect_(bev, fd, sa, socklen);
if (r < 0)
goto freesock;
bufev_p->connecting = 1;
result = 0;
goto done;
- } else
+ } else {
#endif
r = evutil_socket_connect_(&fd, sa, socklen);
if (r < 0) // Previosly this line was executed
// regardless of bufferevent_async_can_connect_(), but the case under
// bufferevent_async_can_connect_() always does goto, so it is 100% the
// same code, but just to make it more cleaner
goto freesock;
+#ifdef _WIN32
+ }
+#endif
}
That wasn't the dead code, since the `r` could be `2` in case of
`ECONNREFUSED`, and it should trigger errorcb not the writecb.
This is actually questionable should be call errorcb at all in case of
connect() returns an error immediately, but I guess the reason was to
make it compatible with others, ECONNREFUSED can be returned only for
specific cases and only on BSD (AFAIK). While for instance EHOSTUNREACH
is not.
And after this change now all tests are passed on FreeBSD. Well,
sometimes few tests fails due to timing issues, but in general looks
good. Since even all tests in parallel passed:
$ rm -f /tmp/libevent*log; bin/regress --list-tests | awk '/^ / { print $1 }' | xargs -I{} -P100 bash -c 'n={}; bin/regress --no-fork --verbose $n |& tee /tmp/libevent-test-${n//\//_}.log' |& grep -F ' [FAILED' |& tee /tmp/libevent-tests.log
And having green CI is crucial for libevent, not only because it is
a rule of thumb for all projects, but also because in case of failures
it will retry on and on, which will cause CI stuck.
Fixes: bufferevent/bufferevent_connect_fail
Fixes: bufferevent/bufferevent_connect_fail_eventcb
Fixes: bufferevent/bufferevent_connect_fail_eventcb_defer
This reverts commit 56e121310954cbee2310c5eb2a3000115186563d.
Refs: https://github.com/libevent/libevent/pull/1100
* test/fixes:
test: mark http/timeout_read_server as retriable
test: reset some static vars to avoid affecting other tests
test: fix printing number of retries for FAILED message
test: add debugging for bufferevent/bufferevent_connect_fail_eventcb*
test: suppress logging for buffer/add_file_leak1