]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
3 years agoMINOR: tcp_sample: clarifying samples support per os, for further expansion.
David CARLIER [Mon, 11 Apr 2022 11:41:24 +0000 (12:41 +0100)] 
MINOR: tcp_sample: clarifying samples support per os, for further expansion.

While there is some overlap between what each OS provides in terms of
retrievable info, each set is not a real subset of another one and this
results in increasing complexity when trying to add support for new OSes.
Let's just condition each item to the OS that support it. It's not pretty
but at least it will avoid a real mess later.

Note that fc_rtt and fc_rttvar are supported on any OS that has TCP_INFO,
not just linux/freebsd/netbsd, so we continue to expose them unconditionally.

3 years agoBUG/MEDIUM: compression: Don't forget to update htx_sl and http_msg flags
Christopher Faulet [Fri, 15 Apr 2022 13:32:03 +0000 (15:32 +0200)] 
BUG/MEDIUM: compression: Don't forget to update htx_sl and http_msg flags

If the response is compressed, we must update the HTX start-line flags and
the HTTP message flags. It is especially important if there is another
filter enabled. Otherwise, there is no way to know the C-L header was
removed and T-E one was added. Except by looping on headers.

This patch is related to the issue #1660. It must backported as far as 2.0
(for HTX part only).

3 years agoBUG/MEDIUM: fcgi-app: Use http_msg flags to know if C-L header can be added
Christopher Faulet [Fri, 15 Apr 2022 13:26:24 +0000 (15:26 +0200)] 
BUG/MEDIUM: fcgi-app: Use http_msg flags to know if C-L header can be added

Instead of relying on the HTX start-line flags, it is better to rely on
http_msg flags to know if a content-length header can be added or not. In
addition, if the header is added, HTTP_MSGF_CNT_LEN flag must be added.

Because of this bug, an invalid message can be emitted when the response is
compressed because it may contain C-L and a T-E headers.

This patch should fix the issue #1660. It must be backported as far as 2.2.

3 years agoBUG/MEDIUM: quic: properly clean frames on stream free
Amaury Denoyelle [Fri, 15 Apr 2022 09:47:03 +0000 (11:47 +0200)] 
BUG/MEDIUM: quic: properly clean frames on stream free

A released qc_stream_desc is freed as soon as all its buffer content has
been acknowledged. However, it may still contains other frames waiting
for ACK pointing to deleted buffer content. This can happen on
retransmission.

When freeing a qc_stream_desc, free all its frames in acked_frms tree to
fix memory leak. This may also possibly fix a crash on retransmission.
Now, the frames are properly removed from a packet. This ensure we do
not retransmit a frame whose buffer is deallocated.

3 years agoBUG/MEDIUM: connection: Don't crush context pointer location if it is a CS
Christopher Faulet [Fri, 15 Apr 2022 08:57:09 +0000 (10:57 +0200)] 
BUG/MEDIUM: connection: Don't crush context pointer location if it is a CS

The issue only concerns the backend connection. The conn-stream is now owned
by the stream and persists during all the stream life. Thus we must not
crush it when the backend connection is released.

It is 2.6-specific. No backport is needed.

3 years agoMINOR: extcheck: fill in the server's UNIX socket address when known
Willy Tarreau [Thu, 14 Apr 2022 17:51:02 +0000 (19:51 +0200)] 
MINOR: extcheck: fill in the server's UNIX socket address when known

While it's often a pain to try to figure a UNIX socket address, the
server ones are reliable and may be emitted in the check provided
they are retrieved in time. We cannot rely on addr_to_str() because
it only reports "unix" since it may be used to log client addresses
or listener addresses (which are renamed).

The address length was extended to 256 chars to deal with long paths
as previously it was limited to INET6_ADDRSTRLEN+1.

This addresses github issue #101. There's no point backporting this,
external checks are almost never used.

3 years agoCLEANUP: extcheck: do not needlessly preset the server's address/port
Willy Tarreau [Thu, 14 Apr 2022 17:49:50 +0000 (19:49 +0200)] 
CLEANUP: extcheck: do not needlessly preset the server's address/port

During the config parsing we preset the server's address and port, but
that's pointless since it's replaced during each check in order to deal
with the possibility that the address was changed since.

3 years agoBUG/MEDIUM: stream: do not abort connection setup too early
Willy Tarreau [Thu, 14 Apr 2022 15:39:48 +0000 (17:39 +0200)] 
BUG/MEDIUM: stream: do not abort connection setup too early

Github issue #472 reports a problem with short client connections making
stick-table entries disappear. The problem is in fact totally different
and stems at the connection establishment step.

What happens is that the stick-table there has a single entry. The
"stick-on" directive is forced to purge an existing entry before being
able to create a new one. The new entry will be committed during the
call to process_store_rules() on the response path.

But if the client sends the FIN immediately after the connection is set
up (e.g. using nc -z) then the SHUTR is received and will cancel the
connection setup just after it starts. This cancellation will induce a
call to cs_shutw() which will in turn leave the server-side state in
ST_DIS. This transition from ST_CON to ST_DIS doesn't belong to the
list of handled transition during the connection setup so it will be
handled right after on the regular path, causing the connection to be
closed. Because of this, we never pass through back_establish() and
the backend's analysers are never set on the response channel, which
is why process_store_rules() is not called and the stick-tables entry
never committed.

The comment above the code that causes this transition clearly says
that the function is to be used after the connection is established
with the server, but there's no such protection, and we always have
the AUTO_CLOSE flag there (but there's hardly any available condition
to eliminate it).

This patch adds a test for the connection not being in ST_CON or for
option abortonclose being set. It's sufficient to do the job and it
should not cause issues.

One concern was that the transition could happen during cs_recv()
after the connection switches from CON to RDY then the read0 would
be taken into account and would cause DIS to appear, which is not
handled either. But that cannot happen because cs_recv() doesn't do
anything until it's in ST_EST state, hence the read0() cannot be
called from CON/RDY. Thus the transition from CON to DIS is only
possible in back_handle_st_con() and back_handle_st_rdy() both of
which are called when dealing with the transition already, or when
abortonclose is set and the client aborts before connect() succeeds.

It's possible that some further improvements could be made to detect
this specific transition but it doesn't seem like anything would have
to be added.

This issue was first reported on 2.1. The abortonclose area is very
sensitive so it would be wise to backport slowly, and probably no
further than 2.4.

3 years agoBUILD: compiler: use a more portable set of asm(".weak") statements
Willy Tarreau [Thu, 14 Apr 2022 14:57:12 +0000 (16:57 +0200)] 
BUILD: compiler: use a more portable set of asm(".weak") statements

The two recent patches b12966af1 ("BUILD: debug: mark the
__start_mem_stats/__stop_mem_stats symbols as weak") and 2a06e248f
("BUILD: initcall: mark the __start_i_* symbols as weak, not global")
aimed at fixing a build warning and resulted in a build breakage on
MacOS which doesn't have a ".weak" asm statement.

We've already had MacOS-specific asm() statements for section names, so
this patch continues on this trend by moving HA_GLOBL() to compiler.h
and using ".globl" on MacOS since apparently nobody complains there.

It is debatable whether to expose this only when !USE_OBSOLETE_LINKER
or all the time, but since these are just macroes it's no big deal to
let them be available when needed and let the caller decide on the
build conditions.

If any of the patches above is backported, this one will need to as
well.

3 years agoBUILD: sched: workaround crazy and dangerous warning in Clang 14
Willy Tarreau [Thu, 14 Apr 2022 13:00:42 +0000 (15:00 +0200)] 
BUILD: sched: workaround crazy and dangerous warning in Clang 14

Ilya reported in issue #1638 that Clang 14 has invented a new warning
that encourages to modify the code in a way that is not always
equivalent, by turning "|" to "||" between some logical operators,
except that the first one guarantees that all members of the expression
will always be evaluated while the latter will stop at the first one
which is true!

This warning triggers in thread_has_tasks(), which is not sensitive to
such change of behavior but which is built this way because it results
in branchless code for something that most often evaluates to false for
all terms. As such it was out of question to turn this to less efficient
compare-and-jump that needlessly pollute the branch predictor, so the
workaround consists in casting each expression to (int). It was verified
that the code is the same.

Yet another example of how-to-introduce-bugs-by-fixing-valid-code
through warnings invented around a beer without thinking longer!

This may need to be backported to a few older branches in case this
compiler lands in recent distros or if gcc finds it wise to imitate it.

3 years agoMINOR: quic: emit CONNECTION_CLOSE on app init error
Amaury Denoyelle [Thu, 14 Apr 2022 12:59:35 +0000 (14:59 +0200)] 
MINOR: quic: emit CONNECTION_CLOSE on app init error

Emit a CONNECTION_CLOSE if the app layer cannot be properly initialized
on qc_xprt_start. This force the quic-conn to enter the closing state
before being closed.

Without this, quic-conn normal operations continue, despite the
app-layer reported as not initialized. This behavior is undefined, in
particular when handling STREAM frames.

3 years agoBUG/MINOR: quic: fix return value for error in start
Amaury Denoyelle [Wed, 13 Apr 2022 15:40:26 +0000 (17:40 +0200)] 
BUG/MINOR: quic: fix return value for error in start

Fix the return value used in quic-conn start callback for error. The
caller expects a negative value in this case.

Without this patch, the quic-conn and the connection stack are not
closed despite an initialization failure error, which is an undefined
behavior and may cause a crash in the end.

3 years agoBUG/MINOR: quic-sock: do not double free session on conn init failure
Amaury Denoyelle [Wed, 13 Apr 2022 14:58:26 +0000 (16:58 +0200)] 
BUG/MINOR: quic-sock: do not double free session on conn init failure

In the quic_session_accept, connection is in charge to call the
quic-conn start callback. If this callback fails for whatever reason,
there is a crash because of an explicit session_free.

This happens because the connection is now the owner of the session due
to previous conn_complete_session call. It will automatically calls
session_free. Fix this by skipping the session_free explicit invocation
on error.

In practice, currently this has never happened as there is only limited
cases of failures for conn_xprt_start for QUIC.

3 years agoBUG/MINOR: mux-quic: prevent a crash in session_free on mux.destroy
Amaury Denoyelle [Wed, 13 Apr 2022 14:54:52 +0000 (16:54 +0200)] 
BUG/MINOR: mux-quic: prevent a crash in session_free on mux.destroy

Implement qc_destroy. This callback is used to quickly release all MUX
resources.

session_free uses this callback. Currently, it can only be called if
there was an error during connection initialization. If not defined, the
process crashes.

3 years agoBUILD: http-client: Avoid dead code when compiled without SSL support
Christopher Faulet [Thu, 14 Apr 2022 10:02:34 +0000 (12:02 +0200)] 
BUILD: http-client: Avoid dead code when compiled without SSL support

When an HTTP client is started on an HAProxy compiled without the SSL
support, an error is triggered when HTTPS is used. In this case, the freshly
created conn-stream is released. But this code is specific to the non-SSL
part. Thus it is moved the in right #if/#else section.

This patch should fix the issue #1655.

3 years agoBUG/MEDIUM: mux-h1: Don't request more room on partial trailers
Christopher Faulet [Wed, 13 Apr 2022 15:48:54 +0000 (17:48 +0200)] 
BUG/MEDIUM: mux-h1: Don't request more room on partial trailers

The commit 744451c7c ("BUG/MEDIUM: mux-h1: Properly detect full buffer cases
during message parsing") introduced a regression if trailers are not
received in one time. Indeed, in this case, nothing is appended in the
channel buffer, while there are some data in the input buffer. In this case,
we must not request more room to the upper layer, especially because the
channel buffer can be empty.

To fix the issue, on trailers parsing, we consider the H1 stream as
congested when the max size allowed is reached. Of course, the H1 stream is
also considered as congested if the trailers are too big and the channel
buffer is not empty.

This patch should fix the issue #1657. It must be backported as far as 2.0.

3 years agoMINOR: conn-stream: Use unsafe functions to get conn/appctx in cs_detach_endp
Christopher Faulet [Thu, 14 Apr 2022 09:40:12 +0000 (11:40 +0200)] 
MINOR: conn-stream: Use unsafe functions to get conn/appctx in cs_detach_endp

There is no reason to rely on safe functions here. This patch should fix the
issue #1656.

3 years agoMINOR: muxes: Don't expect to call release function with no mux defined
Christopher Faulet [Thu, 14 Apr 2022 09:36:41 +0000 (11:36 +0200)] 
MINOR: muxes: Don't expect to call release function with no mux defined

For all muxes, the function responsible to release a mux is always called
with a defined mux. Thus there is no reason to test if it is defined or not.

Note the patch may seem huge but it is just because of indentation changes.

3 years agoMINOR: muxes: Don't handle proto upgrade for muxes not supporting it
Christopher Faulet [Thu, 14 Apr 2022 09:23:50 +0000 (11:23 +0200)] 
MINOR: muxes: Don't handle proto upgrade for muxes not supporting it

Several muxes (h2, fcgi, quic) don't support the protocol upgrade. For these
muxes, there is no reason to have code to support it. Thus in the destroy
callback, there is now a BUG_ON() and the release function is simplified
because the connection is always owned by the mux..

3 years agoMINOR: muxes: Don't expect to have a mux without connection in destroy callback
Christopher Faulet [Thu, 14 Apr 2022 09:08:26 +0000 (11:08 +0200)] 
MINOR: muxes: Don't expect to have a mux without connection in destroy callback

Once a mux initialized, the underlying connection alwaus exists from its
point of view and it is never removed until the mux is released. It may be
owned by another mux during an upgrade. But the pointer remains set. Thus
there is no reason to test it in the destroy callback function.

This patch should fix the issue #1652.

3 years agoBUG/MINOR: mux-h2: use timeout http-request as a fallback for http-keep-alive
Willy Tarreau [Wed, 13 Apr 2022 15:40:28 +0000 (17:40 +0200)] 
BUG/MINOR: mux-h2: use timeout http-request as a fallback for http-keep-alive

The doc states that timeout http-keep-alive is not set, timeout http-request
is used instead. As implemented in commit  15a4733d5 ("BUG/MEDIUM: mux-h2:
make use of http-request and keep-alive timeouts"), we use http-keep-alive
unconditionally between requests, with a fallback on client/server. Let's
make sure http-request is always used as a fallback for http-keep-alive
first.

This needs to be backported wherever the commit above is backported.

Thanks to Christian Ruppert for spotting this.

3 years agoBUG/MINOR: mux-h2: do not use timeout http-keep-alive on backend side
Willy Tarreau [Thu, 14 Apr 2022 09:43:35 +0000 (11:43 +0200)] 
BUG/MINOR: mux-h2: do not use timeout http-keep-alive on backend side

Commit 15a4733d5 ("BUG/MEDIUM: mux-h2: make use of http-request and
keep-alive timeouts") omitted to check the side of the connection, and
as a side effect, automatically enabled timeouts on idle backend
connections, which is totally contrary to the principle that they
must be autonomous.

This needs to be backported wherever the patch above is backported.

3 years agoBUILD: initcall: mark the __start_i_* symbols as weak, not global
Willy Tarreau [Wed, 13 Apr 2022 15:12:20 +0000 (17:12 +0200)] 
BUILD: initcall: mark the __start_i_* symbols as weak, not global

Just like for previous fix, these symbols are marked ".globl" during
their declaration, but their later mention uses __attribute__((weak)),
so it's better to only use ".weak" during the declaration so that the
symbol's class does not change.

No need to backport this unless someone reports build issues.

3 years agoBUILD: debug: mark the __start_mem_stats/__stop_mem_stats symbols as weak
Willy Tarreau [Wed, 13 Apr 2022 15:09:45 +0000 (17:09 +0200)] 
BUILD: debug: mark the __start_mem_stats/__stop_mem_stats symbols as weak

Building with clang and DEBUG_MEM_STATS shows the following warnings:

  warning: __start_mem_stats changed binding to STB_WEAK [-Wsource-mgr]
  warning: __stop_mem_stats changed binding to STB_WEAK [-Wsource-mgr]

The reason is that the symbols are declared using ".globl" while they
are also referenced as __attribute__((weak)) elsewhere. It turns out
that a weak symbol is implicitly a global one and that the two classes
are exclusive, thus it may confuse the linker. Better fix this.

This may be backported where the patch applies.

3 years agoBUG/MINOR: quic: Avoid starting the mux if no ALPN sent by the client
Frédéric Lécaille [Wed, 13 Apr 2022 14:20:09 +0000 (16:20 +0200)] 
BUG/MINOR: quic: Avoid starting the mux if no ALPN sent by the client

If the client does not sent an ALPN, the SSL ALPN negotiation callback
is not called. However, the handshake is reported as successful. Check
just after SSL_do_handshake if an ALPN was negotiated. If not, emit a
CONNECTION_CLOSE with a TLS alert to close the connection.

This prevent a crash in qcc_install_app_ops() called with null as second
parameter value.

3 years agoMINOR: mux-h1: Rely on the endpoint instead of the conn-stream when possible
Christopher Faulet [Wed, 13 Apr 2022 10:09:36 +0000 (12:09 +0200)] 
MINOR: mux-h1: Rely on the endpoint instead of the conn-stream when possible

Instead of testing if a conn-stream exists or not, we rely on CS_EP_ORPHAN
endpoint flag. In addition, if possible, we access the endpoint from the
h1s. Finally, the endpoint flags are now reported in trace messages.

3 years agoMINOR: muxes: Improve show_fd callbacks to dump endpoint flags
Christopher Faulet [Wed, 13 Apr 2022 10:08:09 +0000 (12:08 +0200)] 
MINOR: muxes: Improve show_fd callbacks to dump endpoint flags

H1, H2 and FCGI multiplexers define a show_fd callback to dump some internal
info. The stream endpoint and its flags are now dumped if it exists.

3 years agoCLEANUP: conn-stream: rename cs_register_applet() to cs_applet_create()
Christopher Faulet [Tue, 12 Apr 2022 16:15:16 +0000 (18:15 +0200)] 
CLEANUP: conn-stream: rename cs_register_applet() to cs_applet_create()

cs_register_applet() was not a good name because it suggests it happens
during startup, just like any other registration mechanisms..

3 years agoMINOR: conn-stream: Use a dedicated function to conditionally remove a CS
Christopher Faulet [Tue, 12 Apr 2022 16:09:48 +0000 (18:09 +0200)] 
MINOR: conn-stream: Use a dedicated function to conditionally remove a CS

cs_free_cond() must now be used to remove a CS. cs_free() may be used on
error path to release a freshly allocated but unused CS. But in all other
cases cs_free_cond() must be used. This function takes care to release the
CS if it is possible (no app and detached from any endpoint).

In fact, this function is only used internally. From the outside,
cs_detach_* functions are used.

3 years agoCLEANUP: muxes: Remove MX_FL_CLEAN_ABRT flag
Christopher Faulet [Tue, 12 Apr 2022 16:04:10 +0000 (18:04 +0200)] 
CLEANUP: muxes: Remove MX_FL_CLEAN_ABRT flag

This flag is unused. Thus, it may be removed. No reason to still set it. It
also cleans up "haproxy -vv" output.

3 years agoMEDIUM: check: Use a new conn-stream for each health-check run
Christopher Faulet [Tue, 12 Apr 2022 15:47:07 +0000 (17:47 +0200)] 
MEDIUM: check: Use a new conn-stream for each health-check run

It is a partial revert of 54e85cbfc ("MAJOR: check: Use a persistent
conn-stream for health-checks"). But with the CS refactoring, the result is
cleaner now. A CS is allocated when a new health-check run is started. The
same CS is then used throughout the run. If there are several connections,
the endpoint is just reset. At the end of the run, the CS is released. It
means, in the tcp-check part, the CS is always defined.

3 years agoDOC: conn-stream: Add comments on functions of the new CS api
Christopher Faulet [Tue, 12 Apr 2022 06:51:15 +0000 (08:51 +0200)] 
DOC: conn-stream: Add comments on functions of the new CS api

With the conn-stream refactoring, new functions were added. This patch adds
missing comments to help devs to use them.

3 years agoCLEANUP: conn-stream: Don't export internal functions
Christopher Faulet [Tue, 12 Apr 2022 06:49:27 +0000 (08:49 +0200)] 
CLEANUP: conn-stream: Don't export internal functions

cs_new() and cs_attach_app() are only used internally. Thus, there is no
reason to export them.

3 years agoCLEANUP: tree-wide: Remove any ref to stream-interfaces
Christopher Faulet [Mon, 4 Apr 2022 09:29:28 +0000 (11:29 +0200)] 
CLEANUP: tree-wide: Remove any ref to stream-interfaces

Stream-interfaces are gone. Corresponding files can be safely be removed. In
addition, comments are updated accordingly.

3 years agoDEV: flags: No longer dump SI flags
Christopher Faulet [Mon, 4 Apr 2022 09:28:27 +0000 (11:28 +0200)] 
DEV: flags: No longer dump SI flags

stream-interface API is no longer used. And there is no more SI flags. Thus,
the stream-interface's flags are no longer dumped by "flags" tool.

3 years agoMINOR: conn-stream: Remove the stream-interface from the conn-stream
Christopher Faulet [Mon, 4 Apr 2022 09:25:59 +0000 (11:25 +0200)] 
MINOR: conn-stream: Remove the stream-interface from the conn-stream

The stream-interface API is no longer used. Thus, it is removed from the
conn-stream. From now, stream-interfaces are now longer used !

3 years agoMEDIUM: stream: Don't use the stream-int anymore in process_stream()
Christopher Faulet [Mon, 4 Apr 2022 09:08:42 +0000 (11:08 +0200)] 
MEDIUM: stream: Don't use the stream-int anymore in process_stream()

process_stream() and all associated functions now manipulate conn-streams.
stream-interfaces are no longer used. In addition, function to dump info
about a stream no longer print info about stream-interfaces.

3 years agoMINOR: http-ana: Use CS to perform L7 retries
Christopher Faulet [Mon, 4 Apr 2022 09:07:08 +0000 (11:07 +0200)] 
MINOR: http-ana: Use CS to perform L7 retries

do_l7_retry function now manipulated a conn-stream instead of a
stream-interface.

3 years agoMINOR: stream: Use conn-stream to report server error
Christopher Faulet [Mon, 4 Apr 2022 09:06:31 +0000 (11:06 +0200)] 
MINOR: stream: Use conn-stream to report server error

the stream's srv_error callback function now manipulates a conn-stream
instead of a stream-interface.

3 years agoREORG: stream-int/conn-stream: Move remaining functions to conn-stream
Christopher Faulet [Mon, 4 Apr 2022 07:00:59 +0000 (09:00 +0200)] 
REORG: stream-int/conn-stream: Move remaining functions to conn-stream

functions to get or set blocking flags on a conn-stream are moved to
conn_stream.h.

3 years agoMEDIUM: stream-int/conn-stream: Move I/O functions to conn-stream
Christopher Faulet [Mon, 4 Apr 2022 06:58:34 +0000 (08:58 +0200)] 
MEDIUM: stream-int/conn-stream: Move I/O functions to conn-stream

cs_conn_io_cb(), cs_conn_sync_recv() and cs_conn_sync_send() are moved in
conn_stream.c. Associated functions are moved too (cs_notify, cs_conn_read0,
cs_conn_recv, cs_conn_send and cs_conn_process).

3 years agoMEDIUM: stream-int/conn-stream: Move blocking flags from SI to CS
Christopher Faulet [Mon, 4 Apr 2022 05:51:21 +0000 (07:51 +0200)] 
MEDIUM: stream-int/conn-stream: Move blocking flags from SI to CS

Remaining flags and associated functions are move in the conn-stream
scope. These flags are added on the endpoint and not the conn-stream
itself. This way it will be possible to get them from the mux or the
applet. The functions to get or set these flags are renamed accordingly with
the "cs_" prefix and updated to manipualte a conn-stream instead of a
stream-interface.

3 years agoCLEANUP: stream-int: Remove unused SI functions
Christopher Faulet [Fri, 1 Apr 2022 15:21:49 +0000 (17:21 +0200)] 
CLEANUP: stream-int:  Remove unused SI functions

Some stream-interface's functions are now unused and can safely be removed.

3 years agoMINOR: stream-int/conn-stream: Move si_alloc_ibuf() in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 15:19:36 +0000 (17:19 +0200)] 
MINOR: stream-int/conn-stream: Move si_alloc_ibuf() in the conn-stream scope

si_alloc_ibuf() is renamed as c_alloc_ibuf() and update to manipulate a
conn-stream instead of a stream-interface.

3 years agoMINOR: stream-int/conn-stream Move si_is_conn_error() in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 15:15:10 +0000 (17:15 +0200)] 
MINOR: stream-int/conn-stream Move si_is_conn_error() in the conn-stream scope

si_is_conn_error() is renamed as cs_is_conn_erro() and updated to manipulate
a conn-stream instead of a stream-interface.

3 years agoMINOR: conn-stream: Move si_conn_cb in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 15:06:32 +0000 (17:06 +0200)] 
MINOR: conn-stream: Move si_conn_cb in the conn-stream scope

si_conn_cb variable is renamed cs_data_conn_cb. In addtion, its associated
functions are also renamed. si_cs_recv(), si_cs_send() and si_cs_process() are
renamed cs_conn_recv(), cs_conn_send and cs_conn_process(). These functions are
updated to manipulate conn-streams instead of stream-interfaces.

3 years agoMINOR: stream-int/conn-stream: Move si_sync_recv/send() in conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 15:03:14 +0000 (17:03 +0200)] 
MINOR: stream-int/conn-stream: Move si_sync_recv/send() in conn-stream scope

si_sync_recv() and si_sync_send() are renamesd cs_conn_recv() and
cs_conn_send() and updated to manipulate conn-streams instead of
stream-interfaces.

3 years agoMINOR: stream-int/conn-stream: Move si_cs_io_cb() in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 14:58:52 +0000 (16:58 +0200)] 
MINOR: stream-int/conn-stream: Move si_cs_io_cb() in the conn-stream scope

si_cs_io_cb() is renamed cs_conn_io_cb(). In addition, the context of the
tasklet used to wake-up the conn-stream is now a conn-stream.

3 years agoMINOR: stream-int/conn-stream: Move stream_int_notify() in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 14:48:36 +0000 (16:48 +0200)] 
MINOR: stream-int/conn-stream: Move stream_int_notify() in the conn-stream scope

stream_int_notify() is renamed cs_notify() and is updated to manipulate a
conn-stream instead of a stream-interface.

3 years agoMINOR: stream-int/conn-stream: Move stream_int_read0() in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 14:38:32 +0000 (16:38 +0200)] 
MINOR: stream-int/conn-stream: Move stream_int_read0() in the conn-stream scope

stream_int_read0() is renamed cs_conn_read0() and is updated to manipulate a
conn-stream instead of a stream-interface.

3 years agoMEDIUM: conn-stream/applet: Add a data callback for applets
Christopher Faulet [Fri, 1 Apr 2022 14:34:53 +0000 (16:34 +0200)] 
MEDIUM: conn-stream/applet: Add a data callback for applets

data callbacks were only used for streams attached to a connection and
for health-checks. However there is a callback used by task_run_applet. So,
si_applet_wake_cb() is first renamed to cs_applet_process() and it is
defined as the data callback for streams attached to an applet. This way,
this part now manipulates a conn-stream instead of a stream-interface. In
addition, applets are no longer handled as an exception for this part.

3 years agoMINOR: stream-int/stream: Move si_update_both in stream scope
Christopher Faulet [Fri, 1 Apr 2022 12:48:06 +0000 (14:48 +0200)] 
MINOR: stream-int/stream: Move si_update_both in stream scope

si_update_both() is renamed stream_update_both_cs() and moved in stream.c.
The function is slightly changed to manipulate the stream instead the front
and back conn-streams.

3 years agoMINOR: stream-int-conn-stream: Move si_update_* in conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 12:23:38 +0000 (14:23 +0200)] 
MINOR: stream-int-conn-stream: Move si_update_* in conn-stream scope

si_update_rx(), si_update_tx() and si_update() are renamed cs_update_rx(),
cs_upate_tx() and cs_update() and updated to manipulate a conn-stream
instead of a stream-interface.

3 years agoREORG: conn-stream: Move cs_app_ops in conn_stream.c
Christopher Faulet [Fri, 1 Apr 2022 12:04:29 +0000 (14:04 +0200)] 
REORG: conn-stream: Move cs_app_ops in conn_stream.c

Callback functions to perform shutdown for reads and writes and to trigger
I/O calls are now moved in conn_stream.c.

3 years agoREORG: conn-stream: Move cs_shut* and cs_chk* in cs_utils
Christopher Faulet [Fri, 1 Apr 2022 11:58:09 +0000 (13:58 +0200)] 
REORG: conn-stream: Move cs_shut* and cs_chk* in cs_utils

cs_shutr(), cs_shutw(), cs_chk_rcv() and cs_chk_snd() are moved in
cs_utils.h

3 years agoREORG: stream-int: Move si_is_conn_error() in the header file
Christopher Faulet [Fri, 1 Apr 2022 11:56:30 +0000 (13:56 +0200)] 
REORG: stream-int: Move si_is_conn_error() in the header file

To ease next changes, this function is moved in the header file. It is a
transient commit.

3 years agoREORG: stream-int: Export si_cs_recv(), si_cs_send() and si_cs_process()
Christopher Faulet [Fri, 1 Apr 2022 11:48:39 +0000 (13:48 +0200)] 
REORG: stream-int: Export si_cs_recv(), si_cs_send() and si_cs_process()

It is a transient commit. It should ease next changes about the conn-stream
refactoring. At the end these functions will be moved in the conn-stream
scope.

3 years agoMINOR: stream-int/connection: Move conn_si_send_proxy() in the connection scope
Christopher Faulet [Fri, 1 Apr 2022 11:22:50 +0000 (13:22 +0200)] 
MINOR: stream-int/connection: Move conn_si_send_proxy() in the connection scope

conn_si_send_proxy() function is renamed conn_send_proxy() and moved in
connection.c

3 years agoMINOR: connection: unconst mux's get_fist_cs() callback function
Christopher Faulet [Fri, 1 Apr 2022 11:21:41 +0000 (13:21 +0200)] 
MINOR: connection: unconst mux's get_fist_cs() callback function

This change is mandatory for next commits.

3 years agoMINOR: applet: Use the CS to register and release applets instead of SI
Christopher Faulet [Fri, 1 Apr 2022 09:36:58 +0000 (11:36 +0200)] 
MINOR: applet: Use the CS to register and release applets instead of SI

si_register_applet() and si_applet_release() are renamed
cs_register_applet() and cs_applet_release() and now manipulate a
conn-stream instead of a stream-inteface.

3 years agoMEDIUM: stream-int/conn-stream: Move si_ops in the conn-stream scope
Christopher Faulet [Fri, 1 Apr 2022 06:58:29 +0000 (08:58 +0200)] 
MEDIUM: stream-int/conn-stream: Move si_ops in the conn-stream scope

The si_ops structure is renamed to cs_app_ops and the callback functions are
changed to manipulate a conn-stream instead of a stream-interface..

3 years agoMINOR: stream-int/conn-stream: Move si_shut* and si_chk* in conn-stream scope
Christopher Faulet [Thu, 31 Mar 2022 15:44:45 +0000 (17:44 +0200)] 
MINOR: stream-int/conn-stream: Move si_shut* and si_chk* in conn-stream scope

si_shutr(), si_shutw(), si_chk_rcv() and si_chk_snd() are moved in the
conn-stream scope and renamed, respectively, cs_shutr(), cs_shutw(),
cs_chk_rcv(), cs_chk_snd() and manipulate a conn-stream instead of a
stream-interface.

3 years agoMINOR: conn-stream: Rename CS functions dedicated to connections
Christopher Faulet [Thu, 31 Mar 2022 12:20:00 +0000 (14:20 +0200)] 
MINOR: conn-stream: Rename CS functions dedicated to connections

Some conn-stream functions are only used when there is a connection. Thus,
they was renamed with "cs_conn_" prefix. In addition, we expect to have a
connection, so a BUG_ON is added to be sure the functions are never called
in another context.

3 years agoMEDIUM: stream-int/conn-stream: Handle I/O subscriptions in the conn-stream
Christopher Faulet [Thu, 31 Mar 2022 09:09:28 +0000 (11:09 +0200)] 
MEDIUM: stream-int/conn-stream: Handle I/O subscriptions in the conn-stream

wait_event structure is moved in the conn-stream. The tasklet is only
created if the conn-stream is attached to a mux and released when the mux is
detached. This implies a subtle change. In stream_int_chk_rcv() function,
the wakeup of the tasklet was removed because there is no longer tasklet at
this stage (stream_int_chk_rcv() is a callback function of si_embedded_ops).

3 years agoMEDIUM: conn-stream: Be prepared to fail to attach a cs to a mux
Christopher Faulet [Thu, 31 Mar 2022 17:27:18 +0000 (19:27 +0200)] 
MEDIUM: conn-stream: Be prepared to fail to attach a cs to a mux

To be able to move wait_event from the stream-interface to the conn-stream,
we must be prepare to handle errors when a mux is attached to a conn-stream.
Indeed, the wait_event's tasklet will be allocated when both a mux and a
stream will be both attached to a stream. So, we must be prepared to handle
allocation errors.

3 years agoMINOR: conn-stream/connection: Move SHR/SHW modes in the connection scope
Christopher Faulet [Thu, 31 Mar 2022 09:05:05 +0000 (11:05 +0200)] 
MINOR: conn-stream/connection: Move SHR/SHW modes in the connection scope

These flags only concerns the connection part. In addition, it is required
for a next commit, to avoid circular deps. Thus CS_SHR_* and CS_SHW_* were
renamed with the "CO_" prefix.

3 years agoMINOR: stream-int/conn-stream: Move si_conn_ready() in the conn-stream scope
Christopher Faulet [Thu, 31 Mar 2022 07:58:41 +0000 (09:58 +0200)] 
MINOR: stream-int/conn-stream: Move si_conn_ready() in the conn-stream scope

si_conn_ready() is renamed cs_conn_ready() and handle a conn-stream insted
of a stream-interface. The function is now in cs_utils.h.

3 years agoMINOR: stream-int/backend: Move si_connect() in the backend scope
Christopher Faulet [Thu, 31 Mar 2022 07:53:38 +0000 (09:53 +0200)] 
MINOR: stream-int/backend: Move si_connect() in the backend scope

si_connect() is moved in backend.c and renamed as do_connect_server(). In
addition, the function now manipulate a stream instead of a
stream-interface.

3 years agoMINOR: stream-int/stream: Move si_retnclose() in the stream scope
Christopher Faulet [Thu, 31 Mar 2022 07:47:24 +0000 (09:47 +0200)] 
MINOR: stream-int/stream: Move si_retnclose() in the stream scope

si_retnclose() is used to send a reply to a client before closing. There is
no use on the server side, in spite of the function is generic. Thus, it is
renamed stream_retnclose() and moved into the stream scope. The function now
handle a stream and explicitly send a message to the client.

3 years agoMEDIUM: stream-int/conn-stream: Move stream-interface state in the conn-stream
Christopher Faulet [Thu, 31 Mar 2022 07:16:34 +0000 (09:16 +0200)] 
MEDIUM: stream-int/conn-stream: Move stream-interface state in the conn-stream

The stream-interface state (SI_ST_*) is now in the conn-stream. It is a
mechanical replacement for now. Nothing special. SI_ST_* and SI_SB_* were
renamed accordingly. Utils functions to manipulate these infos were moved
under the conn-stream scope.

But it could be good to keep in mind that this part should be
reworked. Indeed, at the CS level, we only need to know if it is ready to
receive or to send. The state of conn-stream from INI to EST is only used on
the server side. The client CS is immediately set to EST. Thus current
SI_ST_* states should probably be moved to the stream to reflect the server
connection state during the establishment stage.

3 years agoMEDIUM: stream-int: Move SI err_type in the stream
Christopher Faulet [Wed, 30 Mar 2022 17:39:30 +0000 (19:39 +0200)] 
MEDIUM: stream-int: Move SI err_type in the stream

Only the server side is concerned by the stream-interface error type. It is
useless to have an err_type field on the client side. So, it is now move to
the stream. SI_ET_* are renames STRM_ET_* and moved in stream-t.h header
file.

3 years agoMINOR: stream: Only save previous connection state for the server side
Christopher Faulet [Wed, 30 Mar 2022 15:13:02 +0000 (17:13 +0200)] 
MINOR: stream: Only save previous connection state for the server side

The previous connection state on the client side was only used for debugging
purpose to report client close. But this may be handled when the client
stream-interface is switched from SI_ST_DIS to SI_ST_CLO.

So, there only remains the previous connection state on the server side that
is used by the stream, in process_stream(), to be able to set the correct
termination flags. Thus, instead of keeping this info in the
stream-interface for only one side, the info is now stored in the stream
itself.

3 years agoCLEANUP: stream-int: Remove unused SI_FL_CLEAN_ABRT flag
Christopher Faulet [Wed, 30 Mar 2022 14:31:41 +0000 (16:31 +0200)] 
CLEANUP: stream-int: Remove unused SI_FL_CLEAN_ABRT flag

This flag is unused. So remove it to be able to remove the stream-interface.

3 years agoMINOR: stream-int: Remove SI_FL_SRC_ADDR to rely on stream flags instead
Christopher Faulet [Wed, 30 Mar 2022 14:26:39 +0000 (16:26 +0200)] 
MINOR: stream-int: Remove SI_FL_SRC_ADDR to rely on stream flags instead

Flag to get the source ip/port with getsockname is now handled at the stream
level. Thus SI_FL_SRC_ADDR stream-int flag is replaced by SF_SRC_ADDR stream
flag.

3 years agoMINOR: stream-int: Remove SI_FL_INDEP_STR to rely on CS flags instead
Christopher Faulet [Wed, 30 Mar 2022 13:43:23 +0000 (15:43 +0200)] 
MINOR: stream-int: Remove SI_FL_INDEP_STR to rely on CS flags instead

Flag to consider a stream as indepenent is now handled at the conn-stream
level. Thus SI_FL_INDEP_STR stream-int flag is replaced by CS_FL_INDEP_STR
conn-stream flags.

3 years agoMINOR: stream-int: Remove SI_FL_DONT_WAKE to rely on CS flags instead
Christopher Faulet [Wed, 30 Mar 2022 13:30:03 +0000 (15:30 +0200)] 
MINOR: stream-int: Remove SI_FL_DONT_WAKE to rely on CS flags instead

Flag to not wake the stream up on I/O is now handled at the conn-stream
level. Thus SI_FL_DONT_WAKE stream-int flag is replaced by CS_FL_DONT_WAKE
conn-stream flags.

3 years agoMINOR: stream-int: Remove SI_FL_NOLINGER/NOHALF to rely on CS flags instead
Christopher Faulet [Wed, 30 Mar 2022 13:10:18 +0000 (15:10 +0200)] 
MINOR: stream-int: Remove SI_FL_NOLINGER/NOHALF to rely on CS flags instead

Flags to disable lingering and half-close are now handled at the conn-stream
level. Thus SI_FL_NOLINGER and SI_FL_NOHALF stream-int flags are replaced by
CS_FL_NOLINGER and CS_FL_NOHALF conn-stream flags.

3 years agoMINOR: mux-h2/mux-fcgi: Fully rely on CS_EP_KILL_CONN
Christopher Faulet [Wed, 30 Mar 2022 12:48:10 +0000 (14:48 +0200)] 
MINOR: mux-h2/mux-fcgi: Fully rely on CS_EP_KILL_CONN

Instead of using a internal flag to kill the connection with the stream, we
now fully rely on CS_EP_KILL_CONN flag.

3 years agoMINOR: stream-int: Remove SI_FL_KILL_CON to rely on conn-stream endpoint only
Christopher Faulet [Wed, 30 Mar 2022 12:42:50 +0000 (14:42 +0200)] 
MINOR: stream-int: Remove SI_FL_KILL_CON to rely on conn-stream endpoint only

Instead of setting a stream-interface flag to then set the corresponding
conn-stream endpoint flag, we now only rely the conn-stream endoint. Thus
SI_FL_KILL_CON is replaced by CS_EP_KILL_CONN.

In addition si_must_kill_conn() is replaced by cs_must_kill_conn().

3 years agoMINOR: channel: Use conn-streams as channel producer and consumer
Christopher Faulet [Wed, 30 Mar 2022 12:37:49 +0000 (14:37 +0200)] 
MINOR: channel: Use conn-streams as channel producer and consumer

chn_prod() and chn_cons() now return a conn-stream instead of a
stream-interface.

3 years agoMEDIUM: conn-stream: Use endpoint error instead of conn-stream error
Christopher Faulet [Wed, 30 Mar 2022 08:47:32 +0000 (10:47 +0200)] 
MEDIUM: conn-stream: Use endpoint error instead of conn-stream error

Instead of relying on the conn-stream error, via CS_FL_ERR flags, we now
directly use the error at the endpoint level with the flag CS_EP_ERROR. It
should be safe to do so. But we must be careful because it is still possible
that an error is processed too early. Anyway, a conn-stream has always a
valid endpoint, maybe detached from any endpoint, but valid.

3 years agoMINOR: stream-int/conn-stream: Report error to the CS instead of the SI
Christopher Faulet [Wed, 30 Mar 2022 08:06:11 +0000 (10:06 +0200)] 
MINOR: stream-int/conn-stream: Report error to the CS instead of the SI

SI_FL_ERR is removed and replaced by CS_FL_ERROR. It is a transient patch
because the idea is to rely on the endpoint to handle errors at this
level. But if for any reason it is not possible, the stream-interface flags
will still be replaced.

3 years agoMEDIUM: stream-int/stream: Use connect expiration instead of SI expiration
Christopher Faulet [Tue, 29 Mar 2022 17:02:31 +0000 (19:02 +0200)] 
MEDIUM: stream-int/stream: Use connect expiration instead of SI expiration

The expiration date in the stream-interface was only used on the server side
to set the connect, queue or turn-around timeout. It was checked on the
frontend stream-interface, but never used concretely. So it was removed and
replaced by a connect expiration date in the stream itself. Thus, SI_FL_EXP
flag in stream-interfaces is replaced by a stream flag, SF_CONN_EXP.

3 years agoMINOR: stream-int/conn-stream: Move half-close timeout in the conn-stream
Christopher Faulet [Tue, 29 Mar 2022 16:03:35 +0000 (18:03 +0200)] 
MINOR: stream-int/conn-stream: Move half-close timeout in the conn-stream

The half-close timeout (hcto) is now part of the conn-stream. It is a step
closer to the stream-interface removal.

3 years agoMEDIUM: stream-int/conn-stream: Move src/dst addresses in the conn-stream
Christopher Faulet [Tue, 29 Mar 2022 15:53:09 +0000 (17:53 +0200)] 
MEDIUM: stream-int/conn-stream: Move src/dst addresses in the conn-stream

The source and destination addresses at the applicative layer are moved from
the stream-interface to the conn-stream. This simplifies a bit the code and
it is a logicial step to remove the stream-interface.

3 years agoMINOR: stream: Simplify retries counter calculation
Christopher Faulet [Tue, 29 Mar 2022 14:08:44 +0000 (16:08 +0200)] 
MINOR: stream: Simplify retries counter calculation

The conn_retries counter was set to the max value and decremented at each
connection retry. Thus the counter reflected the number of retries left and
not the real number of retries. All calculations of redispatch or reporting
of number of retries experienced were made using subtracts from the
configured retries, which was complicated and didn't bring any benefit.

Now, this counter is set to 0 and incremented at each retry. We know we've
reached the maximum allowed connection retries by comparing it to the
configured value. In all other cases, we directly use the counter.

This patch should address the feature request #1608.

3 years agoMINOR: stream-int/stream: Move conn_retries counter in the stream
Christopher Faulet [Tue, 29 Mar 2022 13:42:09 +0000 (15:42 +0200)] 
MINOR: stream-int/stream: Move conn_retries counter in the stream

The conn_retries counter may be moved into the stream structure. It only
concerns the connection establishment. The frontend stream-interface does not
use it. So it is a logical change.

3 years agoCLEANUP: http-ana: Remove http_alloc_txn() function
Christopher Faulet [Tue, 29 Mar 2022 13:27:32 +0000 (15:27 +0200)] 
CLEANUP: http-ana: Remove http_alloc_txn() function

Since the 2.4, this function is no longer used. Thus we can remove it.

3 years agoMINOR: stream-int/txn: Move buffer for L7 retries in the HTTP transaction
Christopher Faulet [Tue, 29 Mar 2022 13:23:40 +0000 (15:23 +0200)] 
MINOR: stream-int/txn: Move buffer for L7 retries in the HTTP transaction

The L7 retries only concerns the stream when a server connection is
established. Thus instead of storing the L7 buffer into the
stream-interface, it may be moved to the stream. And because it is only
available for HTTP streams, it may be moved in the HTTP transaction.

Associated flags are also moved into the HTTP transaction.

3 years agoMEDIUM: tree-wide: Use CS util functions instead of SI ones
Christopher Faulet [Fri, 25 Mar 2022 15:43:49 +0000 (16:43 +0100)] 
MEDIUM: tree-wide: Use CS util functions instead of SI ones

At many places, we now use the new CS functions to get a stream or a channel
from a conn-stream instead of using the stream-interface API. It is the
first step to reduce the scope of the stream-interfaces. The main change
here is about the applet I/O callback functions. Before the refactoring, the
stream-interface was the appctx owner. Thus, it was heavily used. Now, as
far as possible,the conn-stream is used. Of course, it remains many calls to
the stream-interface API.

3 years agoMINOR: conn-stream: Add header file with util functions related to conn-streams
Christopher Faulet [Fri, 25 Mar 2022 14:21:46 +0000 (15:21 +0100)] 
MINOR: conn-stream: Add header file with util functions related to conn-streams

cs_utils.h header file will contain all util functions related to the
conn_streams. For now, few functions were added, all are equivalent to SI
functions. Idea is to progressively replace SI functions by CS ones.

3 years agoMINOR: conn-stream: Add ISBACK conn-stream flag
Christopher Faulet [Fri, 25 Mar 2022 14:32:38 +0000 (15:32 +0100)] 
MINOR: conn-stream: Add ISBACK conn-stream flag

CS_FL_ISBACK is a new flag, set on backend conn-streams. We must just be
careful to preserve this flag when the endpoint is detached from the
conn-stream.

3 years agoMINOR: mux-pt: Rely on the endpoint instead of the conn-stream when possible
Christopher Faulet [Thu, 24 Mar 2022 09:51:08 +0000 (10:51 +0100)] 
MINOR: mux-pt: Rely on the endpoint instead of the conn-stream when possible

Instead of testing if a conn-stream exists or not, we rely on CS_EP_ORPHAN
endpoint flag. In addition, if possible, we access the endpoint from the
mux_pt context. Finally, the endpoint flags are now reported in trace
messages.

3 years agoMEDIUM: conn-stream: Move remaning flags from CS to endpoint
Christopher Faulet [Thu, 24 Mar 2022 09:27:02 +0000 (10:27 +0100)] 
MEDIUM: conn-stream: Move remaning flags from CS to endpoint

All old flags CS_FL_* are now moved in the endpoint scope and renamed
CS_EP_* accordingly. It is a systematic replacement. There is no true change
except for the health-check and the endpoint reset. Here it is a bit special
because the same conn-stream is reused. Thus, we must handle endpoint
allocation errors. To do so, cs_reset_endp() has been adapted.

Thanks to this last change, it will now be possible to simplify the
multiplexer and probably the applets too. A review must also be performed to
remove some flags in the channel or the stream-interface. The HTX will
probably be simplified too. Finally, there is now some place in the
conn-stream to move info from the stream-interface.

3 years agoMAJOR: conn-stream: Share endpoint struct between the CS and the mux/applet
Christopher Faulet [Wed, 23 Mar 2022 14:15:29 +0000 (15:15 +0100)] 
MAJOR: conn-stream: Share endpoint struct between the CS and the mux/applet

The conn-stream endpoint is now shared between the conn-stream and the
applet or the multiplexer. If the mux or the applet is created first, it is
responsible to also create the endpoint and share it with the conn-stream.
If the conn-stream is created first, it is the opposite.

When the endpoint is only owned by an applet or a mux, it is called an
orphan endpoint (there is no conn-stream). When it is only owned by a
conn-stream, it is called a detached endpoint (there is no mux/applet).

The last entity that owns an endpoint is responsible to release it. When a
mux or an applet is detached from a conn-stream, the conn-stream
relinquishes the endpoint to recreate a new one. This way, the endpoint
state is never lost for the mux or the applet.

3 years agoREORG: applet: Uninline appctx_new function
Christopher Faulet [Wed, 23 Mar 2022 10:46:56 +0000 (11:46 +0100)] 
REORG: applet: Uninline appctx_new function

appctx_new() is moved in the C file and appctx_init() is now private.

3 years agoMEDIUM: conn-stream: Pre-allocate endpoint to create CS from muxes and applets
Christopher Faulet [Wed, 23 Mar 2022 10:01:09 +0000 (11:01 +0100)] 
MEDIUM: conn-stream: Pre-allocate endpoint to create CS from muxes and applets

It is a transient commit to prepare next changes. Now, when a conn-stream is
created from an applet or a multiplexer, an endpoint is always provided. In
addition, the API to create a conn-stream was specialized to have one
function per type.

The next step will be to share the endpoint structure.

3 years agoMEDIUM: conn-stream: Be able to pass endpoint to create a conn-stream
Christopher Faulet [Tue, 22 Mar 2022 17:37:19 +0000 (18:37 +0100)] 
MEDIUM: conn-stream: Be able to pass endpoint to create a conn-stream

It is a transient commit to prepare next changes. It is possible to pass a
pre-allocated endpoint to create a new conn-stream. If it is NULL, a new
endpoint is created, otherwise the existing one is used. There no more
change at the conn-stream level.

In the applets, all conn-stream are created with no pre-allocated
endpoint. But for multiplexers, an endpoint is systematically created before
creating the conn-stream.

3 years agoMINOR: conn-stream: Move some CS flags to the endpoint
Christopher Faulet [Tue, 22 Mar 2022 17:13:29 +0000 (18:13 +0100)] 
MINOR: conn-stream: Move some CS flags to the endpoint

Some CS flags, only related to the endpoint, are moved into the endpoint
struct. More will probably moved later. Those ones are not critical. So it
is pretty safe to move them now and this will ease next changes.

3 years agoMEDIUM: conn-stream: Add an endpoint structure in the conn-stream
Christopher Faulet [Tue, 22 Mar 2022 15:06:25 +0000 (16:06 +0100)] 
MEDIUM: conn-stream: Add an endpoint structure in the conn-stream

Group the endpoint target of a conn-stream, its context and the associated
flags in a dedicated structure in the conn-stream. It is not inlined in the
conn-stream structure. There is a dedicated pool.

For now, there is no complexity. It is just an indirection to get the
endpoint or its context. But the purpose of this structure is to be able to
share a refcounted context between the mux and the conn-stream. This way, it
will be possible to preserve it when the mux is detached from the
conn-stream.