]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: connection: replace conn_full_close() with cs_close()
authorWilly Tarreau <w@1wt.eu>
Thu, 5 Oct 2017 16:52:17 +0000 (18:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 17:03:24 +0000 (18:03 +0100)
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.

src/checks.c
src/stream.c
src/stream_interface.c

index ee0458deaaa3b4b5f4aef1190733a8f96f830c10..49d9467032d9e39bd3b542f6022eef34a6215db2 100644 (file)
@@ -1400,7 +1400,7 @@ static int wake_srv_chk(struct conn_stream *cs)
                 * sure want to abort the hard way.
                 */
                conn_sock_drain(conn);
-               conn_full_close(conn);
+               cs_close(cs);
                ret = -1;
        }
 
@@ -2207,7 +2207,7 @@ static struct task *process_chk_conn(struct task *t)
                         * server state to be suddenly changed.
                         */
                        conn_sock_drain(conn);
-                       conn_full_close(conn);
+                       cs_close(cs);
                }
 
                if (conn) {
@@ -2686,9 +2686,8 @@ static int tcpcheck_main(struct check *check)
                         *   3: release and replace the old one on success
                         */
                        if (check->cs) {
-                               /* XXX: need to kill all CS here as well but not to free them yet */
-                               conn_full_close(check->cs->conn);
-                               retcode = -1; /* do not reuse the fd! */
+                               cs_close(check->cs);
+                               retcode = -1; /* do not reuse the fd in the caller! */
                        }
 
                        /* mark the step as started */
index 722d2f4fd61ba216b6cd95c044ad5c3fc8a11e6e..d347f472f72e076fb2f1808f26aa89ec078a4d13 100644 (file)
@@ -579,7 +579,7 @@ static int sess_update_st_con_tcp(struct stream *s)
        struct stream_interface *si = &s->si[1];
        struct channel *req = &s->req;
        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
         * 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 ?
                 * Probably not for multiple streams.
                 */
-               conn_full_close(srv_conn);
+               cs_close(srv_cs);
 
                if (si->err_type)
                        return 0;
index 9353d08ebfa611ebfe22901ac54f0021d351b72c..2c48b031b647168e884efae3cc6a2bdfb04f474a 100644 (file)
@@ -821,8 +821,7 @@ static void stream_int_shutr_conn(struct stream_interface *si)
                return;
 
        if (si_oc(si)->flags & CF_SHUTW) {
-               /* XXX: should just close cs ? */
-               conn_full_close(conn);
+               cs_close(cs);
                si->state = SI_ST_DIS;
                si->exp = TICK_ETERNITY;
        }
@@ -890,22 +889,13 @@ static void stream_int_shutw_conn(struct stream_interface *si)
                         * layer to try to signal it to the peer before we close.
                         */
                        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))) {
-                                       /* OK just a shutw, but we want the caller
-                                        * to disable polling on this FD if exists.
-                                        */
-                                       conn_cond_update_polling(conn);
-                                       return;
-                               }
+                       if (!(ic->flags & (CF_SHUTR|CF_DONT_READ))) {
+                               /* OK just a shutw, but we want the caller
+                                * to disable polling on this FD if exists.
+                                */
+                               conn_cond_update_polling(conn);
+                               return;
                        }
                }
 
@@ -914,7 +904,7 @@ static void stream_int_shutw_conn(struct stream_interface *si)
                /* we may have to close a pending connection, and mark the
                 * response buffer as shutr
                 */
-               conn_full_close(conn);
+               cs_close(cs);
                /* fall through */
        case SI_ST_CER:
        case SI_ST_QUE:
@@ -1369,11 +1359,7 @@ void stream_sock_read0(struct stream_interface *si)
 
  do_close:
        /* OK we completely close the socket here just as if we went through si_shut[rw]() */
-       conn_full_close(cs->conn);
-
-       ic->flags &= ~CF_SHUTR_NOW;
-       ic->flags |= CF_SHUTR;
-       ic->rex = TICK_ETERNITY;
+       cs_close(cs);
 
        oc->flags &= ~CF_SHUTW_NOW;
        oc->flags |= CF_SHUTW;