From 2357718217df41f02a87c0ae9ded3e91f97925ab Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 20 Dec 2022 18:47:39 +0100 Subject: [PATCH] MEDIUM: channel: Remove CF_READ_ATTACHED and report CF_READ_EVENT instead 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 | 9 ++++----- src/cli.c | 2 +- src/stream.c | 11 +++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/haproxy/channel-t.h b/include/haproxy/channel-t.h index b9b86f865..18ebc0373 100644 --- a/include/haproxy/channel-t.h +++ b/include/haproxy/channel-t.h @@ -104,8 +104,7 @@ #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 */ @@ -121,7 +120,7 @@ #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; diff --git a/src/cli.c b/src/cli.c index 0e6bba76b..23f77e50c 100644 --- 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); diff --git a/src/stream.c b/src/stream.c index b267dbb04..a35f96d38 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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;