haproxy/src
Christopher Faulet 7f59d68fe2 BUG/MEDIIM: stconn: Flush output data before forwarding close to write side
In process_stream(), we wait to have an empty output channel to forward a
close to the write side (a shutw). However, at the stream-connector level,
when a close is detected on one side and we don't want to keep half-close
connections, the shutw is unconditionally forwarded to the write side. This
typically happens on server side.

At first glance, this bug may truncate messages. But depending on the muxes
and the stream states, the bug may be more visible. On recent versions
(2.8-dev and 2.7) and on 2.2 and 2.0, the stream may be freezed, waiting for
the client timeout, if the client mux is unable to forward data because the
client is too slow _AND_ the response channel is not empty _AND_ the server
closes its connection _AND_ the server mux has forwarded all data to the
upper layer _AND_ the client decides to send some data and to close its
connection. On 2.6 and 2.4, it is worst. Instead of a freeze, the client mux
is woken up in loop.

Of course, conditions are pretty hard to meet. Especially because it is highly
time dependent. For what it's worth, I reproduce it with tcploop on client and
server sides and a basic HTTP configuration for HAProxy:

  * client: tcploop -v 8889 C S:"GET / HTTP/1.1\r\nConnection: upgrade\r\n\r\n" P5000 S:"1234567890" K
  * server: tcploop -v 8000 L A R S:"HTTP/1.1 101 ok\r\nConnection: upgrade\r\n\r\n" P2000 S2660000 F R

On 2.8-dev, without this patch, the stream is freezed and when the client
connection timed out, client data are truncated and '--cL' is reported in
logs. With the patch, the client data are forwarded to the server and the
connection is closed. A '--CD' is reported in logs.

It is an old bug. It was probably introduced with the multiplexers. To fix
it, in stconn (Formerly the stream-interface), we must wait all output data
be flushed before forwarding close to write side.

This patch must be backported as far as 2.2 and must be evaluated for 2.0.
2022-12-05 11:24:24 +01:00
..
acl.c BUILD: acl: use __fallthrough in parse_acl_expr() 2022-11-14 11:14:02 +01:00
action.c
activity.c REORG: activity/cli: move the "show activity" handler to activity.c 2022-11-25 15:41:47 +01:00
applet.c BUG/MINOR: applet: make the call_rate only count the no-progress calls 2022-08-23 20:19:11 +02:00
arg.c CLEANUP: arg: remove extra check in make_arg_list arg escaping 2022-11-22 16:27:52 +01:00
auth.c MINOR: auth: silence null dereference warning in check_user() 2022-11-24 15:24:02 +01:00
backend.c MINOR: server/idle: make the next_takeover index per-tgroup 2022-11-21 19:21:07 +01:00
base64.c
cache.c CLEANUP: applet: rename appctx_cs() to appctx_sc() 2022-05-27 19:33:35 +02:00
calltrace.c
cbuf.c CLEANUP: pool/tree-wide: remove suffix "_pool" from certain pool names 2022-06-23 11:49:09 +02:00
cfgcond.c
cfgdiag.c
cfgparse-global.c MINOR: deinit: add a "quick-exit" option to bypass the deinit step 2022-11-15 09:37:09 +01:00
cfgparse-listen.c BUG/MINOR: cfgparse-listen: fix ebpt_next_dup pointer dereference on proxy "from" inheritance 2022-11-22 16:27:52 +01:00
cfgparse-quic.c MINOR: quic: define config option for socket per conn 2022-12-02 14:45:43 +01:00
cfgparse-ssl.c BUG/MINOR: ssl: crt-ignore-err memory leak with 'all' parameter 2022-11-14 11:43:52 +01:00
cfgparse-tcp.c
cfgparse-unix.c
cfgparse.c MINOR: global: generate random cluster.secret if not defined 2022-11-21 16:41:34 +01:00
channel.c CLEANUP: conn_stream: tree-wide rename to stconn (stream connector) 2022-05-27 19:33:34 +02:00
check.c BUILD: check: use __fallthrough in __health_adjust() 2022-11-14 11:14:02 +01:00
chunk.c MINOR: chunk: inline alloc_trash_chunk() 2022-08-17 10:45:22 +02:00
cli.c REORG: activity/cli: move the "show activity" handler to activity.c 2022-11-25 15:41:47 +01:00
clock.c BUG/MEDIUM: wdt/clock: properly handle early task hangs 2022-11-14 19:14:53 +01:00
compression.c
connection.c BUG/MAJOR: conn-idle: fix hash indexing issues on idle conns 2022-10-03 12:06:36 +02:00
cpuset.c MEDIUM: cpu-map: replace the process number with the thread group number 2022-07-15 19:43:10 +02:00
debug.c MINOR: debug: add a balance of alloc - free at the end of the memstats dump 2022-12-01 16:12:21 +01:00
dgram.c
dict.c
dns.c BUG/MEDIUM: dns: Properly initialize new DNS session 2022-08-03 10:30:07 +02:00
dynbuf.c
eb32sctree.c
eb32tree.c
eb64tree.c
ebimtree.c
ebistree.c
ebmbtree.c
ebpttree.c
ebsttree.c
ebtree.c
errors.c CLEANUP: assorted typo fixes in the code and comments 2022-10-30 17:17:56 +01:00
ev_epoll.c MINOR: pollers: only update the local date during busy polling 2022-09-21 09:06:28 +02:00
ev_evports.c MINOR: pollers: only update the local date during busy polling 2022-09-21 09:06:28 +02:00
ev_kqueue.c MINOR: pollers: only update the local date during busy polling 2022-09-21 09:06:28 +02:00
ev_poll.c BUG/MINOR: signals/poller: ensure wakeup from signals 2022-09-09 11:15:22 +02:00
ev_select.c MEDIUM: fd/poller: turn update_mask to group-local IDs 2022-07-15 20:16:30 +02:00
event_hdl.c MINOR: event_hdl: add event handler base api 2022-12-02 09:40:52 +01:00
extcheck.c MINOR: checks: use the lighter PRNG for spread checks 2022-10-12 21:49:30 +02:00
fcgi-app.c MEDIUM: http-ana: Add a proxy option to restrict chars in request header names 2022-05-16 16:00:26 +02:00
fcgi.c
fd.c MINOR: fd: add a new function to only raise RLIMIT_NOFILE 2022-10-04 08:38:47 +02:00
filters.c
fix.c
flt_bwlim.c CLEANUP: Reapply strcmp.cocci 2022-10-10 15:49:09 +02:00
flt_http_comp.c BUILD: compression: use __fallthrough in comp_http_payload() 2022-11-14 11:14:02 +01:00
flt_spoe.c BUILD: spoe: use __fallthrough in spoe_handle_appctx() 2022-11-14 11:14:02 +01:00
flt_trace.c
freq_ctr.c MINOR: freq_ctr: use the thread's local time whenever possible 2022-10-12 14:19:05 +02:00
frontend.c REORG: rename cs_utils.h to sc_strm.h 2022-05-27 19:33:35 +02:00
h1_htx.c BUILD: h1_htx: use __fallthrough in h1_parse_chunk() 2022-11-14 11:14:02 +01:00
h1.c BUG/MINOR: h1: Replace authority validation to conform RFC3986 2022-11-22 17:49:10 +01:00
h2.c BUG/MINOR: h2: properly set the direction flag on HTX response 2022-09-02 11:19:07 +02:00
h3_stats.c MINOR: h3: Add a statistics module for h3 2022-05-30 09:59:26 +02:00
h3.c CLEANUP: quic: create a dedicated quic_conn module 2022-10-03 16:25:17 +02:00
haproxy.c BUG/MINOR: ssl: initialize WolfSSL before parsing 2022-12-02 17:17:43 +01:00
hash.c BUILD: hash: use __fallthrough in hash_djb2() 2022-11-14 11:14:02 +01:00
hlua_fcn.c MEDIUM: stick-table: switch the table lock to rwlock 2022-10-12 14:19:05 +02:00
hlua.c MEDIUM: ssl: rename the struct "cert_key_and_chain" to "ckch_data" 2022-12-02 11:48:30 +01:00
hpack-dec.c
hpack-enc.c
hpack-huff.c OPTIM: hpack-huff: reduce the cache footprint of the huffman decoder 2022-09-20 07:41:58 +02:00
hpack-tbl.c
hq_interop.c MINOR: mux-quic: refactor snd_buf 2022-09-20 15:35:29 +02:00
http_acl.c
http_act.c BUILD: http_act: use __fallthrough in parse_http_del_header() 2022-11-14 11:14:02 +01:00
http_ana.c BUG/MINOR: http_ana/txn: don't re-initialize txn and req var lists 2022-11-18 10:20:44 +01:00
http_client.c BUG/MINOR: ssl: shut the ca-file errors emitted during httpclient init 2022-11-24 19:14:19 +01:00
http_conv.c
http_fetch.c BUILD: http_fetch: silence an uninitiialized warning with gcc-4/5/6 at -Os 2022-10-04 09:18:34 +02:00
http_htx.c CLEANUP: assorted typo fixes in the code and comments 2022-11-30 14:02:36 +01:00
http_rules.c
http.c CLEANUP: assorted typo fixes in the code and comments 2022-11-30 14:02:36 +01:00
htx.c
init.c
jwt.c
lb_chash.c
lb_fas.c
lb_fwlc.c
lb_fwrr.c
lb_map.c
listener.c BUILD: listener: fix build warning on global_listener_rwlock without threads 2022-11-22 09:10:08 +01:00
log.c BUG/MINOR: log: fix parse_log_message rfc5424 size check 2022-11-22 16:27:52 +01:00
lru.c
mailers.c BUG/MEDIUM: mailers: Set the object type for check attached to an email alert 2022-06-08 15:28:38 +02:00
map.c BUILD: map: use __fallthrough in cli_io_handler_*() 2022-11-14 11:14:02 +01:00
mjson.c
mqtt.c
mux_fcgi.c MEDIUM: mux-fcgi: Introduce flags to deal with connection read/write errors 2022-11-17 14:33:15 +01:00
mux_h1.c MINOR: mux-h1: add the expire task and its expiration date in "show fd" 2022-11-30 14:49:56 +01:00
mux_h2.c MINOR: mux-h2: add the expire task and its expiration date in "show fd" 2022-11-29 15:29:00 +01:00
mux_pt.c MEDIUM: mux-pt: Don't always set a final error on SE on the sending path 2022-11-17 14:33:15 +01:00
mux_quic.c MINOR: mux-quic: rename duplicate function names 2022-12-02 14:45:43 +01:00
mworker-prog.c
mworker.c MINOR: mworker/cli: does no try to dump the startup-logs w/o USE_SHM_OPEN 2022-10-21 14:03:29 +02:00
namespace.c
ncbuf.c CLEANUP: ncbuf: use standard BUG_ON with DEBUG_STRICT 2022-11-29 15:15:27 +01:00
pattern.c BUG/MEDIUM: pattern: only visit equivalent nodes when skipping versions 2022-08-01 11:59:46 +02:00
payload.c CLEANUP: check: rename all occurrences of stconn "cs" to "sc" 2022-05-27 19:33:35 +02:00
peers.c BUG/MINOR: peers: always update the stksess shard number on incoming updates 2022-11-29 18:06:42 +01:00
pipe.c
pool.c MINOR: cli/pools: add pool name filtering capability to "show pools" 2022-11-21 10:14:52 +01:00
proto_quic.c BUG/MINOR: quic: fix fd leak on startup check quic-conn owned socket 2022-12-05 10:45:20 +01:00
proto_sockpair.c MINOR: sockpair: move send_fd_uxst() error message in caller 2022-07-25 16:11:11 +02:00
proto_tcp.c MINOR: protocol: replace ctrl_type with xprt_type and clarify it 2022-05-20 18:39:43 +02:00
proto_udp.c MINOR: protocol: replace ctrl_type with xprt_type and clarify it 2022-05-20 18:39:43 +02:00
proto_uxdg.c MINOR: protocol: replace ctrl_type with xprt_type and clarify it 2022-05-20 18:39:43 +02:00
proto_uxst.c MINOR: protocol: replace ctrl_type with xprt_type and clarify it 2022-05-20 18:39:43 +02:00
protocol.c MINOR: listener: small API change 2022-09-09 17:23:01 +02:00
proxy.c BUG/MINOR: server: make sure "show servers state" hides private bits 2022-10-12 21:45:39 +02:00
qmux_http.c BUG/MEDIUM: mux-quic: properly trim HTX buffer on snd_buf reset 2022-09-20 15:35:33 +02:00
qmux_trace.c BUILD: quic: Fix build for m68k cross-compilation 2022-10-18 12:04:10 +02:00
qpack-dec.c MINOR: qpack: report error on enc/dec stream close 2022-08-17 11:04:53 +02:00
qpack-enc.c BUG/MINOR: qpack: support bigger prefix-integer encoding 2022-05-30 14:30:05 +02:00
qpack-tbl.c CLEANUP: qpack: properly use the QPACK macros not HPACK ones in debug code 2022-11-24 15:38:26 +01:00
queue.c BUG/MEDIUM: queue/threads: limit the number of entries dequeued at once 2022-07-30 10:00:59 +02:00
quic_cc_cubic.c BUG/MEDIUM: quic: Floating point exception in cubic_root() 2022-08-03 14:27:20 +02:00
quic_cc_newreno.c CLEANUP: quic: create a dedicated quic_conn module 2022-10-03 16:25:17 +02:00
quic_cc.c CLEANUP: quic: fix headers 2022-10-03 16:25:17 +02:00
quic_conn.c MINOR: quic: reconnect quic-conn socket on address migration 2022-12-02 14:45:43 +01:00
quic_frame.c CLEANUP: quic: create a dedicated quic_conn module 2022-10-03 16:25:17 +02:00
quic_loss.c MINOR: quic: Split the secrets key allocation in two parts 2022-10-13 10:12:03 +02:00
quic_sock.c MINOR: quic: reconnect quic-conn socket on address migration 2022-12-02 14:45:43 +01:00
quic_stats.c MINOR: quic: detect connection migration 2022-12-02 14:45:43 +01:00
quic_stream.c MINOR: quic: New quic_cstream object implementation 2022-10-13 10:12:03 +02:00
quic_tls.c CLEANUP: quic: create a dedicated quic_conn module 2022-10-03 16:25:17 +02:00
quic_tp.c BUILD: quic: silence two invalid build warnings at -O1 with gcc-6.5 2022-11-24 09:16:41 +01:00
raw_sock.c BUG/MEDIUM: raw-sock: Don't report connection error if something was received 2022-11-18 15:12:23 +01:00
regex.c BUG/MINOR: regex: Properly handle PCRE2 lib compiled without JIT support 2022-09-01 19:34:46 +02:00
resolvers.c CLEANUP: assorted typo fixes in the code and comments 2022-11-30 14:02:36 +01:00
ring.c MINOR: ring: ring_cast_from_area() cast from an allocated area 2022-10-13 16:45:28 +02:00
sample.c MINOR: sample: make the rand() sample fetch function use the statistical_prng 2022-11-24 15:04:13 +01:00
server_state.c
server.c MINOR: tools: add port for ipcmp as optional criteria 2022-12-02 14:45:43 +01:00
session.c
sha1.c
shctx.c
signal.c BUG/MINOR: signals/poller: ensure wakeup from signals 2022-09-09 11:15:22 +02:00
sink.c BUG/MEDIUM: ring: fix creation of server in uninitialized ring 2022-11-16 18:59:43 +01:00
slz.c IMPORT: slz: declare len to fix debug build when optimal match is enabled 2022-11-14 11:14:02 +01:00
sock_inet.c BUG/MINOR: quic: set IP_PKTINFO socket option for QUIC receivers only 2022-10-11 16:46:04 +02:00
sock_unix.c MEDIUM: fd: add the tgid to the fd and pass it to fd_insert() 2022-07-15 19:58:06 +02:00
sock.c MINOR: sockpair: move send_fd_uxst() error message in caller 2022-07-25 16:11:11 +02:00
ssl_ckch.c MEDIUM: ssl: rename the struct "cert_key_and_chain" to "ckch_data" 2022-12-02 11:48:30 +01:00
ssl_crtlist.c MEDIUM: ssl: rename the struct "cert_key_and_chain" to "ckch_data" 2022-12-02 11:48:30 +01:00
ssl_sample.c BUG/MINOR: ssl: don't initialize the keylog callback when not required 2022-11-18 15:24:23 +01:00
ssl_sock.c MEDIUM: ssl: rename the struct "cert_key_and_chain" to "ckch_data" 2022-12-02 11:48:30 +01:00
ssl_utils.c BUILD: ssl_utils: fix build on gcc versions before 8 2022-11-14 11:12:49 +01:00
stats.c BUILD: stats: use __fallthrough in stats_dump_proxy_to_buffer() 2022-11-14 11:14:02 +01:00
stconn.c BUG/MEDIIM: stconn: Flush output data before forwarding close to write side 2022-12-05 11:24:24 +01:00
stick_table.c MINOR: stick-table: change the API of the function used to calculate the shard 2022-11-29 18:06:42 +01:00
stream.c BUG/MINOR: http_ana/txn: don't re-initialize txn and req var lists 2022-11-18 10:20:44 +01:00
task.c BUILD: sched: fix build with DEBUG_THREAD with the previous commit 2022-11-22 10:24:07 +01:00
tcp_act.c MEDIUM: tcp-act: add parameter rst-ttl to silent-drop 2022-11-19 04:53:47 +01:00
tcp_rules.c BUG/MINOR: tcp-rules: Make action call final on read error and delay expiration 2022-06-13 08:04:10 +02:00
tcp_sample.c MINOR: Revert part of clarifying samples support per os commit 2022-09-03 06:11:08 +02:00
tcpcheck.c BUILD: tcpcheck: use __fallthrough in check_proxy_tcpcheck() 2022-11-14 11:14:02 +01:00
thread.c MEDIUM: thread: Restric nbthread/thread-group(s) to very first global sections 2022-11-18 16:03:45 +01:00
time.c
tools.c MINOR: tools: add port for ipcmp as optional criteria 2022-12-02 14:45:43 +01:00
trace.c MEDIUM: trace: create a new "trace" statement in the "global" section 2022-11-16 17:55:53 +01:00
uri_auth.c
uri_normalizer.c
vars.c BUILD: vars: use __fallthrough in var_accounting_{diff,add}() 2022-11-14 11:14:02 +01:00
version.c
wdt.c MINOR: wdt: do not rely on threads_to_dump anymore 2022-07-01 19:26:35 +02:00
xprt_handshake.c CLEANUP: pool/tree-wide: remove suffix "_pool" from certain pool names 2022-06-23 11:49:09 +02:00
xprt_quic.c BUG/MINOR: quic: fix subscribe operation 2022-10-26 18:18:26 +02:00