MEDIUM: connection: replace conn_full_close() with cs_close()

At all call places where a conn_stream is in use, we can now use
cs_close() to get rid of a conn_stream and of its underlying connection
if the mux estimates it makes sense. This is what is currently being
done for the pass-through mux.
This commit is contained in:
Willy Tarreau 2017-10-05 18:52:17 +02:00
parent 4b79524591
commit a553ae96f5
3 changed files with 15 additions and 30 deletions

View File

@ -1400,7 +1400,7 @@ static int wake_srv_chk(struct conn_stream *cs)
* sure want to abort the hard way. * sure want to abort the hard way.
*/ */
conn_sock_drain(conn); conn_sock_drain(conn);
conn_full_close(conn); cs_close(cs);
ret = -1; ret = -1;
} }
@ -2207,7 +2207,7 @@ static struct task *process_chk_conn(struct task *t)
* server state to be suddenly changed. * server state to be suddenly changed.
*/ */
conn_sock_drain(conn); conn_sock_drain(conn);
conn_full_close(conn); cs_close(cs);
} }
if (conn) { if (conn) {
@ -2686,9 +2686,8 @@ static int tcpcheck_main(struct check *check)
* 3: release and replace the old one on success * 3: release and replace the old one on success
*/ */
if (check->cs) { if (check->cs) {
/* XXX: need to kill all CS here as well but not to free them yet */ cs_close(check->cs);
conn_full_close(check->cs->conn); retcode = -1; /* do not reuse the fd in the caller! */
retcode = -1; /* do not reuse the fd! */
} }
/* mark the step as started */ /* mark the step as started */

View File

@ -579,7 +579,7 @@ static int sess_update_st_con_tcp(struct stream *s)
struct stream_interface *si = &s->si[1]; struct stream_interface *si = &s->si[1];
struct channel *req = &s->req; struct channel *req = &s->req;
struct channel *rep = &s->res; struct channel *rep = &s->res;
struct connection *srv_conn = __objt_cs(si->end)->conn; struct conn_stream *srv_cs = __objt_cs(si->end);
/* If we got an error, or if nothing happened and the connection timed /* If we got an error, or if nothing happened and the connection timed
* out, we must give up. The CER state handler will take care of retry * out, we must give up. The CER state handler will take care of retry
@ -602,7 +602,7 @@ static int sess_update_st_con_tcp(struct stream *s)
/* XXX cognet: do we really want to kill the connection here ? /* XXX cognet: do we really want to kill the connection here ?
* Probably not for multiple streams. * Probably not for multiple streams.
*/ */
conn_full_close(srv_conn); cs_close(srv_cs);
if (si->err_type) if (si->err_type)
return 0; return 0;

View File

@ -821,8 +821,7 @@ static void stream_int_shutr_conn(struct stream_interface *si)
return; return;
if (si_oc(si)->flags & CF_SHUTW) { if (si_oc(si)->flags & CF_SHUTW) {
/* XXX: should just close cs ? */ cs_close(cs);
conn_full_close(conn);
si->state = SI_ST_DIS; si->state = SI_ST_DIS;
si->exp = TICK_ETERNITY; si->exp = TICK_ETERNITY;
} }
@ -890,15 +889,7 @@ static void stream_int_shutw_conn(struct stream_interface *si)
* layer to try to signal it to the peer before we close. * layer to try to signal it to the peer before we close.
*/ */
cs_shutw(cs, CS_SHW_NORMAL); cs_shutw(cs, CS_SHW_NORMAL);
conn_sock_shutw(conn);
/* If the stream interface is configured to disable half-open
* connections, we'll skip the shutdown(), but only if the
* read size is already closed. Otherwise we can't support
* closed write with pending read (eg: abortonclose while
* waiting for the server).
*/
if (!(si->flags & SI_FL_NOHALF) || !(ic->flags & (CF_SHUTR|CF_DONT_READ))) {
if (!(ic->flags & (CF_SHUTR|CF_DONT_READ))) { if (!(ic->flags & (CF_SHUTR|CF_DONT_READ))) {
/* OK just a shutw, but we want the caller /* OK just a shutw, but we want the caller
* to disable polling on this FD if exists. * to disable polling on this FD if exists.
@ -907,14 +898,13 @@ static void stream_int_shutw_conn(struct stream_interface *si)
return; return;
} }
} }
}
/* fall through */ /* fall through */
case SI_ST_CON: case SI_ST_CON:
/* we may have to close a pending connection, and mark the /* we may have to close a pending connection, and mark the
* response buffer as shutr * response buffer as shutr
*/ */
conn_full_close(conn); cs_close(cs);
/* fall through */ /* fall through */
case SI_ST_CER: case SI_ST_CER:
case SI_ST_QUE: case SI_ST_QUE:
@ -1369,11 +1359,7 @@ void stream_sock_read0(struct stream_interface *si)
do_close: do_close:
/* OK we completely close the socket here just as if we went through si_shut[rw]() */ /* OK we completely close the socket here just as if we went through si_shut[rw]() */
conn_full_close(cs->conn); cs_close(cs);
ic->flags &= ~CF_SHUTR_NOW;
ic->flags |= CF_SHUTR;
ic->rex = TICK_ETERNITY;
oc->flags &= ~CF_SHUTW_NOW; oc->flags &= ~CF_SHUTW_NOW;
oc->flags |= CF_SHUTW; oc->flags |= CF_SHUTW;