]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
3 years agoMINOR: stconn: turn SE_FL_WILL_CONSUME to SE_FL_WONT_CONSUME
Willy Tarreau [Fri, 27 May 2022 14:43:52 +0000 (16:43 +0200)] 
MINOR: stconn: turn SE_FL_WILL_CONSUME to SE_FL_WONT_CONSUME

This flag was the only remaining one that was inverted as a blocking
condition, requiring special handling to preset it on sedesc allocation.
Let's flip it in its definition and accessors.

3 years agoCLEANUP: stconn: rename a few "endp" arguments and variables to "sd"
Willy Tarreau [Fri, 27 May 2022 14:21:33 +0000 (16:21 +0200)] 
CLEANUP: stconn: rename a few "endp" arguments and variables to "sd"

For consistency with the few other places, let's avoid using the
confusing "endp" pointer when it designates the descriptor.

3 years agoCLEANUP: mux-pt: rename the "endp" field to "sd"
Willy Tarreau [Fri, 27 May 2022 14:17:23 +0000 (16:17 +0200)] 
CLEANUP: mux-pt: rename the "endp" field to "sd"

The stream endpoint descriptor that was named "endp" is now called "sd"
both in the mux_pt_ctx struct and in the few functions using this.

3 years agoCLEANUP: mux-fcgi: rename the "endp" field to "sd"
Willy Tarreau [Fri, 27 May 2022 14:15:32 +0000 (16:15 +0200)] 
CLEANUP: mux-fcgi: rename the "endp" field to "sd"

The stream endpoint descriptor that was named "endp" is now called "sd"
both in the fcgi_strm struct and in the few functions using this. The
name was also updated in the "show fd" output.

3 years agoCLEANUP: mux-h2: rename the "endp" field to "sd"
Willy Tarreau [Fri, 27 May 2022 14:14:10 +0000 (16:14 +0200)] 
CLEANUP: mux-h2: rename the "endp" field to "sd"

The stream endpoint descriptor that was named "endp" is now called "sd"
both in the h2s struct and in the few functions using this. The name
was also updated in the "show fd" output.

3 years agoCLEANUP: mux-h1: rename the "endp" field to "sd"
Willy Tarreau [Fri, 27 May 2022 14:12:05 +0000 (16:12 +0200)] 
CLEANUP: mux-h1: rename the "endp" field to "sd"

The stream endpoint descriptor that was named "endp" is now called "sd"
both in the h1s struct and in the few functions using this. The name
was also updated in the "show fd" output.

3 years agoCLEANUP: mux-quic: rename the "endp" field to "sd"
Willy Tarreau [Fri, 27 May 2022 14:09:35 +0000 (16:09 +0200)] 
CLEANUP: mux-quic: rename the "endp" field to "sd"

The stream endpoint descriptor that was named "endp" is now called "sd"
both in the qcs struct and in the few functions using this.

3 years agoDOC: internal: update the muxes doc to mention the stconn
Willy Tarreau [Fri, 27 May 2022 09:45:50 +0000 (11:45 +0200)] 
DOC: internal: update the muxes doc to mention the stconn

The stream connector replaced the conn_stream and the sc_conn_io_cb()
function appeared. There's no place there to mention the endpoint
descriptor, but a separate diagram showing the relation between stream
and endpoint via the connector would be nice.

3 years agoCLEANUP: stconn: replace a few remaining occurrences of CS in comments or traces
Willy Tarreau [Fri, 27 May 2022 09:23:05 +0000 (11:23 +0200)] 
CLEANUP: stconn: replace a few remaining occurrences of CS in comments or traces

A few "CS" desginating stconns were still present in code comments and
stream traces. This addresses them.

3 years agoCLEANUP: obj_type: rename OBJ_TYPE_CS to OBJ_TYPE_SC
Willy Tarreau [Fri, 27 May 2022 09:15:19 +0000 (11:15 +0200)] 
CLEANUP: obj_type: rename OBJ_TYPE_CS to OBJ_TYPE_SC

Let's apply the new name to the type as well.

3 years agoCLEANUP: stream: rename stream_upgrade_from_cs() to stream_upgrade_from_sc()
Willy Tarreau [Fri, 27 May 2022 09:11:15 +0000 (11:11 +0200)] 
CLEANUP: stream: rename stream_upgrade_from_cs() to stream_upgrade_from_sc()

It upgrades the protocol on a stream connector, let's update the name.

3 years agoCLEANUP: applet: rename appctx_cs() to appctx_sc()
Willy Tarreau [Fri, 27 May 2022 09:08:15 +0000 (11:08 +0200)] 
CLEANUP: applet: rename appctx_cs() to appctx_sc()

It returns a stream connector, not a conn_stream anymore, so let's
fix its name.

3 years agoCLEANUP: sslsock: remove only occurrence of local variable "cs"
Willy Tarreau [Fri, 27 May 2022 08:44:39 +0000 (10:44 +0200)] 
CLEANUP: sslsock: remove only occurrence of local variable "cs"

In ssl_action_wait_for_hs() the local variables called "cs" is just a
copy of s->scf that's only used once, so it can be removed. In addition
the check was removed as well since it's not possible to have a NULL SC
on a stream.

3 years agoCLEANUP: sink: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:44:25 +0000 (10:44 +0200)] 
CLEANUP: sink: rename all occurrences of stconn "cs" to "sc"

In the applet, function arguments and local variables called "cs"
were renamed to "sc" to avoid future confusion.

3 years agoCLEANUP: peers: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:44:04 +0000 (10:44 +0200)] 
CLEANUP: peers: rename all occurrences of stconn "cs" to "sc"

In the applet, function arguments and local variables called "cs"
were renamed to "sc" to avoid future confusion.

3 years agoCLEANUP: mux-pt: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:43:18 +0000 (10:43 +0200)] 
CLEANUP: mux-pt: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to
"sc" to avoid future confusion. There was also one place in traces
where "cs" used to display the stconn, which were turned to "sc".

3 years agoCLEANUP: mux-h2: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:41:24 +0000 (10:41 +0200)] 
CLEANUP: mux-h2: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to
"sc" to avoid future confusion. There were also 2 places in traces
where "cs" used to display the stconn, which were turned to "sc".
The "nb_cs" struct field and "h2_has_too_many_cs()" functions were
also renamed.

3 years agoCLEANUP: mux-h1: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:39:17 +0000 (10:39 +0200)] 
CLEANUP: mux-h1: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to
"sc" to avoid future confusion. There were also 2 places in traces
where "cs" used to display the stconn, which were turned to "sc".
h1s_upgrade_cs() and h1s_new_cs() were both renamed to _cs.

3 years agoCLEANUP: mux-fcgi: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:38:10 +0000 (10:38 +0200)] 
CLEANUP: mux-fcgi: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to
"sc" to avoid future confusion. There were also 3 places in debugging
traces where "cs" used to display the stconn, which were turned to "sc"
for similar reasons. The number of streams "nb_cs" was turned to "nb_sc".

3 years agoCLEANUP: http-client: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:37:32 +0000 (10:37 +0200)] 
CLEANUP: http-client: rename all occurrences of stconn "cs" to "sc"

In the applet, function arguments and local variables called "cs"
were renamed to "sc" to avoid future confusion.

3 years agoCLEANUP: log-forward: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:36:36 +0000 (10:36 +0200)] 
CLEANUP: log-forward: rename all occurrences of stconn "cs" to "sc"

In the log-forwarding applet, function arguments and local variables
called "cs" were renamed to "sc" to avoid future confusion.

3 years agoCLEANUP: hlua: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:35:27 +0000 (10:35 +0200)] 
CLEANUP: hlua: rename all occurrences of stconn "cs" to "sc"

In the TCP and HTTP applets, function arguments and local variables
called "cs" were renamed to "sc" to avoid future confusion.

3 years agoCLEANUP: spoe: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:34:25 +0000 (10:34 +0200)] 
CLEANUP: spoe: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables in the SPOE applet called "cs"
were renamed to "sc" to avoid future confusion.

3 years agoCLEANUP: dns: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:33:42 +0000 (10:33 +0200)] 
CLEANUP: dns: rename all occurrences of stconn "cs" to "sc"

This concerns the DNS client applet. Function arguments and local
variables called "cs" were renamed to "sc" to avoid future confusion.

3 years agoCLEANUP: cache: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:33:20 +0000 (10:33 +0200)] 
CLEANUP: cache: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to "sc"
to avoid future confusion.

3 years agoCLEANUP: applet: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:32:34 +0000 (10:32 +0200)] 
CLEANUP: applet: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to "sc"
to avoid future confusion.

3 years agoCLEANUP: cli: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:26:46 +0000 (10:26 +0200)] 
CLEANUP: cli: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to "sc"
in the various keyword handlers.

3 years agoCLEANUP: stats: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:17:46 +0000 (10:17 +0200)] 
CLEANUP: stats: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to "sc"
to avoid future confusion. Both the core functions and the ones in the
resolvers files were updated.

3 years agoCLEANUP: promex: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:16:15 +0000 (10:16 +0200)] 
CLEANUP: promex: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to "sc"
to avoid future confusion.

3 years agoCLEANUP: stream: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:13:37 +0000 (10:13 +0200)] 
CLEANUP: stream: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to "sc"
to avoid future confusion. The HTTP analyser and the backend functions
were all updated after being reviewed. Function stream_update_both_cs()
was renamed to stream_update_both_sc()

3 years agoCLEANUP: quic/h3: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:09:11 +0000 (10:09 +0200)] 
CLEANUP: quic/h3: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to "sc"
to avoid future confusion. The "nb_cs" stream-connector counter was
renamed to "nb_sc" and qc_attach_cs() was renamed to qc_attach_sc().

3 years agoCLEANUP: stconn: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:02:48 +0000 (10:02 +0200)] 
CLEANUP: stconn: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to "sc"
to avoid future confusion. The change is huge (~580 lines), so extreme
care was given not to change anything else.

3 years agoCLEANUP: connection: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:00:13 +0000 (10:00 +0200)] 
CLEANUP: connection: rename all occurrences of stconn "cs" to "sc"

Function arguments and local variables called "cs" were renamed to "sc"
to avoid future confusion.

3 years agoCLEANUP: check: rename all occurrences of stconn "cs" to "sc"
Willy Tarreau [Fri, 27 May 2022 08:04:04 +0000 (10:04 +0200)] 
CLEANUP: check: rename all occurrences of stconn "cs" to "sc"

The check struct had a "cs" field renamed to "sc", which also required
a tiny update to a few functions using it to distinguish a check from
a stream (log.c, payload.c, ssl_sample.c, tcp_sample.c, tcpcheck.c,
connection.c).

Function arguments and local variables called "cs" were renamed to "sc".
The presence of one "cs=" in the debugging traces was also turned to
"sc=" for consistency.

3 years agoDEV: flags: use "sc" for stream conns instead of "cs"
Willy Tarreau [Fri, 27 May 2022 07:57:31 +0000 (09:57 +0200)] 
DEV: flags: use "sc" for stream conns instead of "cs"

"cs" used to stand for "conn_stream" while these objects are now called
"stream connectors", "stconn" or "sc". Let's just use "sc" here.

3 years agoCLEANUP: muxes: rename "get_first_cs" to "get_first_sc"
Willy Tarreau [Fri, 27 May 2022 09:00:59 +0000 (11:00 +0200)] 
CLEANUP: muxes: rename "get_first_cs" to "get_first_sc"

This is renamed both in the mux_ops descriptor and the mux functions
themselves to accommodate the new type name.

3 years agoREORG: stconn: rename conn_stream.{c,h} to stconn.{c,h}
Willy Tarreau [Fri, 27 May 2022 07:47:12 +0000 (09:47 +0200)] 
REORG: stconn: rename conn_stream.{c,h} to stconn.{c,h}

There's no more reason for keepin the code and definitions in conn_stream,
let's move all that to stconn. The alphabetical ordering of include files
was adjusted.

3 years agoREORG: rename cs_utils.h to sc_strm.h
Willy Tarreau [Fri, 27 May 2022 07:25:10 +0000 (09:25 +0200)] 
REORG: rename cs_utils.h to sc_strm.h

This file contains all the stream-connector functions that are specific
to application layers of type stream. So let's name it accordingly so
that it's easier to figure what's located there.

The alphabetical ordering of include files was preserved.

3 years agoCLEANUP: quic: drop the name "conn_stream" from the pool variable names
Willy Tarreau [Fri, 27 May 2022 07:11:02 +0000 (09:11 +0200)] 
CLEANUP: quic: drop the name "conn_stream" from the pool variable names

QUIC was the last user of entities with "conn_stream" in their names,
though there's no more reason for this given that the pool names were
already pretty straightforward. The renaming does this:

  qc_stream_desc: pool_head_quic_conn_stream -> pool_head_quic_stream_desc
  qc_stream_buf:  pool_head_quic_conn_stream_buf -> pool_head_quic_stream_buf

3 years agoCLEANUP: stconn: rename final state manipulation functions from cs_* to sc_*
Willy Tarreau [Fri, 27 May 2022 07:03:30 +0000 (09:03 +0200)] 
CLEANUP: stconn: rename final state manipulation functions from cs_* to sc_*

This applies the following renaming. It's a bit large but pretty
mechanical:

cs_state -> sc_state  (enum)

cs_alloc_ibuf() -> sc_alloc_ibuf()
cs_is_conn_error() -> sc_is_conn_error()
cs_opposite() -> sc_opposite()
cs_report_error() -> sc_report_error()
cs_set_state() -> sc_set_state()
cs_state_bit() -> sc_state_bit()
cs_state_in() -> sc_state_in()
cs_state_str() -> sc_state_str()

3 years agoCLEANUP: stconn: rename cs_{shut,chk}* to sc_*
Willy Tarreau [Fri, 27 May 2022 07:00:19 +0000 (09:00 +0200)] 
CLEANUP: stconn: rename cs_{shut,chk}* to sc_*

This applies the following renaming:

cs_shutr() -> sc_shutr()
cs_shutw() -> sc_shutw()
cs_chk_rcv() -> sc_chk_rcv()
cs_chk_snd() -> sc_chk_snd()
cs_must_kill_conn() -> sc_must_kill_conn()

3 years agoCLEANUP: stconn: rename cs{,_get}_{src,dst} to sc_*
Willy Tarreau [Fri, 27 May 2022 06:57:21 +0000 (08:57 +0200)] 
CLEANUP: stconn: rename cs{,_get}_{src,dst} to sc_*

The following functions were renamed:

cs_src() -> sc_src()
cs_dst() -> sc_dst()
cs_get_src() -> sc_get_src()
cs_get_dst() -> sc_get_dst()

3 years agoCLEANUP: stconn: rename remaining management functions from cs_* to sc_*
Willy Tarreau [Fri, 27 May 2022 06:49:24 +0000 (08:49 +0200)] 
CLEANUP: stconn: rename remaining management functions from cs_* to sc_*

This is the end of the renaming for the generic SC management functions
and macros:

cs_applet_process() -> sc_applet_process()
cs_attach_applet()  -> sc_attach_applet()
cs_attach_mux()     -> sc_attach_mux()
cs_attach_strm()    -> sc_attach_strm()
cs_detach_app()     -> sc_detach_app()
cs_detach_endp()    -> sc_detach_endp()
cs_notify()         -> sc_notify()
cs_reset_endp()     -> sc_reset_endp()
cs_state_in()       -> sc_state_in()
cs_update()         -> sc_update()
cs_update_rx()      -> sc_update_rx()
cs_update_tx()      -> sc_update_tx()
IS_HTX_CS()         -> IS_HTX_SC()

3 years agoCLEANUP: stconn: rename cs_{new,create,free,destroy}_* to sc_*
Willy Tarreau [Fri, 27 May 2022 06:33:53 +0000 (08:33 +0200)] 
CLEANUP: stconn: rename cs_{new,create,free,destroy}_* to sc_*

This renames the following functions:

cs_new_from_endp()  -> sc_new_from_endp()
cs_new_from_strm()  -> sc_new_from_strm()
cs_new_from_check() -> sc_new_from_check()
cs_applet_create()  -> sc_applet_create()
cs_destroy()        -> sc_destroy()
cs_free()           -> sc_free()

3 years agoCLEANUP: stconn: rename cs_cant_get() to se_need_more_data()
Willy Tarreau [Wed, 25 May 2022 16:21:43 +0000 (18:21 +0200)] 
CLEANUP: stconn: rename cs_cant_get() to se_need_more_data()

An equivalent applet_need_more_data() was added as well since that function
is mostly used from applet code. It makes it much clearer that the applet
is waiting for data from the stream layer.

3 years agoCLEANUP: stconn: rename cs_{want,stop}_get() to se_{will,wont}_consume()
Willy Tarreau [Wed, 25 May 2022 16:12:11 +0000 (18:12 +0200)] 
CLEANUP: stconn: rename cs_{want,stop}_get() to se_{will,wont}_consume()

These ones are essentially for the stream endpoint, let's give them a
name that matches the intent. Equivalent versions were provided in the
applet namespace to ease code legibility.

3 years agoCLEANUP: stconn: remove cs_tx_blocked() and cs_tx_endp_ready()
Willy Tarreau [Wed, 25 May 2022 16:05:53 +0000 (18:05 +0200)] 
CLEANUP: stconn: remove cs_tx_blocked() and cs_tx_endp_ready()

These ones were used exactly once and together, in sc_is_send_allowed().
No need to give them confusing names, instead let's just put the flags,
they're way more explicit, and drop the two functions.

3 years agoCLEANUP: stconn: rename SE_FL_WANT_GET to SE_FL_WILL_CONSUME
Willy Tarreau [Wed, 25 May 2022 16:00:26 +0000 (18:00 +0200)] 
CLEANUP: stconn: rename SE_FL_WANT_GET to SE_FL_WILL_CONSUME

This flag indicates the that stream endpoint is willing to consume output
data from the stream. Its new name makes this more explicit. The function
names will be updated accordingly, which will remove the disturbing "get"
everywhere.

3 years agoMEDIUM: stconn: move the RXBLK flags to the stream connector
Willy Tarreau [Wed, 25 May 2022 14:36:21 +0000 (16:36 +0200)] 
MEDIUM: stconn: move the RXBLK flags to the stream connector

The following flags are not at all related to the endpoint but to the
connector itself:
  - SE_FL_RXBLK_ROOM
  - SE_FL_RXBLK_BUFF
  - SE_FL_RXBLK_CHAN

As such they have no business staying in the endpoint descriptor and
they must move to the stream connector. They've also been renamed
accordingly to better match what they correspond to (the same name
as the function that sets them).

The rare occurrences of cs_rx_blocked() were replaced by an explicit
test on the list of flags. The reason is that cs_rx_blocked() used to
preserve some tests that are not needed at certain places since already
known. For the same reason SE_FL_RXBLK_ANY wasn't converted. As such it
will later be possible to carefully review these few locations and
eliminate the unneeded flags from the tests. No particular function
was made to test them since they're explicit enough.

It now looks like ci_putchk() and friends could very well place the flag
themselves on the connector when they detect a buffer full condition, as
this would significantly simplify the high-level API. But all usages must
first be reviewed before this simplification can be done. For now it
remains done by applet_put*() instead.

3 years agoCLEANUP: stconn: rename SE_FL_RX_WAIT_EP to SE_FL_HAVE_NO_DATA
Willy Tarreau [Wed, 25 May 2022 14:01:38 +0000 (16:01 +0200)] 
CLEANUP: stconn: rename SE_FL_RX_WAIT_EP to SE_FL_HAVE_NO_DATA

It's more explicit this way. The cs_rx_endp_ready() function could be
removed so that the flag is directly tested. In the future it should
be inverted and the few places where it's set (or preserved via
SE_FL_APP_MASK) could be dropped.

3 years agoMINOR: stconn: add sc_is_recv_allowed() to check for ability to receive
Willy Tarreau [Wed, 25 May 2022 13:00:44 +0000 (15:00 +0200)] 
MINOR: stconn: add sc_is_recv_allowed() to check for ability to receive

At plenty of places we combine multiple flags checks to determine if we
can receive (endp_ready, rx_blocked, cf_shutr etc). Let's group them
under a single function that is meant to replace existing tests.

Some tests were only checking the rxblk flags at the connection level,
so for now they were not converted, this requires a bit of auditing
first, and probably a test to determine whether or not to check for
cf_shutr (e.g. there is none if no stream is present).

3 years agoMINOR: stconn: start to rename cs_rx_endp_{more,done}() to se_have_{no_,}more_data()
Willy Tarreau [Wed, 25 May 2022 13:42:03 +0000 (15:42 +0200)] 
MINOR: stconn: start to rename cs_rx_endp_{more,done}() to se_have_{no_,}more_data()

The analysis of cs_rx_endp_more() showed that the purpose is for a stream
endpoint to inform the connector that it's ready to deliver more data to
that one, and conversely cs_rx_endp_done() that it's done delivering data
so it should not be bothered again for this.

This was modified two ways:
  - the operation is no longer performed on the connector but on the
    endpoint so that there is no more doubt when reading applet code
    about what this rx refers to; it's the endpoint that has more or
    no more data.

  - an applet implementation is also provided and mostly used from
    applet code since it saves the caller from having to access the
    endpoint descriptor.

It's visible that the flag ought to be inverted because some places
have to set it by default for no reason.

3 years agoCLEANUP: stconn: rename cs_rx_buff_{blk,rdy} to sc_{need,have}_buff()
Willy Tarreau [Wed, 25 May 2022 05:48:07 +0000 (07:48 +0200)] 
CLEANUP: stconn: rename cs_rx_buff_{blk,rdy} to sc_{need,have}_buff()

These functions are used by the application layer to disable or enable
reading at the stream connector's level when the input buffer failed to
be allocated (or was finally allocated). The new names makes things
clearer.

3 years agoCLEANUP: stconn: rename cs_rx_chan_{blk,rdy} to sc_{wont,will}_read()
Willy Tarreau [Wed, 25 May 2022 05:35:53 +0000 (07:35 +0200)] 
CLEANUP: stconn: rename cs_rx_chan_{blk,rdy} to sc_{wont,will}_read()

These functions were used by the channel to inform the lower layer
whether reading was acceptable or not. Usually this directly mimmicks
the CF_DONT_READ flag from the channel, which may be set when it's
desired not to buffer incoming data that will not be processed, or
that the buffer wants to be flushed before starting to read again,
or that bandwidth limiting might be enforced, etc. It's always a
policy reason, not a purely resource-based one.

3 years agoCLEANUP: stconn: rename cs_rx_room_{blk,rdy} to sc_{need,have}_room()
Willy Tarreau [Wed, 25 May 2022 05:29:36 +0000 (07:29 +0200)] 
CLEANUP: stconn: rename cs_rx_room_{blk,rdy} to sc_{need,have}_room()

The new name mor eclearly indicates that a stream connector cannot make
any more progress because it needs room in the channel buffer, or that
it may be unblocked because the buffer now has more room available. The
testing function is sc_waiting_room(). This is mostly used by applets.
Note that the flags will change soon.

3 years agoMEDIUM: stconn: take SE_FL_APPLET_NEED_CONN out of the RXBLK_ANY flags
Willy Tarreau [Tue, 24 May 2022 14:56:55 +0000 (16:56 +0200)] 
MEDIUM: stconn: take SE_FL_APPLET_NEED_CONN out of the RXBLK_ANY flags

This makes SE_FL_APPLET_NEED_CONN autonomous, in that we check for it
everywhere we have a relevant cs_rx_blocked(), so that the flag doesn't
need anymore to be covered by cs_rx_blocked(). Indeed, this flag doesn't
really translate a receive blocking condition but rather a refusal to
wake up an applet that is waiting for a connection to finish to setup.

This also ensures we will not risk to set it back on a new endpoint
after cs_reset_endp() via SE_FL_APP_MASK, because the flag being
specific to the endpoint only and not to the connector, we don't
want to preserve it when replacing the endpoint.

It's possible that cs_chk_rcv() could later be further simplified if
we can demonstrate that the two tests in it can be merged.

3 years agoMINOR: stconn: rename SE_FL_RXBLK_CONN to SE_FL_APPLET_NEED_CONN
Willy Tarreau [Tue, 24 May 2022 14:49:03 +0000 (16:49 +0200)] 
MINOR: stconn: rename SE_FL_RXBLK_CONN to SE_FL_APPLET_NEED_CONN

This flag is exclusively used when a front applet needs to wait for the
other side to connect (or fail to). Let's give it a more explicit name
and remove the ambiguous function that was used only once.

This also ensures we will not risk to set it back on a new endpoint
after cs_reset_endp() via SE_FL_APP_MASK, because the flag being
specific to the endpoint only and not to the connector, we don't
want to preserve it when replacing the endpoint.

3 years agoMEDIUM: stconn: remove SE_FL_RXBLK_SHUT
Willy Tarreau [Tue, 24 May 2022 14:22:24 +0000 (16:22 +0200)] 
MEDIUM: stconn: remove SE_FL_RXBLK_SHUT

This flag is no more needed, it was only set on shut read to be tested
by cs_rx_blocked() which is now properly tested for shutr as well. The
cs_rx_blk_shut() calls were removed. Interestingly it allowed to remove
a special case in the L7 retry code.

This also ensures we will not risk to set it back on a new endpoint
after cs_reset_endp() via SE_FL_APP_MASK.

3 years agoMEDIUM: stconn: always rely on CF_SHUTR in addition to cs_rx_blocked()
Willy Tarreau [Tue, 24 May 2022 14:18:11 +0000 (16:18 +0200)] 
MEDIUM: stconn: always rely on CF_SHUTR in addition to cs_rx_blocked()

One flag (RXBLK_SHUT) is always set with CF_SHUTR, so in order to remove
it, we first need to make sure we always check for CF_SHUTR where
cs_rx_blocked() is being used.

3 years agoMINOR: stconn: remove calls to cs_done_get()
Willy Tarreau [Tue, 24 May 2022 08:39:15 +0000 (10:39 +0200)] 
MINOR: stconn: remove calls to cs_done_get()

It was only called after setting SHUTW on the output channel, and since
it's now handled by sc_is_send_allowed() we don't need it anymore.

3 years agoMINOR: stconn: consider CF_SHUTW for sc_is_send_allowed()
Willy Tarreau [Tue, 24 May 2022 07:11:17 +0000 (09:11 +0200)] 
MINOR: stconn: consider CF_SHUTW for sc_is_send_allowed()

When a shutdown(WR) is performed, send is no longer allowed, and that is
currently handled by the explicit cs_done_get() in the various shutw()
calls. That's a bit ugly and complicated for no reason, let's simply
integrate the test of SHUTW in sc_is_send_allowed().

Note that the test could also be added wherever sc_is_send_allowed() is
used but for now proceeding like this limits the changes.

3 years agoCLEANUP: stconn: use a single function to know if SC may send to SE
Willy Tarreau [Tue, 24 May 2022 06:49:24 +0000 (08:49 +0200)] 
CLEANUP: stconn: use a single function to know if SC may send to SE

sc_is_send_allowed() is now used everywhere instead of the combination
of cs_tx_endp_ready() && !cs_tx_blocked(). There's no place where we
need them individually thus it's simpler. The test was placed in cs_util
as we'll complete it later.

3 years agoCLEANUP: stconn: make a few functions take a const argument
Willy Tarreau [Tue, 24 May 2022 07:08:33 +0000 (09:08 +0200)] 
CLEANUP: stconn: make a few functions take a const argument

A number of functions in cs_utils.h are not usable from functions taking
a const because they're not declared as using const, despite never
modifying the stconn. Let's address this for the following ones:

  sc_ic(), sc_oc(), sc_ib(), sc_ob(), sc_strm_task(),
  cs_opposite(), sc_conn_ready(), cs_src(), cs_dst(),

3 years agoCLEANUP: stconn: rename cs_ep_set_error() to se_fl_set_error()
Willy Tarreau [Wed, 18 May 2022 16:15:18 +0000 (18:15 +0200)] 
CLEANUP: stconn: rename cs_ep_set_error() to se_fl_set_error()

First it applies to the stream endpoint and not the conn_stream, and
second it only tests and touches the flags so it makes sense to call
it se_fl_ like other functions which only manipulate the flags, as
it's just a special case of flags.

3 years agoCLEANUP: stconn: rename cs_conn_get_first() to conn_get_first_sc()
Willy Tarreau [Wed, 18 May 2022 16:11:27 +0000 (18:11 +0200)] 
CLEANUP: stconn: rename cs_conn_get_first() to conn_get_first_sc()

It returns an stconn from a connection and not the opposite, so the name
change was more appropriate. In addition it was moved to connection.h
which manipulates the connection stuff, and it happens that only
connection.c uses it.

3 years agoCLEANUP: stconn: rename cs_conn_*() to sc_conn_*()
Willy Tarreau [Wed, 18 May 2022 16:06:53 +0000 (18:06 +0200)] 
CLEANUP: stconn: rename cs_conn_*() to sc_conn_*()

The following functions which act on a connection-based stream connector
were renamed to sc_conn_* (~60 places):

  cs_conn_drain_and_shut
  cs_conn_process
  cs_conn_read0
  cs_conn_ready
  cs_conn_recv
  cs_conn_send
  cs_conn_shut
  cs_conn_shutr
  cs_conn_shutw

3 years agoCLEANUP: stconn: rename cs_get_data_name() to sc_get_data_name()
Willy Tarreau [Wed, 18 May 2022 16:00:31 +0000 (18:00 +0200)] 
CLEANUP: stconn: rename cs_get_data_name() to sc_get_data_name()

Only used twice to dump stream debug info.

3 years agoCLEANUP: stconn: rename __cs_endp_target() to __sc_endp()
Willy Tarreau [Wed, 18 May 2022 15:56:13 +0000 (17:56 +0200)] 
CLEANUP: stconn: rename __cs_endp_target() to __sc_endp()

The function returns the real stream endpoint so since there's no more
confusion around the terminology, let's drop "target".

3 years agoCLEANUP: stconn: rename cs_appctx() to sc_appctx()
Willy Tarreau [Wed, 18 May 2022 15:58:02 +0000 (17:58 +0200)] 
CLEANUP: stconn: rename cs_appctx() to sc_appctx()

Nothing special, just s/cs/sc/, roughly 50-60 entries.

3 years agoCLEANUP: stconn: rename cs_conn_mux() to sc_mux_ops()
Willy Tarreau [Wed, 18 May 2022 15:51:19 +0000 (17:51 +0200)] 
CLEANUP: stconn: rename cs_conn_mux() to sc_mux_ops()

This effectively returns the mux_ops from the connection when it exists
on an stconn.

3 years agoCLEANUP: stconn: rename cs_mux() to sc_mux_strm()
Willy Tarreau [Wed, 18 May 2022 14:28:02 +0000 (16:28 +0200)] 
CLEANUP: stconn: rename cs_mux() to sc_mux_strm()

The function doesn't return a pointer to the mux but to the mux stream
(h1s, h2s etc). Let's adjust its name to reflect this. It's rarely used,
the name can be enlarged a bit. And of course s/cs/sc to accommodate for
the updated name.

3 years agoCLEANUP: stconn: rename cs_conn() to sc_conn()
Willy Tarreau [Wed, 18 May 2022 14:23:22 +0000 (16:23 +0200)] 
CLEANUP: stconn: rename cs_conn() to sc_conn()

It's mostly used from upper layers. Both the checked and unchecked
functions were updated, or ~150 entries.

3 years agoCLEANUP: stconn: rename cs_{check,strm,strm_task} to sc_strm_*
Willy Tarreau [Wed, 18 May 2022 14:10:52 +0000 (16:10 +0200)] 
CLEANUP: stconn: rename cs_{check,strm,strm_task} to sc_strm_*

These functions return the app-layer associated with an stconn, which
is a check, a stream or a stream's task. They're used a lot to access
channels, flags and for waking up tasks. Let's just name them
appropriately for the stream connector.

3 years agoCLEANUP: stconn: rename cs_{i,o}{b,c} to sc_{i,o}{b,c}
Willy Tarreau [Wed, 18 May 2022 13:55:18 +0000 (15:55 +0200)] 
CLEANUP: stconn: rename cs_{i,o}{b,c} to sc_{i,o}{b,c}

We're starting to propagate the stream connector's new name through the
API. Most call places of these functions that retrieve the channel or its
buffer are in applets. The local variable names are not changed in order
to keep the changes small and reviewable. There were ~92 uses of cs_ic(),
~96 of cs_oc() (due to co_get*() being less factorizable than ci_put*),
and ~5 accesses to the buffer itself.

3 years agoCLEANUP: applet: use applet_put*() everywhere possible
Willy Tarreau [Wed, 18 May 2022 13:07:19 +0000 (15:07 +0200)] 
CLEANUP: applet: use applet_put*() everywhere possible

This applies the change so that the applet code stops using ci_putchk()
and friends everywhere possible, for the much saferapplet_put*() instead.
The change is mechanical but large. Two or three functions used to have no
appctx and a cs derived from the appctx instead, which was a reminiscence
of old times' stream_interface. These were simply changed to directly take
the appctx. No sensitive change was performed, and the old (more complex)
API is still usable when needed (e.g. the channel is already known).

The change touched roughly a hundred of locations, with no less than 124
lines removed.

It's worth noting that the stats applet, the oldest of the series, could
get a serious lifting, as it's still very channel-centric instead of
propagating the appctx along the chain. Given that this code doesn't
change often, there's no emergency to clean it up but it would look
better.

3 years agoMINOR: applet: add new wrappers to put chk/blk/str/chr to channel from appctx
Willy Tarreau [Wed, 18 May 2022 09:38:31 +0000 (11:38 +0200)] 
MINOR: applet: add new wrappers to put chk/blk/str/chr to channel from appctx

The vast majority of calls to ci_putchk() etc are performed from applets
which directly know an endpoint. Figuring the correct API (writing into
input channel etc) isn't trivial for newcomers, and knowing that they
must mark the flag indicating a buffer full condition isn't trivial
either.

Here we're adding wrappers to these functions but to be used directly
from the appctx. That's already what is being done in multiple steps in
the applet code, where the endp is derived from the appctx, then the cs
from the endp, then the stream from the cs, then the channel from the
stream, and so on. But this time the function doesn't require to know
much of the internals, applet_putchr() writes a char from the appctx,
and marks the buffer full if needed. Period. This will allow to remove
a significant amount of obscure ci_putchk() and cs_ic() calls from the
code, hence a significant number of possible mistakes.

3 years agoMEDIUM: stconn: merge the app_ops and the data_cb fields
Willy Tarreau [Wed, 18 May 2022 08:17:16 +0000 (10:17 +0200)] 
MEDIUM: stconn: merge the app_ops and the data_cb fields

For historical reasons (stream-interface and connections), we used to
require two independent fields for the application level callbacks and
the transport-level functions. Over time the distinction faded away so
much that the low-level functions became specific to the application
and conversely. For example, applets may only work with streams on top
since they rely on the channels, and the stream-level functions differ
between applets and connections. Right now the application level only
contains a wake() callback and the low-level ones contain the functions
that act at the lower level to perform the shutr/shutw and at the upper
level to notify about readability and writability. Let's just merge them
together into a single set and get rid of this confusing distinction.
Note that the check ops do not define any app-level function since these
are only called by streams.

3 years agoMINOR: conn_stream: test the various ops functions before calling them
Willy Tarreau [Tue, 24 May 2022 06:17:58 +0000 (08:17 +0200)] 
MINOR: conn_stream: test the various ops functions before calling them

We currently call all ->shutr, ->chk_snd etc from ->ops unconditionally,
while the ->wake() call from data_cb is checked. Better check ops as
well for consistency, this will help get them merged.

3 years agoMINOR: check: export wake_srv_chk()
Willy Tarreau [Wed, 18 May 2022 07:11:52 +0000 (09:11 +0200)] 
MINOR: check: export wake_srv_chk()

We'll need it to centralize the stream connectors definitions.

3 years agoCLEANUP: stconn: tree-wide rename stconn states CS_ST/SB_* to SC_ST/SB_*
Willy Tarreau [Tue, 17 May 2022 17:47:17 +0000 (19:47 +0200)] 
CLEANUP: stconn: tree-wide rename stconn states CS_ST/SB_* to SC_ST/SB_*

This also follows the natural naming. There are roughly 238 changes, all
totally trivial. conn_stream-t.h has become completely void of any
"conn_stream" related stuff now (except its name).

3 years agoCLEANUP: stconn: tree-wide rename stream connector flags CS_FL_* to SC_FL_*
Willy Tarreau [Tue, 17 May 2022 17:44:42 +0000 (19:44 +0200)] 
CLEANUP: stconn: tree-wide rename stream connector flags CS_FL_* to SC_FL_*

This follows the natural naming. There are roughly 100 changes, all
totally trivial.

3 years agoCLEANUP: stream: rename "csf" and "csb" to "scf" and "scb"
Willy Tarreau [Tue, 17 May 2022 17:40:40 +0000 (19:40 +0200)] 
CLEANUP: stream: rename "csf" and "csb" to "scf" and "scb"

These are the stream connectors, let's give them consistent names. The
patch is large (405 locations) but totally trivial.

3 years agoCLEANUP: stdesc: rename the stream connector ->cs field to ->sc
Willy Tarreau [Wed, 18 May 2022 05:43:52 +0000 (07:43 +0200)] 
CLEANUP: stdesc: rename the stream connector ->cs field to ->sc

This is a rename of this field. Most of the places were in muxes, but
were already factored with the previous series adding *_sc().

3 years agoCLEANUP: mux-pt: add and use pt_sc() to retrieve the stream connector
Willy Tarreau [Wed, 18 May 2022 05:36:10 +0000 (07:36 +0200)] 
CLEANUP: mux-pt: add and use pt_sc() to retrieve the stream connector

This is better and easier to adapt than pt->endp->cs.

3 years agoCLEANUP: mux-fcgi: add and use fcgi_strm_sc() to retrieve the stream connector
Willy Tarreau [Wed, 18 May 2022 05:34:16 +0000 (07:34 +0200)] 
CLEANUP: mux-fcgi: add and use fcgi_strm_sc() to retrieve the stream connector

This is better and easier to adapt than fstrm->endp->cs.

3 years agoCLEANUP: mux-h2: add and use h2s_sc() to retrieve the stream connector
Willy Tarreau [Wed, 18 May 2022 05:31:41 +0000 (07:31 +0200)] 
CLEANUP: mux-h2: add and use h2s_sc() to retrieve the stream connector

This is better and easier to adapt than h2s->endp->cs.

3 years agoCLEANUP: mux-h1: add and use h1s_sc() to retrieve the stream connector
Willy Tarreau [Wed, 18 May 2022 05:27:14 +0000 (07:27 +0200)] 
CLEANUP: mux-h1: add and use h1s_sc() to retrieve the stream connector

This is better and easier to adapt than h1s->endp->cs.

3 years agoCLEANUP: conn_stream: tree-wide rename to stconn (stream connector)
Willy Tarreau [Tue, 17 May 2022 17:07:51 +0000 (19:07 +0200)] 
CLEANUP: conn_stream: tree-wide rename to stconn (stream connector)

This renames the "struct conn_stream" to "struct stconn" and updates
the descriptions in all comments (and the rare help descriptions) to
"stream connector" or "connector". This touches a lot of files but
the change is minimal. The local variables were not even renamed, so
there's still a lot of "cs" everywhere.

3 years agoCLEANUP: conn_stream: rename cs_app_* to sc_app_*
Willy Tarreau [Tue, 17 May 2022 16:28:19 +0000 (18:28 +0200)] 
CLEANUP: conn_stream: rename cs_app_* to sc_app_*

Let's start to introduce the stream connector at the app_ops level.
This is entirely self-contained into conn_stream.c. The functions
were also updated to reflect the new name, and the comments were
updated.

3 years agoCLEANUP: conn_stream: rename the conn_stream's endp to sedesc
Willy Tarreau [Tue, 17 May 2022 16:20:02 +0000 (18:20 +0200)] 
CLEANUP: conn_stream: rename the conn_stream's endp to sedesc

Just like for the appctx, this is a pointer to a stream endpoint descriptor,
so let's make this explicit and not confuse it with the full endpoint. There
are very few changes thanks to the preliminary refactoring of the flags
manipulation.

3 years agoCLEANUP: applet: rename the sedesc pointer from "endp" to "sedesc"
Willy Tarreau [Tue, 17 May 2022 16:05:31 +0000 (18:05 +0200)] 
CLEANUP: applet: rename the sedesc pointer from "endp" to "sedesc"

Now at least it makes it obvious that it's the stream endpoint descriptor
and not an endpoint. There were few changes thanks to the previous refactor
of the flags.

3 years agoCLEANUP: conn_stream: rename cs_endpoint to sedesc (stream endpoint descriptor)
Willy Tarreau [Tue, 17 May 2022 15:53:22 +0000 (17:53 +0200)] 
CLEANUP: conn_stream: rename cs_endpoint to sedesc (stream endpoint descriptor)

After some discussion we found that the cs_endpoint was precisely the
descriptor for a stream endpoint, hence the naturally coming name,
stream endpoint constructor.

This patch renames only the type everywhere and the new/init/free functions
to remain consistent with it. Future patches will address field names and
argument names in various code areas.

3 years agoCLEANUP: conn_stream: rename the cs_endpoint's target to "se"
Willy Tarreau [Mon, 16 May 2022 15:29:42 +0000 (17:29 +0200)] 
CLEANUP: conn_stream: rename the cs_endpoint's target to "se"

That's the "stream endpoint" pointer. Let's change it now while it's
not much spread. The function __cs_endp_target() wasn't yet renamed
because that will change more globally soon.

3 years agoCLEANUP: conn_stream: rename the stream endpoint flags CS_EP_* to SE_FL_*
Willy Tarreau [Tue, 17 May 2022 15:04:55 +0000 (17:04 +0200)] 
CLEANUP: conn_stream: rename the stream endpoint flags CS_EP_* to  SE_FL_*

Let's now use the new flag names for the stream endpoint.

3 years agoCLEANUP: conn_stream: apply endp_flags.cocci tree-wide
Willy Tarreau [Tue, 17 May 2022 14:31:36 +0000 (16:31 +0200)] 
CLEANUP: conn_stream: apply endp_flags.cocci tree-wide

This changes all main uses of endp->flags to the se_fl_*() equivalent
by applying coccinelle script endp_flags.cocci. The se_fl_*() functions
themselves were manually excluded from the change, of course.

Note: 144 locations were touched, manually reviewed and found to be OK.

The script was applied with all includes:

  spatch --in-place --recursive-includes -I include --sp-file $script $files

3 years agoDEV: coccinelle: add endp_flags.cocci
Willy Tarreau [Tue, 17 May 2022 14:30:44 +0000 (16:30 +0200)] 
DEV: coccinelle: add endp_flags.cocci

This one turns the various forms of "endp->flags <op> value" to their
se_fl_<op>(cs) equivalent. That's basically the same as the previous
one except that it acts on the stream endpoint itself instead of the
conn_stream.

3 years agoCLEANUP: conn_stream: apply cs_endp_flags.cocci tree-wide
Willy Tarreau [Tue, 17 May 2022 14:10:17 +0000 (16:10 +0200)] 
CLEANUP: conn_stream: apply cs_endp_flags.cocci tree-wide

This changes all main uses of cs->endp->flags to the sc_ep_*() equivalent
by applying coccinelle script cs_endp_flags.cocci.

Note: 143 locations were touched, manually reviewed and found to be OK,
except a single one that was adjusted in cs_reset_endp() where the flags
are read and filtered to be used as-is and not as a boolean, hence was
replaced with sc_ep_get() & $FLAGS.

The script was applied with all includes:

  spatch --in-place --recursive-includes -I include --sp-file $script $files

3 years agoDEV: coccinelle: add cs_endp_flags.cocci
Willy Tarreau [Tue, 17 May 2022 14:08:36 +0000 (16:08 +0200)] 
DEV: coccinelle: add cs_endp_flags.cocci

This one turns the various forms of "cs->endp->flags <op> value" to
their sc_ep_<op>(cs) equivalent.

3 years agoMINOR: conn_stream: add new sets of functions to set/get endpoint flags
Willy Tarreau [Tue, 17 May 2022 13:39:33 +0000 (15:39 +0200)] 
MINOR: conn_stream: add new sets of functions to set/get endpoint flags

At plenty of places we need to manipulate the conn_stream's endpoint just
to set or clear a flag. This patch adds a handful of functions to perform
the common operations (clr/set/get etc) on these flags at both the endpoint
and at the conn_stream level.

The functions were named after the target names, i.e. se_fl_*() to act on
the stream endpoint flags, and sc_ep_* to manipulate the endpoint flags
from the stream connector (currently conn_stream).

For now they're not used.

3 years agoCLEANUP: conn_stream: rename the cs_endpoint's context to "conn"
Willy Tarreau [Mon, 16 May 2022 15:17:16 +0000 (17:17 +0200)] 
CLEANUP: conn_stream: rename the cs_endpoint's context to "conn"

This one is exclusively used by the connection, regardless its generic
name "ctx" is rather confusing. Let's make it a struct connection* and
call it "conn". This way there's no doubt about what it is and there's
no way it will be used by accident by being taken for something else.