]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: connection: remove useless flag CO_FL_DATA_WR_SH
authorWilly Tarreau <w@1wt.eu>
Wed, 30 Aug 2017 07:59:52 +0000 (09:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Aug 2017 08:05:49 +0000 (10:05 +0200)
After careful inspection, this flag is set at exactly two places :
  - once in the health-check receive callback after receipt of a
    response
  - once in the stream interface's shutw() code where CF_SHUTW is
    always set on chn->flags

The flag was checked in the checks before deciding to send data, but
when it is set, the wake() callback immediately closes the connection
so the CO_FL_SOCK_WR_SH flag is also set.

The flag was also checked in si_conn_send(), but checking the channel's
flag instead is enough and even reveals that one check involving it
could never match.

So it's time to remove this flag and replace its check with a check of
CF_SHUTW in the stream interface. This way each layer is responsible
for its shutdown, this will ease insertion of the mux layer.

contrib/debug/flags.c
include/proto/connection.h
include/types/connection.h
src/checks.c
src/stream_interface.c

index 7b938a078d62f5c02e4d71806aaa18953b2f1db3..0989e3b9c89cb5855b6d9539184daa54d19ba733 100644 (file)
@@ -116,7 +116,6 @@ void show_conn_flags(unsigned int f)
        SHOW_FLAG(f, CO_FL_ERROR);
        SHOW_FLAG(f, CO_FL_SOCK_WR_SH);
        SHOW_FLAG(f, CO_FL_SOCK_RD_SH);
-       SHOW_FLAG(f, CO_FL_DATA_WR_SH);
        SHOW_FLAG(f, CO_FL_ADDR_TO_SET);
        SHOW_FLAG(f, CO_FL_ADDR_FROM_SET);
        SHOW_FLAG(f, CO_FL_WAIT_ROOM);
index 8c0301c1861d8db32c71c364ddcb53a5b1db73fa..9be862b40c8ffcd5de11911c33947263683da7c3 100644 (file)
@@ -438,7 +438,6 @@ static inline void conn_sock_shutw(struct connection *c)
 
 static inline void conn_data_shutw(struct connection *c)
 {
-       c->flags |= CO_FL_DATA_WR_SH;
        __conn_data_stop_send(c);
 
        /* clean data-layer shutdown */
@@ -448,7 +447,6 @@ static inline void conn_data_shutw(struct connection *c)
 
 static inline void conn_data_shutw_hard(struct connection *c)
 {
-       c->flags |= CO_FL_DATA_WR_SH;
        __conn_data_stop_send(c);
 
        /* unclean data-layer shutdown */
index a24b8585c4ce159bc8142119445e5de90c7e5b05..9724b2ce6b49b59efc477817d2ae581ee54e0a23 100644 (file)
@@ -97,10 +97,10 @@ enum {
 
        /* unused : 0x00004000 */
        /* unused : 0x00008000 */
+       /* unused : 0x00010000 */
+       /* unused : 0x00020000 */
 
        /* flags used to remember what shutdown have been performed/reported */
-       /* unused : 0x00010000 */
-       CO_FL_DATA_WR_SH    = 0x00020000,  /* DATA layer asked for shutw */
        CO_FL_SOCK_RD_SH    = 0x00040000,  /* SOCK layer was notified about shutr/read0 */
        CO_FL_SOCK_WR_SH    = 0x00080000,  /* SOCK layer asked for shutw */
 
index db805e8f9a91b573973812a6f992a7b92202e688..ba783085cbe38fc6b23f59c2be7b55e04c858e09 100644 (file)
@@ -744,7 +744,7 @@ static void event_srv_chk_w(struct connection *conn)
                goto out_wakeup;
        }
 
-       if (conn->flags & (CO_FL_SOCK_WR_SH | CO_FL_DATA_WR_SH)) {
+       if (conn->flags & CO_FL_SOCK_WR_SH) {
                /* if the output is closed, we can't do anything */
                conn->flags |= CO_FL_ERROR;
                chk_report_conn_err(conn, 0, 0);
@@ -2756,7 +2756,7 @@ static void tcpcheck_main(struct connection *conn)
                                check->bi->i = 0;
                        }
 
-                       if (conn->flags & (CO_FL_SOCK_WR_SH | CO_FL_DATA_WR_SH)) {
+                       if (conn->flags & CO_FL_SOCK_WR_SH) {
                                conn->flags |= CO_FL_ERROR;
                                chk_report_conn_err(conn, 0, 0);
                                goto out_end_tcpcheck;
index c19c1469560531c94393cee0bf264ed66d149114..c3e2c539545ae599894f571b8cf0454e207b8d08 100644 (file)
@@ -633,7 +633,7 @@ static void si_conn_send(struct connection *conn)
        /* when we're here, we already know that there is no spliced
         * data left, and that there are sendable buffered data.
         */
-       if (!(conn->flags & (CO_FL_ERROR | CO_FL_SOCK_WR_SH | CO_FL_DATA_WR_SH | CO_FL_HANDSHAKE))) {
+       if (!(conn->flags & (CO_FL_ERROR | CO_FL_SOCK_WR_SH | CO_FL_HANDSHAKE)) && !(oc->flags & CF_SHUTW)) {
                /* check if we want to inform the kernel that we're interested in
                 * sending more data after this call. We want this if :
                 *  - we're about to close after this last send and want to merge
@@ -648,8 +648,7 @@ static void si_conn_send(struct connection *conn)
 
                if ((!(oc->flags & (CF_NEVER_WAIT|CF_SEND_DONTWAIT)) &&
                     ((oc->to_forward && oc->to_forward != CHN_INFINITE_FORWARD) ||
-                     (oc->flags & CF_EXPECT_MORE))) ||
-                   ((oc->flags & (CF_SHUTW|CF_SHUTW_NOW)) == CF_SHUTW_NOW))
+                     (oc->flags & CF_EXPECT_MORE))) || (oc->flags & CF_SHUTW_NOW))
                        send_flag |= CO_SFL_MSG_MORE;
 
                if (oc->flags & CF_STREAMER)