From: Willy Tarreau Date: Tue, 16 Mar 2010 19:55:43 +0000 (+0100) Subject: [BUG] checks: don't report an error when recv() returns an error after data X-Git-Tag: v1.4.2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c1a07960a67789e1e01db14049892db1f040669a;p=thirdparty%2Fhaproxy.git [BUG] checks: don't report an error when recv() returns an error after data This happens when a server immediately closes the connection after the response without lingering or when we close before the end of the data. We get an RST which translates into a late error. We must not declare an error without checking that the contents are OK. --- diff --git a/src/checks.c b/src/checks.c index eeed75af40..cba49f8b23 100644 --- a/src/checks.c +++ b/src/checks.c @@ -898,10 +898,17 @@ static int event_srv_chk_r(int fd) fdtab[fd].ev &= ~FD_POLL_IN; return 0; } - /* network error, report it */ - if (!(s->result & SRV_CHK_ERROR)) - set_server_check_status(s, HCHK_STATUS_SOCKERR, NULL); - goto out_wakeup; + + /* Report network errors only if we got no other data. Otherwise + * we'll let the upper layers decide whether the response is OK + * or not. It is very common that an RST sent by the server is + * reported as an error just after the last data chunk. + */ + if (!s->check_data_len) { + if (!(s->result & SRV_CHK_ERROR)) + set_server_check_status(s, HCHK_STATUS_SOCKERR, NULL); + goto out_wakeup; + } } /* Full response received.