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
Doc: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api
From the API list, the libevent library only uses:
- mach_absolute_time, but that one is avoided with HAVE_POSIX_MONOTONIC (default) instead of HAVE_MACH_MONOTONIC
- fstat and stat in evbuffer_file_segment_new, which is covered by third-party SDK usage (0A2A.1)
- fstat and stat in evutil_read_file_, which is used to read the "/etc/resolv.conf" and "/etc/hosts" files, for which there are no available supporting reasons
Conventionally, ident for EVFILT_USER is set to 0 to avoid
collision of file descriptors, which is what other renowned
networking frameworks like netty(java), mio(rust), gnet(go),
swift-nio(swift), etc. do currently.
Co-authored-by: Azat Khuzhin <azat@libevent.org>
This commit disables the property of TCP keepalive on Unix domain
sockets, because they essentially serve no purpose here, except for
causing problems on Windows and macOS systems.
Fixes#1615
Register the eventfd with EPOLLET to enable edge-triggered notification
where we don't need to read the data from the eventfd for every wakeup
event.
When the eventfd counter reaches the maximum value of the unsigned 64-bit,
we rewind the counter and retry again. This optimization saves one system
call on each event-loop wakeup, which eliminates the extra latency for epoll
as the EVFILT_USER filter does for the kqueue.