]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: checks: do not trust errno in write event before any syscall
authorWilly Tarreau <w@1wt.eu>
Wed, 4 Dec 2013 23:31:46 +0000 (00:31 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 5 Dec 2013 01:23:48 +0000 (02:23 +0100)
commit20a18342195c36b60e4c36227034383411d9382f
treebdb2258996d0d1d0ca6511b0db7b29d23b3eec7a
parentce3eda7c6a8e594cf690b3c2f8e35378e8601dfc
BUG/MINOR: checks: do not trust errno in write event before any syscall

The only case where errno is supposed to be valid is when the connection
has just got the CO_FL_ERROR flag and errno is not zero, because it will
have been set by the same function that has set the flag. For all other
situations, we need to check the socket using getsockopt(), but only do
it once, since it clears the pending error code. For this reason, we
assign the error code to errno in order not to lose it. The same call
is made at the entry of event_srv_chk_r(), event_srv_chk_w(), and
wake_srv_chk() so that we get a chance to collect errors reported by
the poller or by failed syscalls.

Note that this fix relies on the 4 previous patches, so backporters
must be very careful.
src/checks.c