libevent / libevent

Event notification library
https://libevent.org
Other
10.84k stars 3.35k forks source link

Fix incorrect handling of ECONNREFUSED on BSD #1649

Closed azat closed 1 month ago

azat commented 1 month ago

1100 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