]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: channel: Remove CF_READ_ATTACHED and report CF_READ_EVENT instead
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 20 Dec 2022 17:47:39 +0000 (18:47 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 9 Jan 2023 17:41:08 +0000 (18:41 +0100)
CF_READ_ATTACHED flag is only used in input events for stream analyzers,
CF_MASK_ANALYSER. A read event can be reported instead and this flag can be
removed. We must only take care to report a read event when the client
connection is upgraded from TCP to HTTP.

include/haproxy/channel-t.h
src/cli.c
src/stream.c

index b9b86f8657ad5d9d16cdaa71bce6c237c5d0dab5..18ebc037320c20207a9ea51d0d8ffefb3e5687c4 100644 (file)
 #define CF_STREAMER_FAST  0x00020000  /* the consumer seems to eat the stream very fast */
 
 #define CF_WROTE_DATA     0x00040000  /* some data were sent from this buffer */
-/* unused 0x00080000 */
-#define CF_READ_ATTACHED  0x00100000  /* the read side is attached for the first time */
+/* unused 0x00080000 - 0x00100000  */
 #define CF_KERN_SPLICING  0x00200000  /* kernel splicing desired for this channel */
 #define CF_READ_DONTWAIT  0x00400000  /* wake the task up after every read (eg: HTTP request) */
 #define CF_AUTO_CONNECT   0x00800000  /* consumer may attempt to establish a new connection */
 #define CF_ISRESP         0x80000000  /* 0 = request channel, 1 = response channel */
 
 /* Masks which define input events for stream analysers */
-#define CF_MASK_ANALYSER  (CF_READ_ATTACHED|CF_READ_EVENT|CF_READ_ERROR|CF_READ_TIMEOUT|CF_WRITE_EVENT|CF_WRITE_ERROR|CF_WAKE_ONCE)
+#define CF_MASK_ANALYSER  (CF_READ_EVENT|CF_READ_ERROR|CF_READ_TIMEOUT|CF_WRITE_EVENT|CF_WRITE_ERROR|CF_WAKE_ONCE)
 
 /* Mask for static flags which cause analysers to be woken up when they change */
 #define CF_MASK_STATIC    (CF_SHUTR|CF_SHUTW|CF_SHUTR_NOW|CF_SHUTW_NOW)
@@ -141,10 +140,10 @@ static forceinline char *chn_show_flags(char *buf, size_t len, const char *delim
        _(CF_WRITE_TIMEOUT, _(CF_WRITE_ERROR,
        _(CF_WAKE_WRITE, _(CF_SHUTW, _(CF_SHUTW_NOW, _(CF_AUTO_CLOSE,
        _(CF_STREAMER, _(CF_STREAMER_FAST, _(CF_WROTE_DATA,
-       _(CF_READ_ATTACHED, _(CF_KERN_SPLICING, _(CF_READ_DONTWAIT,
+       _(CF_KERN_SPLICING, _(CF_READ_DONTWAIT,
        _(CF_AUTO_CONNECT, _(CF_DONT_READ, _(CF_EXPECT_MORE,
        _(CF_SEND_DONTWAIT, _(CF_NEVER_WAIT, _(CF_WAKE_ONCE, _(CF_FLT_ANALYZE,
-       _(CF_EOI, _(CF_ISRESP))))))))))))))))))))))))))));
+       _(CF_EOI, _(CF_ISRESP)))))))))))))))))))))))))));
        /* epilogue */
        _(~0U);
        return buf;
index 0e6bba76b507cf03c8dda7d6b2e503d9048f7c42..23f77e50cb55c2e1bf8cc3ee7f5562f677f54ca2 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2785,7 +2785,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                sc_set_state(s->scb, SC_ST_INI);
                s->scb->flags &= SC_FL_ISBACK | SC_FL_DONT_WAKE; /* we're in the context of process_stream */
                s->req.flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WROTE_DATA);
-               s->res.flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_EVENT|CF_NEVER_WAIT|CF_WROTE_DATA|CF_READ_EVENT);
+               s->res.flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_EVENT|CF_NEVER_WAIT|CF_WROTE_DATA|CF_READ_EVENT);
                s->flags &= ~(SF_DIRECT|SF_ASSIGNED|SF_BE_ASSIGNED|SF_FORCE_PRST|SF_IGNORE_PRST);
                s->flags &= ~(SF_CURR_SESS|SF_REDIRECTABLE|SF_SRV_REUSED);
                s->flags &= ~(SF_ERR_MASK|SF_FINST_MASK|SF_REDISP);
index b267dbb0422adac7dfe2f056cb1b13cc42c9ff7a..a35f96d38f2e5ab52401bc0ad8ef7ac7cb79aedd 100644 (file)
@@ -294,9 +294,9 @@ int stream_upgrade_from_sc(struct stconn *sc, struct buffer *input)
                s->req.buf = *input;
                *input = BUF_NULL;
                s->req.total = (IS_HTX_STRM(s) ? htxbuf(&s->req.buf)->data : b_data(&s->req.buf));
-               s->req.flags |= (s->req.total ? CF_READ_EVENT : 0);
        }
 
+       s->req.flags |= CF_READ_EVENT; /* Always report a read event */
        s->flags &= ~SF_IGNORE;
 
        task_wakeup(s->task, TASK_WOKEN_INIT);
@@ -501,7 +501,7 @@ struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer
        s->store_count = 0;
 
        channel_init(&s->req);
-       s->req.flags |= CF_READ_ATTACHED; /* the producer is already connected */
+       s->req.flags |= CF_READ_EVENT; /* the producer is already connected */
        s->req.analysers = sess->listener ? sess->listener->analysers : sess->fe->fe_req_ana;
 
        if (IS_HTX_STRM(s)) {
@@ -567,7 +567,6 @@ struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer
                s->req.buf = *input;
                *input = BUF_NULL;
                s->req.total = (IS_HTX_STRM(s) ? htxbuf(&s->req.buf)->data : b_data(&s->req.buf));
-               s->req.flags |= (s->req.total ? CF_READ_EVENT : 0);
        }
 
        /* it is important not to call the wakeup function directly but to
@@ -937,7 +936,7 @@ static void back_establish(struct stream *s)
        rep->analysers |= strm_fe(s)->fe_rsp_ana | s->be->be_rsp_ana;
 
        se_have_more_data(s->scb->sedesc);
-       rep->flags |= CF_READ_ATTACHED; /* producer is now attached */
+       rep->flags |= CF_READ_EVENT; /* producer is now attached */
        if (conn) {
                /* real connections have timeouts
                 * if already defined, it means that a set-timeout rule has
@@ -1553,8 +1552,8 @@ static void stream_update_both_sc(struct stream *s)
        struct channel *req = &s->req;
        struct channel *res = &s->res;
 
-       req->flags &= ~(CF_READ_EVENT|CF_READ_ATTACHED|CF_WRITE_EVENT);
-       res->flags &= ~(CF_READ_EVENT|CF_READ_ATTACHED|CF_WRITE_EVENT);
+       req->flags &= ~(CF_READ_EVENT|CF_WRITE_EVENT);
+       res->flags &= ~(CF_READ_EVENT|CF_WRITE_EVENT);
 
        s->prev_conn_state = scb->state;