]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
6 years agoBUG/MINOR: peers: Really close the sessions with no heartbeat.
Frédéric Lécaille [Thu, 21 Mar 2019 10:12:32 +0000 (11:12 +0100)] 
BUG/MINOR: peers: Really close the sessions with no heartbeat.

645635d commit was not sufficient to implement the heartbeat feature.
When no heartbeat was received before its timeout has expired the session was not
closed due to the fact that process_peer_sync() which is the task responsible of
handling the heartbeat and session expirations only checked the heartbeat timeout,
and sent a heartbeat message if it has expired. This has as side
effect to leave the session opened. On the remote side, a peer which receives a
heartbeat message, even if not supported, does not close the session.
Furthermore it not sufficient to update ->reconnect peer member field to schedule
a peer session release.

With this patch, a peer is flagged as alive as soon as it received peer protocol
messages (and not only heartbeat messages). When no updates must be sent,
we first check the reconnection timeout (->reconnect peer member field). If expired,
we really shutdown the session if the peer is not alive, but if the peer seen as alive,
we reset this flag and update the ->reconnect for the next period.
If the reconnection timeout has not expired, then we check the heartbeat timeout
which is there only to emit heartbeat messages upon expirations. If expired, as before this
patch we increment the heartbeat timeout by 3s to schedule the next heartbeat message
then we emit a heartbeat message waking up the peer I/O handler.
In every cases we update the task expiration to the earlier time between the
reconnection time and the heartbeat timeout time so that to be sure to check
again these two ->reconnect and ->heartbeat timers.

6 years ago[RELEASE] Released version 2.0-dev2 v2.0-dev2
Willy Tarreau [Tue, 26 Mar 2019 04:40:51 +0000 (05:40 +0100)] 
[RELEASE] Released version 2.0-dev2

Released version 2.0-dev2 with the following main changes :
    - CLEANUP: http: Remove unreachable code in parse_http_req_capture
    - CLEANUP: stream: Remove bogus loop in conn_si_send_proxy
    - MINOR: lists: Implement locked variations.
    - MEDIUM: servers: Used a locked list for idle_orphan_conns.
    - MEDIUM: servers: Reorganize the way idle connections are cleaned.
    - BUG/MEDIUM: lists: Properly handle the case we're removing the first elt.
    - MINOR: cfgparse: Add a cast to make gcc happier.
    - BUG/MEDIUM: standard: Wrong reallocation size.
    - BUG/MINOR: listener: keep accept rate counters accurate under saturation
    - DOC: fix alphabetic ordering for "tune.fail-alloc" setting
    - MAJOR: config: disable support for nbproc and nbthread in parallel
    - MEDIUM: listener: keep a single thread-mask and warn on "process" misuse
    - MAJOR: listener: do not hold the listener lock in listener_accept()
    - MINOR: listener: maintain a per-thread count of the number of connections on a listener
    - MINOR: tools: implement functions to look up the nth bit set in a mask
    - MINOR: listener: pre-compute some thread counts per bind_conf
    - MINOR: listener: implement multi-queue accept for threads
    - MAJOR: listener: use the multi-queue for multi-thread listeners
    - MINOR: activity: add accept queue counters for pushed and overflows
    - MINOR: config: add global tune.listener.multi-queue setting
    - MAJOR: threads: enable one thread per CPU by default
    - DOC: update management.txt to reflect that threads are used by default
    - BUG/MINOR: config: don't over-count the global maxsock value
    - BUG/MEDIUM: list: fix the rollback on addq in the locked liss
    - BUG/MEDIUM: list: fix LIST_POP_LOCKED's removal of the last pointer
    - BUG/MEDIUM: list: add missing store barriers when updating elements and head
    - MINOR: list: make the delete and pop operations idempotent
    - MINOR: server: remove a few unneeded LIST_INIT calls after LIST_DEL_LOCKED
    - BUG/MEDIUM: listener: use a self-locked list for the dequeue lists
    - BUG/MEDIUM: listener: make sure the listener never accepts too many conns
    - BUG/MEDIUM: list: correct fix for LIST_POP_LOCKED's removal of last element
    - MINOR: listener: introduce listener_backlog() to report the backlog value
    - MINOR: listener: do not needlessly set l->maxconn
    - MINOR: proxy: do not change the listeners' maxconn when updating the frontend's
    - MEDIUM: config: don't enforce a low frontend maxconn value anymore
    - MINOR: peers: Add a message for heartbeat.
    - MINOR: global: keep a copy of the initial rlim_fd_cur and rlim_fd_max values
    - BUG/MINOR: init: never lower rlim_fd_max
    - BUG/MINOR: checks: make external-checks restore the original rlim_fd_cur/max
    - BUG/MINOR: mworker: be careful to restore the original rlim_fd_cur/max on reload
    - MINOR: init: make the maxpipe computation more accurate
    - MINOR: init: move some maxsock updates earlier
    - MEDIUM: init: make the global maxconn default to what rlim_fd_cur permits
    - REGTEST: fix a spurious "nbthread 4" in the connection test
    - DOC: update the text related to the global maxconn value
    - BUG/MAJOR: mux-h2: fix race condition between close on both ends
    - MINOR: sample: Replace "req.ungrpc" smp fetch by a "ungrpc" converter.
    - BUG/MEDIUM: list: fix again LIST_ADDQ_LOCKED
    - MINOR: htx: unconditionally handle parsing errors in requests or responses
    - MINOR: mux-h2: always pass HTX_FL_PARSING_ERROR between h2s and buf on RX
    - BUG/MEDIUM: h2/htx: verify that :path doesn't contain invalid chars
    - MINOR: sample: Code factorization "ungrpc" converter.
    - MINOR: sample: Rework gRPC converter code.
    - CLEANUP: wurfl: remove dead, broken and unmaintained code
    - MINOR: config: relax the range checks on cpu-map
    - BUG/MINOR: ssl: fix warning about ssl-min/max-ver support
    - MINOR: sample: Extract some protocol buffers specific code.
    - DOC: Remove tabs and fixed punctuation.
    - MINOR: sample: Add a protocol buffers specific converter.
    - REGTEST: Peers reg tests.
    - REGTEST: Enable reg tests with HEAD HTTP method usage.
    - MINOR: lists: add a LIST_DEL_INIT() macro
    - MINOR: task: use LIST_DEL_INIT() to remove a task from the queue
    - MINOR: listener: improve incoming traffic distribution
    - MINOR: tools: implement my_flsl()
    - MEDIUM: listener: change the LB algorithm again to use two round robins instead
    - CLEANUP: listener: remove old thread bit mapping
    - MINOR: listener: move thr_idx from the bind_conf to the listener
    - BUG/MEDIUM: logs: Only attempt to free startup_logs once.
    - BUG/MAJOR: config: Wrong maxconn adjustment.
    - BUG/MEDIUM: 51d: fix possible segfault on deinit_51degrees()
    - OPTIM: task: limit the impact of memory barriers in taks_remove_from_task_list()
    - MINOR: fd: Remove debugging code.
    - BUG/MEDIUM: listeners: Don't call fd_stop_recv() if fd_updt is NULL.
    - MINOR: threads: Implement __ha_barrier_atomic*.
    - MEDIUM: threads: Use __ATOMIC_SEQ_CST when using the newer atomic API.
    - MINOR: threads: Add macros to do atomic operation with no memory barrier.
    - MEDIUM: various: Use __ha_barrier_atomic* when relevant.
    - MEDIUM: applets: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: xref: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: fd: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: freq_ctr: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: proxy: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: server: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: task: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: activity: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: backend: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: cache: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: checks: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: pollers: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: compression: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: spoe: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: threads: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: http: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: lb/threads: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: listeners: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: logs: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: memory: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: peers: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: proto_tcp: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: queues: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: sessions: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: ssl: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: stream: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: tcp_rules: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: time: Use the new _HA_ATOMIC_* macros.
    - MEDIUM: vars: Use the new _HA_ATOMIC_* macros.
    - MINOR: config: remove obsolete use of DEFAULT_MAXCONN at various places
    - MINOR: config: continue to rely on DEFAULT_MAXCONN to set the minimum maxconn
    - BUG/MEDIUM: list: fix incorrect pointer unlocking in LIST_DEL_LOCKED()
    - BUG/MEDIUM: listener: make sure we don't pick stopped threads
    - MEDIUM: list: Remove useless barriers.
    - MEDIUM: list: Use _HA_ATOMIC_*
    - MEDIUM: connections: Use _HA_ATOMIC_*
    - BUG/MAJOR: tasks: Use the TASK_GLOBAL flag to know if we're in the global rq.
    - BUG/MEDIUM: threads/fd: do not forget to take into account epoll_fd/pipes
    - BUG/MEDIUM: init/threads: consider epoll_fd/pipes for automatic maxconn calculation
    - BUG/MEDIUM: tasks: Make sure we wake sleeping threads if needed.
    - BUG/MINOR: mux-h1: Don't report an error on EOS if no message was received
    - BUG/MINOR: stats/htx: Call channel_add_input() when response headers are sent
    - BUG/MINOR: lua/htx: Use channel_add_input() when response data are added
    - BUG/MINOR: lua/htx: Don't forget to call htx_to_buf() when appropriate
    - MINOR: stats: Add the status code STAT_STATUS_IVAL to handle invalid requests
    - MINOR: stats: Move stuff about the stats status codes in stats files
    - BUG/MINOR: stats: Be more strict on what is a valid request to the stats applet
    - Revert "REGTEST: Enable reg tests with HEAD HTTP method usage."
    - BUILD: listener: shut up a build warning when threads are disabled
    - BUILD: Makefile: allow the reg-tests target to be verbose
    - BUILD: Makefile: resolve LEVEL before calling run-regtests
    - BUG/MAJOR: spoe: Fix initialization of thread-dependent fields
    - BUG/MAJOR: stats: Fix how huge POST data are read from the channel
    - BUG/MINOR: http/counters: fix missing increment of fe->srv_aborts
    - BUG/MEDIUM: mux-h2: Always wakeup streams with no id to avoid frozen streams
    - MINOR: mux-h2: Set REFUSED_STREAM error to reset a stream if no data was never sent
    - MINOR: muxes: Report the Last read with a dedicated flag
    - MINOR: proto-http/proto-htx: Make error handling clearer during data forwarding
    - BUILD: tools: fix a build warning on some 32-bit archs
    - MINOR: init: report the list of optionally available services
    - MEDIUM: proto_htx: Switch to infinite forwarding if there is no data filter
    - BUG/MINOR: cache: Fully consume large requests in the cache applet
    - BUG/MINOR: stats: Fully consume large requests in the stats applet
    - BUG/MEDIUM: lua: Fully consume large requests when an HTTP applet ends
    - MINOR: proto_http: Add function to handle the header "Expect: 100-continue"
    - MINOR: proto_htx: Add function to handle the header "Expect: 100-continue"
    - MINOR: stats/cache: Handle the header Expect when applets are registered
    - MINOR: http/applets: Handle all applets intercepting HTTP requests the same way
    - CLEANUP: cache: don't export http_cache_applet anymore
    - MINOR: lua: Don't handle the header Expect in lua HTTP applets anymore
    - BUG/MINOR: doc: Be accurate on the behavior on pool-purge-delay.
    - Revert "MEDIUM: proto_htx: Switch to infinite forwarding if there is no data filter"
    - BUG/MEDIUM: mux-h2: Make sure we destroyed the h2s once shutr/shutw is done.
    - BUG/MEDIUM: mux-h2: Don't bother keeping the h2s if detaching and nothing to send.
    - BUG/MEDIUM: mux-h2: Use the right list in h2_stop_senders().
    - MINOR: mux-h2: copy small data blocks more often and reduce the number of pauses
    - CLEANUP: mux-h2: add some comments to help understand the code
    - BUG/MEDIUM: ssl: ability to set TLS 1.3 ciphers using ssl-default-server-ciphersuites
    - BUG/MINOR: log: properly format IPv6 address when LOG_OPT_HEXA modifier is used.
    - BUG/MEDIUM: h2: Try to be fair when sending data.
    - BUG/MINOR: proto-http: Don't forward request body anymore on error
    - MINOR: mux-h2: Remove useless test on ES flag in h2_frt_transfer_data()
    - MINOR: connection: and new flag to mark end of input (EOI)
    - MINOR: channel: Report EOI on the input channel if it was reached in the mux
    - MEDIUM: mux-h2: Don't mix the end of the message with the end of stream
    - MINOR: mux-h1: Set CS_FL_EOI the end of the message is reached
    - BUG/MEDIUM: http/htx: Fix handling of the option abortonclose
    - CLEANUP: muxes/stream-int: Remove flags CS_FL_READ_NULL and SI_FL_READ_NULL
    - MEDIUM: proto_htx: Reintroduce the infinite forwarding on data
    - BUG/MEDIUM: h2: only destroy the h2s if h2s->cs is NULL.
    - BUG/MEDIUM: h2: Use the new sending_list in h2s_notify_send().
    - BUG/MEDIUM: h2: Follow the same logic in h2_deferred_shut than in h2_snd_buf.
    - BUG/MEDIUM: h2: Remove the tasklet from the task list if unsubscribing.
    - BUG/MEDIUM: task/h2: add an idempotent task removal fucntion
    - CLEANUP: task: only perform a LIST_DEL() when the list is not empty
    - BUG/MEDIUM: mux-h2: make sure to always notify streams of EOS condition
    - CONTRIB: debug: report the CS and CF's EOI flags
    - MINOR: channel: don't unset CF_SHUTR_NOW after shutting down.

6 years agoMINOR: channel: don't unset CF_SHUTR_NOW after shutting down.
Willy Tarreau [Mon, 25 Mar 2019 17:35:05 +0000 (18:35 +0100)] 
MINOR: channel: don't unset CF_SHUTR_NOW after shutting down.

This flag is set by the stream layer to request an abort, and results in
CF_SHUTR being set once the abort is performed. However by analogy with
the send side, the flag was removed once the CF_SHUTR flag was set, thus
we lose the information about the cause of the shutr. This is what creates
the confusion that sometimes arises between client and server aborts.

This patch makes sure we don't remove this flag anymore in this case.
All call places only use it to perform the shutr and already check it
against CF_SHUTR. So no condition needs to be updated to take this into
account.

Some later, more careful changes may consist in refining the conditions
where we report a client reset or a server reset to ignore SHUTR when
SHUTR_NOW is set so that we don't report such misleading information
anymore.

6 years agoCONTRIB: debug: report the CS and CF's EOI flags
Willy Tarreau [Mon, 25 Mar 2019 17:34:28 +0000 (18:34 +0100)] 
CONTRIB: debug: report the CS and CF's EOI flags

These ones indicate an end of input.

6 years agoBUG/MEDIUM: mux-h2: make sure to always notify streams of EOS condition
Willy Tarreau [Mon, 25 Mar 2019 17:13:16 +0000 (18:13 +0100)] 
BUG/MEDIUM: mux-h2: make sure to always notify streams of EOS condition

Recent commit 63768a63d ("MEDIUM: mux-h2: Don't mix the end of the message
with the end of stream") introduced a race which may manifest itself with
small connection counts on large objects and large server timeouts in
legacy mode. Sometimes h2s_close() is called while the data layer is
subscribed to read events but nothing in the chain can cause this wake-up
to happen and some streams stall for a while at the end of a transfer
until the server timeout strikes and ends the stream completes.

We need to wake the stream up if it's subscribed to rx events there,
which is what this patch does. When the patch above is backported to
1.9, this patch will also have to be backported.

6 years agoCLEANUP: task: only perform a LIST_DEL() when the list is not empty
Willy Tarreau [Mon, 25 Mar 2019 17:10:53 +0000 (18:10 +0100)] 
CLEANUP: task: only perform a LIST_DEL() when the list is not empty

In tasklet_free() we unconditionally perform a LIST_DEL() even when
the list is empty, let's move the LIST_DEL() inside the matching block.

6 years agoBUG/MEDIUM: task/h2: add an idempotent task removal fucntion
Willy Tarreau [Mon, 25 Mar 2019 17:02:54 +0000 (18:02 +0100)] 
BUG/MEDIUM: task/h2: add an idempotent task removal fucntion

Previous commit 3ea351368 ("BUG/MEDIUM: h2: Remove the tasklet from the
task list if unsubscribing.") uncovered an issue which needs to be
addressed in the scheduler's API. The function task_remove_from_task_list()
was initially designed to remove a task from the running tasklet list from
within the scheduler, and had to be used in h2 to abort pending I/O events.
However this function was not designed to be idempotent, occasionally
causing a double removal from the tasklet list, with the second doing
nothing but affecting the apparent tasks count and making haproxy use
100% CPU on some tests consisting in stopping the client during some
transfers. The h2_unsubscribe() function can sometimes be called upon
stream exit after an error where the tasklet was possibly already
removed, so it.

This patch does 2 things :
  - it renames task_remove_from_task_list() to
    __task_remove_from_tasklet_list() to discourage users from calling
    it. Also note the fix in the naming since it's a tasklet list and
    not a task list. This function is still uesd from the scheduler.
  - it adds a new, idempotent, task_remove_from_tasklet_list() function
    which does nothing if the task is already not in the tasklet list.

This patch will need to be backported where the commit above is backported.

6 years agoBUG/MEDIUM: h2: Remove the tasklet from the task list if unsubscribing.
Olivier Houchard [Mon, 25 Mar 2019 13:10:42 +0000 (14:10 +0100)] 
BUG/MEDIUM: h2: Remove the tasklet from the task list if unsubscribing.

In h2_unsubscribe(), if we unsubscribe on SUB_CALL_UNSUBSCRIBE, then remove
ourself from the sending_list, and remove the tasklet from the task list.
We're probably about to destroy the stream anyway, so we don't want the
tasklet to run, or to stay in the sending_list, or it could lead to a crash.

This should be backpored to 1.9.

6 years agoBUG/MEDIUM: h2: Follow the same logic in h2_deferred_shut than in h2_snd_buf.
Olivier Houchard [Mon, 25 Mar 2019 13:08:01 +0000 (14:08 +0100)] 
BUG/MEDIUM: h2: Follow the same logic in h2_deferred_shut than in h2_snd_buf.

In h2_deferred_shut(), don't just set h2s->send_wait to NULL, instead, use
the same logic as in h2_snd_buf() and only do so if we successfully sent data
(or if we don't want to send them anymore). Setting it to NULL can lead to
crashes.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: h2: Use the new sending_list in h2s_notify_send().
Olivier Houchard [Mon, 25 Mar 2019 13:04:25 +0000 (14:04 +0100)] 
BUG/MEDIUM: h2: Use the new sending_list in h2s_notify_send().

In h2s_notify_send(), use the new sending_list instead of using the old
way of setting hs->send_wait to NULL, failing to do so may lead to crashes.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: h2: only destroy the h2s if h2s->cs is NULL.
Olivier Houchard [Mon, 25 Mar 2019 12:25:02 +0000 (13:25 +0100)] 
BUG/MEDIUM: h2: only destroy the h2s if h2s->cs is NULL.

In h2_deferred_shut(), only attempt to destroy the h2s if h2s->cs is NULL.
h2s->cs being non-NULL means it's still referenced by the stream interface,
so it may try to use it later, and that could lead to a crash.

This should be backported to 1.9.

6 years agoMEDIUM: proto_htx: Reintroduce the infinite forwarding on data
Christopher Faulet [Fri, 22 Mar 2019 13:54:52 +0000 (14:54 +0100)] 
MEDIUM: proto_htx: Reintroduce the infinite forwarding on data

This commit was reverted because of bugs. Now it should be ok. Difference with
the commit f52170d2f ("MEDIUM: proto_htx: Switch to infinite forwarding if there
is no data filte") is that when the infinite forwarding is enabled, the message
is switched to the state HTTP_MSG_DONE if the flag CF_EOI is set.

6 years agoCLEANUP: muxes/stream-int: Remove flags CS_FL_READ_NULL and SI_FL_READ_NULL
Christopher Faulet [Fri, 22 Mar 2019 13:51:36 +0000 (14:51 +0100)] 
CLEANUP: muxes/stream-int: Remove flags CS_FL_READ_NULL and SI_FL_READ_NULL

Since the flag CF_SHUTR is no more set to mark the end of the message, these
flags become useless.

This patch should be backported to 1.9.

6 years agoBUG/MEDIUM: http/htx: Fix handling of the option abortonclose
Christopher Faulet [Fri, 22 Mar 2019 13:23:18 +0000 (14:23 +0100)] 
BUG/MEDIUM: http/htx: Fix handling of the option abortonclose

Because the flag CF_SHUTR is no more set to mark the end of the message by the
H2 multiplexer, we can rely on it again to detect aborts. there is no more need
to make a check on the flag SI_FL_CLEAN_ABRT when the option abortonclose is
enabled. So, this option should work as before for h2 clients.

This patch must be backported to 1.9 with the previous EOI patches.

6 years agoMINOR: mux-h1: Set CS_FL_EOI the end of the message is reached
Christopher Faulet [Fri, 22 Mar 2019 13:09:41 +0000 (14:09 +0100)] 
MINOR: mux-h1: Set CS_FL_EOI the end of the message is reached

As for the H2 multiplexer, When the end of a message is detected, the flag
CS_FL_EOI is set on the conn_stream.

This patch should be backported to 1.9.

6 years agoMEDIUM: mux-h2: Don't mix the end of the message with the end of stream
Christopher Faulet [Fri, 22 Mar 2019 13:05:52 +0000 (14:05 +0100)] 
MEDIUM: mux-h2: Don't mix the end of the message with the end of stream

The H2 multiplexer now sets CS_FL_EOI when it receives a frame with the ES
flag. And when the H2 streams is closed, it set the flag CS_FL_REOS.

This patch should be backported to 1.9.

6 years agoMINOR: channel: Report EOI on the input channel if it was reached in the mux
Christopher Faulet [Fri, 22 Mar 2019 13:16:14 +0000 (14:16 +0100)] 
MINOR: channel: Report EOI on the input channel if it was reached in the mux

The flag CF_EOI is now set on the input channel when the flag CS_FL_EOI is set
on the corresponding conn_stream. In addition, if a read activity is reported
when this flag is set, the stream is woken up.

This patch should be backported to 1.9.

6 years agoMINOR: connection: and new flag to mark end of input (EOI)
Christopher Faulet [Fri, 22 Mar 2019 13:05:52 +0000 (14:05 +0100)] 
MINOR: connection: and new flag to mark end of input (EOI)

Since the begining, in the H2 multiplexer, when the end of a message is reached,
the flag CS_FL_(R)EOS is set on the conn_stream to notify the upper layer that
all data were received and consumed and there is no longer any expected. The
stream-interface converts it into a shutdown read. But it leads to some
ambiguities with the real shutr. Once it was reported at the end of the message,
there is no way to report it when the read0 is received. For this reason, aborts
after the message was fully received cannot be reported. And on the channel
side, it is hard to make the difference between a shutr because the end of the
message was reached and a shutr because of an abort.

For these reasons, there is now a flag to mark the end of the message. It is
called CS_FL_EOI (end-of-input) because it is only used on the receipt path.
This flag is only declared and not used yet.

This patch will be used by future bug fixes and will have to be backported
to 1.9.

6 years agoMINOR: mux-h2: Remove useless test on ES flag in h2_frt_transfer_data()
Christopher Faulet [Fri, 22 Mar 2019 13:12:11 +0000 (14:12 +0100)] 
MINOR: mux-h2: Remove useless test on ES flag in h2_frt_transfer_data()

Same test is already performed in the caller function, h2c_frt_handle_data().

This patch should be backported to 1.9.

6 years agoBUG/MINOR: proto-http: Don't forward request body anymore on error
Christopher Faulet [Tue, 19 Mar 2019 13:55:11 +0000 (14:55 +0100)] 
BUG/MINOR: proto-http: Don't forward request body anymore on error

In the commit 93e02d8b7 ("MINOR: proto-http/proto-htx: Make error handling
clearer during data forwarding"), a return clause was removed by error in the
function http_request_forward_body(). This bug seems not having any visible
impact.

This patch must be backported to 1.9.

6 years agoBUG/MEDIUM: h2: Try to be fair when sending data.
Olivier Houchard [Fri, 22 Mar 2019 16:37:16 +0000 (17:37 +0100)] 
BUG/MEDIUM: h2: Try to be fair when sending data.

On the send path, try to be fair, and make sure the first to attempt to
send data will actually be the first to send data when it's possible (ie
when the mux' buffer is not full anymore).
To do so, use a separate list element for the sending_list, and only remove
the h2s from the send_list/fctl_list if we successfully sent data. If we did
not, we'll keep our place in the list, and will be able to try again next time.

This should be backported to 1.9.

6 years agoBUG/MINOR: log: properly format IPv6 address when LOG_OPT_HEXA modifier is used.
Radek Zajic [Fri, 22 Mar 2019 10:21:54 +0000 (10:21 +0000)] 
BUG/MINOR: log: properly format IPv6 address when LOG_OPT_HEXA modifier is used.

In lf_ip(), when LOG_OPT_HEXA modifier is used, there is a code to format the
IP address as a hexadecimal string. This code does not properly handle cases
when the IP address is IPv6. In such case, the code only prints `00000000`.

This patch adds support for IPv6. For legacy IPv4, the format remains
unchanged. If IPv6 socket is used to accept IPv6 connection, the full IPv6
address is returned. For example, IPv6 localhost, ::1, is printed as
00000000000000000000000000000001.

If IPv6 socket accepts IPv4 connection, the IPv4 address is mapped by the
kernel into the IPv4-mapped-IPv6 address space (RFC4291, section 2.5.5.2)
and is formatted as such. For example, 127.0.0.1 becomes ::ffff:127.0.0.1,
which is printed as 00000000000000000000FFFF7F000001.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: ssl: ability to set TLS 1.3 ciphers using ssl-default-server-ciphersuites
Pierre Cheynier [Thu, 21 Mar 2019 16:15:47 +0000 (16:15 +0000)] 
BUG/MEDIUM: ssl: ability to set TLS 1.3 ciphers using ssl-default-server-ciphersuites

Any attempt to put TLS 1.3 ciphers on servers failed with output 'unable
to set TLS 1.3 cipher suites'.

This was due to usage of SSL_CTX_set_cipher_list instead of
SSL_CTX_set_ciphersuites in the TLS 1.3 block (protected by
OPENSSL_VERSION_NUMBER >= 0x10101000L & so).

This should be backported to 1.9 and 1.8.

Signed-off-by: Pierre Cheynier <p.cheynier@criteo.com>
Reported-by: Damien Claisse <d.claisse@criteo.com>
Cc: Emeric Brun <ebrun@haproxy.com>
6 years agoCLEANUP: mux-h2: add some comments to help understand the code
Willy Tarreau [Thu, 21 Mar 2019 18:19:36 +0000 (19:19 +0100)] 
CLEANUP: mux-h2: add some comments to help understand the code

Some functions' roles and usage are far from being obvious, and diving
into this part each time requires deep concentration before starting to
understand who does what. Let's add a few comments which help figure
some of the useful pieces.

6 years agoMINOR: mux-h2: copy small data blocks more often and reduce the number of pauses
Willy Tarreau [Thu, 21 Mar 2019 16:47:28 +0000 (17:47 +0100)] 
MINOR: mux-h2: copy small data blocks more often and reduce the number of pauses

We tend to refrain from sending data a bit too much in the H2 mux :
whenever there are pending data in the buffer and we try to copy
something larger than 1/4 of the buffer we prefer to pause. This
is suboptimal for medium-sized objects which have to send their
headers and later their data.

This patch slightly changes this by allowing a copy of a large block
if it fits at once and if the realign cost is small, i.e. the pending
data are small or the block fits in the contiguous area. Depending on
the object size this measurably improves the download performance by
between 1 and 10%, and possibly lowers the transfer latency for medium
objects.

6 years agoBUG/MEDIUM: mux-h2: Use the right list in h2_stop_senders().
Olivier Houchard [Thu, 21 Mar 2019 14:50:58 +0000 (15:50 +0100)] 
BUG/MEDIUM: mux-h2: Use the right list in h2_stop_senders().

In h2_stop_senders(), when we're about to move the h2s about to send back
to the send_list, because we know the mux is full, instead of putting them
all in the send_list, put them back either in the fctl_list or the send_list
depending on if they are waiting for the flow control or not. This also makes
sure they're inserted in their arrival order and not reversed.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: mux-h2: Don't bother keeping the h2s if detaching and nothing to send.
Olivier Houchard [Thu, 21 Mar 2019 14:48:46 +0000 (15:48 +0100)] 
BUG/MEDIUM: mux-h2: Don't bother keeping the h2s if detaching and nothing to send.

In h2_detach(), don't bother keeping the h2s even if it was waiting for
flow control if we no longer are subscribed for receiving or sending, as
nobody will do anything once we can write in the mux, anyway. Failing to do
so may lead to h2s being kept opened forever.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: mux-h2: Make sure we destroyed the h2s once shutr/shutw is done.
Olivier Houchard [Thu, 21 Mar 2019 14:47:13 +0000 (15:47 +0100)] 
BUG/MEDIUM: mux-h2: Make sure we destroyed the h2s once shutr/shutw is done.

If we're waiting until we can send a shutr and/or a shutw, once we're done
and not considering sending anything, destroy the h2s, and eventually the
h2c if we're done with the whole connection, or it will never be done.

This should be backported to 1.9.

6 years agoRevert "MEDIUM: proto_htx: Switch to infinite forwarding if there is no data filter"
Willy Tarreau [Thu, 21 Mar 2019 17:00:30 +0000 (18:00 +0100)] 
Revert "MEDIUM: proto_htx: Switch to infinite forwarding if there is no data filter"

This reverts commit f52170d2f47efbace729bc88349eb189968df568.

This commit was merged too early, some areas are not ready and
transfers from H1 to H2 often stall. Christopher suggested to wait
for the other parts to be ready before reintroducing it.

6 years agoBUG/MINOR: doc: Be accurate on the behavior on pool-purge-delay.
Olivier Houchard [Tue, 19 Mar 2019 15:44:02 +0000 (16:44 +0100)] 
BUG/MINOR: doc: Be accurate on the behavior on pool-purge-delay.

Setting pool-purge-delay to 0 disables the pool, it doesn't keep the
connection forever, so correctly states this.

This should be backported to 1.9.

6 years agoMINOR: lua: Don't handle the header Expect in lua HTTP applets anymore
Christopher Faulet [Fri, 1 Mar 2019 11:02:08 +0000 (12:02 +0100)] 
MINOR: lua: Don't handle the header Expect in lua HTTP applets anymore

This header is now handled in HTTP analyzers the same way for all HTTP applets.

6 years agoCLEANUP: cache: don't export http_cache_applet anymore
Willy Tarreau [Tue, 19 Mar 2019 08:57:55 +0000 (09:57 +0100)] 
CLEANUP: cache: don't export http_cache_applet anymore

This one can become static since it's not used by http/htx anymore.

6 years agoMINOR: http/applets: Handle all applets intercepting HTTP requests the same way
Christopher Faulet [Fri, 1 Mar 2019 10:44:26 +0000 (11:44 +0100)] 
MINOR: http/applets: Handle all applets intercepting HTTP requests the same way

In addition to stats and cache applets, there are also HTTP applet services
declared in an http-request rule. All these applets are now handled the same
way. Among other things, the header Expect is handled at the same place for all
these applets.

6 years agoMINOR: stats/cache: Handle the header Expect when applets are registered
Christopher Faulet [Fri, 1 Mar 2019 10:36:26 +0000 (11:36 +0100)] 
MINOR: stats/cache: Handle the header Expect when applets are registered

First of all, it is a way to handle 100-Continue for the cache without
duplicating code. Then, for the stats, it is no longer necessary to wait for the
request body.

6 years agoMINOR: proto_htx: Add function to handle the header "Expect: 100-continue"
Christopher Faulet [Fri, 1 Mar 2019 10:19:40 +0000 (11:19 +0100)] 
MINOR: proto_htx: Add function to handle the header "Expect: 100-continue"

The function htx_handle_expect_hdr() is now responsible to search the header
"Expect" and send the corresponding response if necessary.

6 years agoMINOR: proto_http: Add function to handle the header "Expect: 100-continue"
Christopher Faulet [Fri, 1 Mar 2019 10:16:34 +0000 (11:16 +0100)] 
MINOR: proto_http: Add function to handle the header "Expect: 100-continue"

The function http_handle_expect_hdr() is now responsible to search the header
"Expect" and send the corresponding response if necessary.

6 years agoBUG/MEDIUM: lua: Fully consume large requests when an HTTP applet ends
Christopher Faulet [Wed, 27 Feb 2019 21:06:23 +0000 (22:06 +0100)] 
BUG/MEDIUM: lua: Fully consume large requests when an HTTP applet ends

In Lua, when an HTTP applet ends (in HTX and legacy HTTP), we must flush
remaining outgoing data on the request. But only outgoing data at time the
applet is called are consumed. If a request with a huge body is sent, an error
is triggerred because a SHUTW is catched for an unfinisehd request.

Now, we consume request data until the end. In fact, we don't try to shutdown
the request's channel for write anymore.

This patch must be backported to 1.9 after some observation period. It should
probably be backported in prior versions too. But honnestly, with refactoring
on the connection layer and the stream interface in 1.9, it is probably safer
to not do so.

6 years agoBUG/MINOR: stats: Fully consume large requests in the stats applet
Christopher Faulet [Wed, 27 Feb 2019 15:19:48 +0000 (16:19 +0100)] 
BUG/MINOR: stats: Fully consume large requests in the stats applet

In the stats applet (in HTX and legacy HTTP), after a response is fully sent to
a client, the request is consumed. It is done at the end, after all the response
was copied into the channel's buffer. But only outgoing data at time the applet
is called are consumed. Then the applet is closed. If a request with a huge body
is sent, an error is triggerred because a SHUTW is catched for an unfinisehd
request.

Now, we consume request data until the end. In fact, we don't try to shutdown
the request's channel for write anymore.

This patch must be backported to 1.9 after some observation period. It should
probably be backported in prior versions too. But honnestly, with refactoring
on the connection layer and the stream interface in 1.9, it is probably safer
to not do so.

6 years agoBUG/MINOR: cache: Fully consume large requests in the cache applet
Christopher Faulet [Mon, 25 Feb 2019 10:40:49 +0000 (11:40 +0100)] 
BUG/MINOR: cache: Fully consume large requests in the cache applet

In the cache applet (in HTX and legacy HTTP), when an cached object is sent to a
client, the request must be consumed. It is done at the end, after all the
response was copied into the channel's buffer. But only outgoing data at time
the applet is called are consumed. Then the applet is closed. If a request with
a huge body is sent, an error is triggerred because a SHUTW is catched on an
unfinished request.

Now, we consume request data as soon as possible and we do it until the end. In
fact, we don't try to shutdown the request's channel for write anymore.

This patch must be backported to 1.9 after some observation period.

6 years agoMEDIUM: proto_htx: Switch to infinite forwarding if there is no data filter
Christopher Faulet [Fri, 8 Mar 2019 14:45:26 +0000 (15:45 +0100)] 
MEDIUM: proto_htx: Switch to infinite forwarding if there is no data filter

Because in HTX the parsing is done by the multiplexers, there is no reason to
limit the amount of data fast-forwarded. Of course, it is only true when there
is no data filter registered on the corresponding channel. So now, we enable the
infinite forwarding when possible. However, the HTTP message state remains
HTTP_MSG_DATA. Then, when infinite forwarding is enabled, if the flag CF_SHUTR
is set, the state is switched to HTTP_MSG_DONE.

6 years agoMINOR: init: report the list of optionally available services
Willy Tarreau [Tue, 19 Mar 2019 07:08:10 +0000 (08:08 +0100)] 
MINOR: init: report the list of optionally available services

It's never easy to guess what services are built in. We currently have
the prometheus exporter in contrib/ which is the only extension for now.
Let's enumerate all available ones just like we do for filterr and pollers.

6 years agoBUILD: tools: fix a build warning on some 32-bit archs
Willy Tarreau [Mon, 18 Mar 2019 15:31:18 +0000 (16:31 +0100)] 
BUILD: tools: fix a build warning on some 32-bit archs

Some recent versions of gcc apparently can detect that x >> 32 will not
work on a 32-bit architecture, but are failing to see that the code will
not be built since it's enclosed in "if (sizeof(LONG) > 4)" or equivalent.
Just shift right twice by 16 bits in this case, the compiler correctly
replaces it by a single 32-bit shift.

No backport is needed.

6 years agoMINOR: proto-http/proto-htx: Make error handling clearer during data forwarding
Christopher Faulet [Fri, 8 Mar 2019 13:18:50 +0000 (14:18 +0100)] 
MINOR: proto-http/proto-htx: Make error handling clearer during data forwarding

It is just a cleanup. Error handling is grouped at the end HTTP data analysers.

This patch must be backported to 1.9 because it is used by another patch to fix
a bug.

6 years agoMINOR: muxes: Report the Last read with a dedicated flag
Christopher Faulet [Fri, 8 Mar 2019 08:23:46 +0000 (09:23 +0100)] 
MINOR: muxes: Report the Last read with a dedicated flag

For conveniance, in HTTP muxes (h1 and h2), the end of the stream and the end of
the message are reported the same way to the stream, by setting the flag
CS_FL_EOS. In the stream-interface, when CS_FL_EOS is detected, a shutdown for
read is reported on the channel side. This is historical. With the legacy HTTP
layer, because the parsing is done by the stream in HTTP analyzers, the EOS
really means a shutdown for read.

Most of time, for muxes h1 and h2, it works pretty well, especially because the
keep-alive is handled by the muxes. The stream is only used for one
transaction. So mixing EOS and EOM is good enough. But not everytime. For now,
client aborts are only reported if it happens before the end of the request. It
is an error and it is properly handled. But because the EOS was already
reported, client aborts after the end of the request are silently
ignored. Eventually an error can be reported when the response is sent to the
client, if the sending fails. Otherwise, if the server does not reply fast
enough, an error is reported when the server timeout is reached. It is the
expected behaviour, excpect when the option abortonclose is set. In this case,
we must report an error when the client aborts. But as said before, this event
can be ignored. So to be short, for now, the abortonclose is broken.

In fact, it is a design problem and we have to rethink all channel's flags and
probably the conn-stream ones too. It is important to split EOS and EOM to not
loose information anymore. But it is not a small job and the refactoring will be
far from straightforward.

So for now, temporary flags are introduced. When the last read is received, the
flag CS_FL_READ_NULL is set on the conn-stream. This way, we can set the flag
SI_FL_READ_NULL on the stream interface. Both flags are persistant. And to be
sure to wake the stream, the event CF_READ_NULL is reported. So the stream will
always have the chance to handle the last read.

This patch must be backported to 1.9 because it will be used by another patch to
fix the option abortonclose.

6 years agoMINOR: mux-h2: Set REFUSED_STREAM error to reset a stream if no data was never sent
Christopher Faulet [Thu, 7 Mar 2019 14:51:33 +0000 (15:51 +0100)] 
MINOR: mux-h2: Set REFUSED_STREAM error to reset a stream if no data was never sent

According to the H2 spec (see #8.1.4), setting the REFUSED_STREAM error code
is a way to indicate that the stream is being closed prior to any processing
having occurred, such as when a server-side H1 keepalive connection is closed
without sending anything (which differs from the regular error case since
haproxy doesn't even generate an error message). Any request that was sent on
the reset stream can be safely retried. So, when a stream is closed, if no
data was ever sent back (ie. the flag H2_SF_HEADERS_SENT is not set), we can
set the REFUSED_STREAM error code on the RST_STREAM frame.

This patch may be backported to 1.9.

6 years agoBUG/MEDIUM: mux-h2: Always wakeup streams with no id to avoid frozen streams
Christopher Faulet [Thu, 7 Mar 2019 15:21:34 +0000 (16:21 +0100)] 
BUG/MEDIUM: mux-h2: Always wakeup streams with no id to avoid frozen streams

This only happens for server streams because their id is assigned when the first
message is sent. If these streams are not woken up, some events can be lost
leading to frozen streams. For instance, it happens when a server closes its
connection before sending its preface.

This patch must be backported to 1.9.

6 years agoBUG/MINOR: http/counters: fix missing increment of fe->srv_aborts
Willy Tarreau [Mon, 18 Mar 2019 10:02:57 +0000 (11:02 +0100)] 
BUG/MINOR: http/counters: fix missing increment of fe->srv_aborts

When a server aborts a transfer, we used to increment the backend's
counter but not the frontend's during the forwarding phase. This fixes
it. It might be backported to all supported versions (possibly removing
the htx part) though it is of very low importance.

6 years agoBUG/MAJOR: stats: Fix how huge POST data are read from the channel
Christopher Faulet [Wed, 27 Feb 2019 14:30:57 +0000 (15:30 +0100)] 
BUG/MAJOR: stats: Fix how huge POST data are read from the channel

When the body length is greater than a chunk size (so if length of POST data
exceeds the buffer size), the requests is rejected with the status code
STAT_STATUS_EXCD. Otherwise the stats applet will wait to have all the data to
copy and parse them. But there is a problem when the total request size
(including the headers) is just lower than the buffer size but greater the
buffer size less the reserve. In such case, the body length is considered as
enough small to be processed but not entierly received. So the stats applet
waits for more data. But because outgoing data are still there, the channel's
buffer is considered as full and nothing more can be read, leading to a freeze
of the session.

Note this bug is pretty easy to reproduce with the legacy HTTP. It is harder
with the HTX but still possible. To fix the bug, in the stats applet, when the
request is not fully received, we check if at least the reserve remains
available the channel's buffer.

This patch must be backported as far as 1.5. But because the HTX does not exist
in 1.8 and lower, it will have to be adapted for these versions.

6 years agoBUG/MAJOR: spoe: Fix initialization of thread-dependent fields
Christopher Faulet [Mon, 18 Mar 2019 12:57:42 +0000 (13:57 +0100)] 
BUG/MAJOR: spoe: Fix initialization of thread-dependent fields

A bug was introduced in the commit b0769b ("BUG/MEDIUM: spoe: initialization
depending on nbthread must be done last"). The code depending on global.nbthread
was moved from cfg_parse_spoe_agent() to spoe_check() but the pointer on the
agent configuration was not updated to use the filter's one. The variable
curagent is a global variable only valid during the configuration parsing. In
spoe_check(), conf->agent must be used instead.

This patch must be backported to 1.9 and 1.8.

6 years agoBUILD: Makefile: resolve LEVEL before calling run-regtests
Willy Tarreau [Fri, 15 Mar 2019 16:29:53 +0000 (17:29 +0100)] 
BUILD: Makefile: resolve LEVEL before calling run-regtests

Calling "make reg-tests V=1" shows --LEVEL "$LEVEL" which is not quite
useful. Let's use "$(LEVEL)" instead of "$$LEVEL" so that make resolves
the variable before launching the command. This way the reported command
is usable from the shell.

6 years agoBUILD: Makefile: allow the reg-tests target to be verbose
Willy Tarreau [Fri, 15 Mar 2019 16:28:36 +0000 (17:28 +0100)] 
BUILD: Makefile: allow the reg-tests target to be verbose

When debugging reg-tests, it's quite annoying not to be able to figure
the syntax to call the scripts. Let's replace the '@' with '$(Q)' as for
other commands so that launching them with "V=1" is enough to reveal the
command line.

6 years agoBUILD: listener: shut up a build warning when threads are disabled
Willy Tarreau [Fri, 15 Mar 2019 16:16:34 +0000 (17:16 +0100)] 
BUILD: listener: shut up a build warning when threads are disabled

We get this with __decl_hathreads due to the lone semi-colon, let's move
it at the end of the innermost declaration :

  src/listener.c: In function 'listener_accept':
  src/listener.c:601:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

6 years agoRevert "REGTEST: Enable reg tests with HEAD HTTP method usage."
Willy Tarreau [Fri, 15 Mar 2019 14:07:12 +0000 (15:07 +0100)] 
Revert "REGTEST: Enable reg tests with HEAD HTTP method usage."

This reverts commit 47e4e13c0177b1cc910e1a62575a5e12235ba2c4.

It's a temporary revert. This commit suggested to update to vtest
commit 4e43cc1 to fix handling of HEAD requests, but the compression
was broken two commits before, leaving us with no single version of
vtest being able to run all tests anymore.

Let's temporary disable HEAD again in the tests so that we can use
any version up to and including a2e82a8 for the time it takes vtest
to fix the compression.

6 years agoBUG/MINOR: stats: Be more strict on what is a valid request to the stats applet
Christopher Faulet [Wed, 27 Feb 2019 14:15:23 +0000 (15:15 +0100)] 
BUG/MINOR: stats: Be more strict on what is a valid request to the stats applet

First of all, only GET, HEAD and POST methods are now allowed. Others will be
rejected with the status code STAT_STATUS_IVAL (invalid request). Then, for the
legacy HTTP, only POST requests with a content-length are allowed. Now, chunked
encoded requests are also considered as invalid because the chunk formatting
will interfere with the parsing of POST parameters. In HTX, It is not a problem
because data are unchunked.

This patch must be backported to 1.9. For prior versions too, but HTX part must
be removed. The patch introducing the status code STAT_STATUS_IVAL must also be
backported.

6 years agoMINOR: stats: Move stuff about the stats status codes in stats files
Christopher Faulet [Wed, 27 Feb 2019 15:42:58 +0000 (16:42 +0100)] 
MINOR: stats: Move stuff about the stats status codes in stats files

The status codes definition (STAT_STATUS_*) and their string representation
stat_status_codes) have been moved in stats files. There is no reason to keep
them in proto_http files.

6 years agoMINOR: stats: Add the status code STAT_STATUS_IVAL to handle invalid requests
Christopher Faulet [Wed, 27 Feb 2019 15:41:27 +0000 (16:41 +0100)] 
MINOR: stats: Add the status code STAT_STATUS_IVAL to handle invalid requests

This patch must be backported to 1.9 because a bug fix depends on it.

6 years agoBUG/MINOR: lua/htx: Don't forget to call htx_to_buf() when appropriate
Christopher Faulet [Wed, 27 Feb 2019 20:36:59 +0000 (21:36 +0100)] 
BUG/MINOR: lua/htx: Don't forget to call htx_to_buf() when appropriate

When htx_from_buf() is used to get an HTX message from a buffer, htx_to_buf()
must always be called when finish. Some calls to htx_to_buf() were missing.

This patch must be backported to 1.9.

6 years agoBUG/MINOR: lua/htx: Use channel_add_input() when response data are added
Christopher Faulet [Wed, 27 Feb 2019 20:20:09 +0000 (21:20 +0100)] 
BUG/MINOR: lua/htx: Use channel_add_input() when response data are added

This patch must be backported to 1.9.

6 years agoBUG/MINOR: stats/htx: Call channel_add_input() when response headers are sent
Christopher Faulet [Wed, 27 Feb 2019 15:28:48 +0000 (16:28 +0100)] 
BUG/MINOR: stats/htx: Call channel_add_input() when response headers are sent

This function will only increment the total amount of bytes read by a channel
because at this stage there is no fast forwarding. So the bug is pretty limited.

This patch must be backported to 1.9.

6 years agoBUG/MINOR: mux-h1: Don't report an error on EOS if no message was received
Christopher Faulet [Fri, 8 Mar 2019 14:13:41 +0000 (15:13 +0100)] 
BUG/MINOR: mux-h1: Don't report an error on EOS if no message was received

An error is reported if the EOS is detected before the end of the message. But
we must be carefull to not report an error if there is no message at all.

This patch must be backported to 1.9.

6 years agoBUG/MEDIUM: tasks: Make sure we wake sleeping threads if needed.
Olivier Houchard [Thu, 14 Mar 2019 23:23:10 +0000 (00:23 +0100)] 
BUG/MEDIUM: tasks: Make sure we wake sleeping threads if needed.

When waking a task on a remote thread, we currently check 1) if this
thread was sleeping, and 2) if it was already marked as active before
writing to its pipe. Unfortunately this doesn't always work as desired
because only one thread from the mask is woken up, while the
active_tasks_mask indicates all eligible threads for this task. As a
result, if one multi-thread task (e.g. a health check) wakes up to run
on any thread, then an accept() dispatches an incoming connection on
thread 2, this thread will already have its bit set in active_tasks_mask
because of the previous wakeup and will not be woken up.

This is easily noticeable on 2.0-dev by injecting on a multi-threaded
listener with a single connection at a time while health checks are
running quickly in the background : the injection runs slowly with
random response times (the poll timeouts). In 1.9 it affects the
dequeing of server connections, which occasionally experience pauses
if multiple threads share the same queue.

The correct solution consists in adjusting the sleeping_thread_mask
when waking another thread up. This mask reflects threads that are
sleeping, hence that need to be signaled to wake up. Threads with a
bit in active_tasks_mask already don't have their sleeping_thread_mask
bit set before polling so the principle remains consistent. And by
doing so we can remove the old_active_mask field.

This should be backported to 1.9.

6 years agoBUG/MEDIUM: init/threads: consider epoll_fd/pipes for automatic maxconn calculation
Willy Tarreau [Thu, 14 Mar 2019 18:13:17 +0000 (19:13 +0100)] 
BUG/MEDIUM: init/threads: consider epoll_fd/pipes for automatic maxconn calculation

This is the equivalent of the previous patch for the automatic maxconn
calculation. This doesn't need any backport.

6 years agoBUG/MEDIUM: threads/fd: do not forget to take into account epoll_fd/pipes
Willy Tarreau [Thu, 14 Mar 2019 18:10:55 +0000 (19:10 +0100)] 
BUG/MEDIUM: threads/fd: do not forget to take into account epoll_fd/pipes

Each thread uses one epoll_fd or kqueue_fd, and a pipe (thus two FDs).
These ones have to be accounted for in the maxsock calculation, otherwise
we can reach maxsock before maxconn. This is difficult to observe but it
in fact happens when a server connects back to the frontend and has checks
enabled : the check uses its FD and serves to fill the loop. In this case
all FDs planed for the datapath are used for this.

This needs to be backported to 1.9 and 1.8.

6 years agoBUG/MAJOR: tasks: Use the TASK_GLOBAL flag to know if we're in the global rq.
Olivier Houchard [Thu, 14 Mar 2019 15:14:04 +0000 (16:14 +0100)] 
BUG/MAJOR: tasks: Use the TASK_GLOBAL flag to know if we're in the global rq.

In task_unlink_rq, to decide if we should logk the global runqueue lock,
use the TASK_GLOBAL flag instead of relying on t->thread_mask being tid_bit,
as it could be so while still being in the global runqueue if another thread
woke that task for us.

This should be backported to 1.9.

6 years agoMEDIUM: connections: Use _HA_ATOMIC_*
Olivier Houchard [Wed, 13 Mar 2019 17:52:21 +0000 (18:52 +0100)] 
MEDIUM: connections: Use _HA_ATOMIC_*

Use _HA_ATOMIC_ instead of HA_ATOMIC_ because we know we don't need barriers

6 years agoMEDIUM: list: Use _HA_ATOMIC_*
Olivier Houchard [Wed, 13 Mar 2019 17:50:33 +0000 (18:50 +0100)] 
MEDIUM: list: Use _HA_ATOMIC_*

Use _HA_ATOMIC_ instead of HA_ATOMIC_ because we know we don't need barriers.

6 years agoMEDIUM: list: Remove useless barriers.
Olivier Houchard [Wed, 13 Mar 2019 16:13:04 +0000 (17:13 +0100)] 
MEDIUM: list: Remove useless barriers.

Don't bother forcing a barrier after using HA_ATOMIC_XCHG if we're about
to check the returned value anyway.

6 years agoBUG/MEDIUM: listener: make sure we don't pick stopped threads
Willy Tarreau [Wed, 13 Mar 2019 14:03:53 +0000 (15:03 +0100)] 
BUG/MEDIUM: listener: make sure we don't pick stopped threads

Dragan Dosen reported that after the multi-queue changes, appending
"process 1/even" on a bind line can make the process immediately crash
when delivering a first connection. This is due to the fact that I
believed that thread_mask(mask) applied the all_threads_mask value,
but it doesn't. And in case of even/odd the bits cover more than the
available threads, resulting in too high a thread number being selected
and a non-existing task to be woken up.

No backport is needed.

6 years agoBUG/MEDIUM: list: fix incorrect pointer unlocking in LIST_DEL_LOCKED()
Willy Tarreau [Wed, 13 Mar 2019 13:03:28 +0000 (14:03 +0100)] 
BUG/MEDIUM: list: fix incorrect pointer unlocking in LIST_DEL_LOCKED()

Injecting on a saturated listener started to exhibit some deadlocks
again between LIST_POP_LOCKED() and LIST_DEL_LOCKED(). Olivier found
it was due to a leftover from a previous debugging session. This patch
fixes it.

This will have to be backported if the other LIST_*_LOCKED() patches
are backported.

6 years agoMINOR: config: continue to rely on DEFAULT_MAXCONN to set the minimum maxconn
Willy Tarreau [Wed, 13 Mar 2019 09:10:49 +0000 (10:10 +0100)] 
MINOR: config: continue to rely on DEFAULT_MAXCONN to set the minimum maxconn

Some packages used to rely on DEFAULT_MAXCONN to set the default global
maxconn value to use regardless of the initial ulimit. The recent changes
made the lowest bound set to 100 so that it is compatible with almost any
environment. Now that DEFAULT_MAXCONN is not needed for anything else, we
can use it for the lowest bound set when maxconn is not configured. This
way it retains its original purpose of setting the default maxconn value
eventhough most of the time the effective value will be higher thanks to
the automatic computation based on "ulimit -n".

6 years agoMINOR: config: remove obsolete use of DEFAULT_MAXCONN at various places
Willy Tarreau [Wed, 13 Mar 2019 09:03:07 +0000 (10:03 +0100)] 
MINOR: config: remove obsolete use of DEFAULT_MAXCONN at various places

This entry was still set to 2000 but never used anymore. The only places
where it appeared was as an alias to SYSTEM_MAXCONN which forces it, so
let's turn these ones to SYSTEM_MAXCONN and remove the default value for
DEFAULT_MAXCONN. SYSTEM_MAXCONN still defines the upper bound however.

6 years agoMEDIUM: vars: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:55:38 +0000 (18:55 +0100)] 
MEDIUM: vars: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: time: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:55:31 +0000 (18:55 +0100)] 
MEDIUM: time: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: tcp_rules: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:55:10 +0000 (18:55 +0100)] 
MEDIUM: tcp_rules: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: stream: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:54:51 +0000 (18:54 +0100)] 
MEDIUM: stream: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: ssl: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:54:43 +0000 (18:54 +0100)] 
MEDIUM: ssl: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: sessions: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:54:34 +0000 (18:54 +0100)] 
MEDIUM: sessions: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: queues: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:54:16 +0000 (18:54 +0100)] 
MEDIUM: queues: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: proto_tcp: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:54:04 +0000 (18:54 +0100)] 
MEDIUM: proto_tcp: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: peers: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:53:43 +0000 (18:53 +0100)] 
MEDIUM: peers: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: memory: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:53:35 +0000 (18:53 +0100)] 
MEDIUM: memory: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: logs: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:53:21 +0000 (18:53 +0100)] 
MEDIUM: logs: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: listeners: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:52:57 +0000 (18:52 +0100)] 
MEDIUM: listeners: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: lb/threads: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:52:46 +0000 (18:52 +0100)] 
MEDIUM: lb/threads: Use the new _HA_ATOMIC_* macros.

    Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: http: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:52:00 +0000 (18:52 +0100)] 
MEDIUM: http: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: threads: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:51:17 +0000 (18:51 +0100)] 
MEDIUM: threads: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: spoe: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:50:42 +0000 (18:50 +0100)] 
MEDIUM: spoe: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: compression: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:50:27 +0000 (18:50 +0100)] 
MEDIUM: compression: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: pollers: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:49:54 +0000 (18:49 +0100)] 
MEDIUM: pollers: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: checks: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:49:32 +0000 (18:49 +0100)] 
MEDIUM: checks: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: cache: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:49:24 +0000 (18:49 +0100)] 
MEDIUM: cache: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: backend: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:49:07 +0000 (18:49 +0100)] 
MEDIUM: backend: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: activity: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:48:58 +0000 (18:48 +0100)] 
MEDIUM: activity: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: task: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:48:47 +0000 (18:48 +0100)] 
MEDIUM: task: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: server: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:48:31 +0000 (18:48 +0100)] 
MEDIUM: server: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: proxy: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:48:16 +0000 (18:48 +0100)] 
MEDIUM: proxy: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: freq_ctr: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:47:59 +0000 (18:47 +0100)] 
MEDIUM: freq_ctr: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: fd: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:47:42 +0000 (18:47 +0100)] 
MEDIUM: fd: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: xref: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:47:29 +0000 (18:47 +0100)] 
MEDIUM: xref: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.

6 years agoMEDIUM: applets: Use the new _HA_ATOMIC_* macros.
Olivier Houchard [Fri, 8 Mar 2019 17:46:48 +0000 (18:46 +0100)] 
MEDIUM: applets: Use the new _HA_ATOMIC_* macros.

Use the new _HA_ATOMIC_* macros and add barriers where needed.