mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-24 22:43:02 +00:00
OPTIM: checks: avoid setting SO_LINGER twice
We happened to preform this call twice on some checks, once in the recv event handler, and another one in the main function. Remove the one from the event handler which does not make any more sense there.
This commit is contained in:
parent
06559ac1fb
commit
2d351b68c2
33
src/checks.c
33
src/checks.c
@ -1363,12 +1363,6 @@ static void event_srv_chk_r(struct connection *conn)
|
||||
if (conn->xprt && conn->xprt->shutw)
|
||||
conn->xprt->shutw(conn, 0);
|
||||
|
||||
if (conn->ctrl && !(conn->flags & CO_FL_SOCK_RD_SH)) {
|
||||
if (conn->flags & CO_FL_WAIT_RD || !conn->ctrl->drain || !conn->ctrl->drain(conn->t.sock.fd))
|
||||
setsockopt(conn->t.sock.fd, SOL_SOCKET, SO_LINGER,
|
||||
(struct linger *) &nolinger, sizeof(struct linger));
|
||||
}
|
||||
|
||||
/* OK, let's not stay here forever */
|
||||
if (check->result & SRV_CHK_FAILED)
|
||||
conn->flags |= CO_FL_ERROR;
|
||||
@ -1399,20 +1393,21 @@ static int wake_srv_chk(struct connection *conn)
|
||||
*/
|
||||
chk_report_conn_err(conn, errno, 0);
|
||||
|
||||
/* We're here because nobody wants to handle the error, so we
|
||||
* sure want to abort the hard way.
|
||||
*/
|
||||
if (conn->ctrl && !(conn->flags & CO_FL_SOCK_RD_SH)) {
|
||||
setsockopt(conn->t.sock.fd, SOL_SOCKET, SO_LINGER,
|
||||
(struct linger *) &nolinger, sizeof(struct linger));
|
||||
}
|
||||
|
||||
__conn_data_stop_both(conn);
|
||||
task_wakeup(check->task, TASK_WOKEN_IO);
|
||||
}
|
||||
|
||||
if (check->result & (SRV_CHK_FAILED|SRV_CHK_PASSED))
|
||||
if (check->result & (SRV_CHK_FAILED|SRV_CHK_PASSED)) {
|
||||
/* We're here because nobody wants to handle the error, so we
|
||||
* sure want to abort the hard way.
|
||||
*/
|
||||
if (conn->ctrl && !(conn->flags & CO_FL_SOCK_RD_SH)) {
|
||||
if (conn->flags & CO_FL_WAIT_RD || !conn->ctrl->drain || !conn->ctrl->drain(conn->t.sock.fd))
|
||||
setsockopt(conn->t.sock.fd, SOL_SOCKET, SO_LINGER,
|
||||
(struct linger *) &nolinger, sizeof(struct linger));
|
||||
}
|
||||
conn_full_close(conn);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1621,9 +1616,11 @@ static struct task *process_chk(struct task *t)
|
||||
* as a failed response coupled with "observe layer7" caused the
|
||||
* server state to be suddenly changed.
|
||||
*/
|
||||
if (conn->ctrl)
|
||||
setsockopt(conn->t.sock.fd, SOL_SOCKET, SO_LINGER,
|
||||
(struct linger *) &nolinger, sizeof(struct linger));
|
||||
if (conn->ctrl && !(conn->flags & CO_FL_SOCK_RD_SH)) {
|
||||
if (conn->flags & CO_FL_WAIT_RD || !conn->ctrl->drain || !conn->ctrl->drain(conn->t.sock.fd))
|
||||
setsockopt(conn->t.sock.fd, SOL_SOCKET, SO_LINGER,
|
||||
(struct linger *) &nolinger, sizeof(struct linger));
|
||||
}
|
||||
conn_full_close(conn);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user