mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-26 06:32:13 +00:00
BUG/MINOR: checks: do not uselessly poll for reads before the connection is up
It's pointless to start to perform a recv() call on a connection that is not yet established. The only purpose used to be to subscribe but that causes many extra syscalls when we know we can do it later. This patch only attempts a read if the connection is established or if there is no write planed, since we want to be certain to be called. And in wake_srv_chk() we continue to attempt to read if the reader was not subscribed, so as to perform the first read attempt. In case a first result is provided, __event_srv_chk_r() will not do anything anyway so this is totally harmless in this case. This fix requires that commit "BUG/MINOR: checks: make __event_chk_srv_r() report success before closing" is applied before, otherwise it will break some checks (notably SSL) by doing them again after the connection is shut down. This completes the fixes on the checks described in issue #253 by roughly cutting the number of syscalls in half. It must be backported to 2.0.
This commit is contained in:
parent
4c1a2b30a3
commit
c594039225
@ -1447,8 +1447,12 @@ static int wake_srv_chk(struct conn_stream *cs)
|
|||||||
ret = tcpcheck_main(check);
|
ret = tcpcheck_main(check);
|
||||||
cs = check->cs;
|
cs = check->cs;
|
||||||
conn = cs->conn;
|
conn = cs->conn;
|
||||||
} else if (!(check->wait_list.events & SUB_RETRY_SEND))
|
} else {
|
||||||
|
if (!(check->wait_list.events & SUB_RETRY_SEND))
|
||||||
__event_srv_chk_w(cs);
|
__event_srv_chk_w(cs);
|
||||||
|
if (!(check->wait_list.events & SUB_RETRY_RECV))
|
||||||
|
__event_srv_chk_r(cs);
|
||||||
|
}
|
||||||
|
|
||||||
if (unlikely(conn->flags & CO_FL_ERROR || cs->flags & CS_FL_ERROR)) {
|
if (unlikely(conn->flags & CO_FL_ERROR || cs->flags & CS_FL_ERROR)) {
|
||||||
/* We may get error reports bypassing the I/O handlers, typically
|
/* We may get error reports bypassing the I/O handlers, typically
|
||||||
@ -2260,6 +2264,8 @@ static struct task *process_chk_conn(struct task *t, void *context, unsigned sho
|
|||||||
* sending since otherwise we won't be woken up.
|
* sending since otherwise we won't be woken up.
|
||||||
*/
|
*/
|
||||||
__event_srv_chk_w(cs);
|
__event_srv_chk_w(cs);
|
||||||
|
if (!(conn->flags & CO_FL_WAIT_L4_CONN) ||
|
||||||
|
!(check->wait_list.events & SUB_RETRY_SEND))
|
||||||
__event_srv_chk_r(cs);
|
__event_srv_chk_r(cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user