]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
7 years agoMAJOR: threads/map: Make acls/maps thread safe
Emeric Brun [Mon, 3 Jul 2017 09:34:05 +0000 (11:34 +0200)] 
MAJOR: threads/map: Make acls/maps thread safe

locks have been added in pat_ref and pattern_expr structures to protect all
accesses to an instance of on of them. Moreover, a global lock has been added to
protect the LRU cache used for pattern matching.

Patterns are now duplicated after a successfull matching, to avoid modification
by other threads when the result is used.

Finally, the function reloading a pattern list has been modified to be
thread-safe.

7 years agoMEDIUM: threads/queue: Make queues thread-safe
Christopher Faulet [Tue, 27 Jun 2017 13:43:53 +0000 (15:43 +0200)] 
MEDIUM: threads/queue: Make queues thread-safe

The list of pending connections are now protected using the proxy or server
lock, depending on the context.

7 years agoMAJOR: threads/ssl: Make SSL part thread-safe
Emeric Brun [Thu, 15 Jun 2017 14:37:39 +0000 (16:37 +0200)] 
MAJOR: threads/ssl: Make SSL part thread-safe

First, OpenSSL is now initialized to be thread-safe. This is done by setting 2
callbacks. The first one is ssl_locking_function. It handles the locks and
unlocks. The second one is ssl_id_function. It returns the current thread
id. During the init step, we create as much as R/W locks as needed, ie the
number returned by CRYPTO_num_locks function.

Next, The reusable SSL session in the server context is now thread-local.

Shctx is now also initialized if HAProxy is started with several threads.

And finally, a global lock has been added to protect the LRU cache used to store
generated certificates. The function ssl_sock_get_generated_cert is now
deprecated because the retrieved certificate can be removed by another threads
in same time. Instead, a new function has been added,
ssl_sock_assign_generated_cert. It must be used to search a certificate in the
cache and set it immediatly if found.

7 years agoMEDIUM: threads/stream: Make streams list thread safe
Emeric Brun [Fri, 30 Jun 2017 14:23:45 +0000 (16:23 +0200)] 
MEDIUM: threads/stream: Make streams list thread safe

Adds a global lock to protect the full streams list used to dump
sessions on stats socket.

7 years agoMAJOR: threads/buffer: Make buffer wait queue thread safe
Emeric Brun [Wed, 21 Jun 2017 13:42:52 +0000 (15:42 +0200)] 
MAJOR: threads/buffer: Make buffer wait queue thread safe

Adds a global lock to protect the buffer wait queue.

7 years agoMAJOR: threads/peers: Make peers thread safe
Emeric Brun [Mon, 19 Jun 2017 15:46:37 +0000 (17:46 +0200)] 
MAJOR: threads/peers: Make peers thread safe

A lock is used to protect accesses to a peer structure.

A the lock is taken in the applet handler when the peer is identified
and released living the applet handler.

In the scheduling task for peers section, the lock is taken for every
listed peer and released at the end of the process task function.

The peer 'force shutdown' function was also re-worked.

7 years agoMAJOR: threads/applet: Handle multithreading for applets
Emeric Brun [Mon, 19 Jun 2017 10:38:55 +0000 (12:38 +0200)] 
MAJOR: threads/applet: Handle multithreading for applets

A global lock has been added to protect accesses to the list of active
applets. A process mask has also been added on each applet. Like for FDs and
tasks, it is used to know which threads are allowed to process an
applet. Because applets are, most of time, linked to a session, it should be
sticky on the same thread. But in all cases, it is the responsibility of the
applet handler to lock what have to be protected in the applet context.

7 years agoMINOR: threads/regex: Change Regex trash buffer into a thread local variable
Emeric Brun [Thu, 15 Jun 2017 09:53:49 +0000 (11:53 +0200)] 
MINOR: threads/regex: Change Regex trash buffer into a thread local variable

7 years agoMEDIUM: threads/http: Make http_capture_bad_message thread-safe
Emeric Brun [Thu, 15 Jun 2017 09:30:06 +0000 (11:30 +0200)] 
MEDIUM: threads/http: Make http_capture_bad_message thread-safe

This is done by passing the right stream's proxy (the frontend or the backend,
depending on the context) to lock the error snapshot used to store the error
info.

7 years agoMINOR: threads/sample: Change temp_smp into a thread local variable
Emeric Brun [Wed, 14 Jun 2017 12:15:36 +0000 (14:15 +0200)] 
MINOR: threads/sample: Change temp_smp into a thread local variable

7 years agoMEDIUM: threads/stick-tables: handle multithreads on stick tables
Emeric Brun [Tue, 13 Jun 2017 17:37:32 +0000 (19:37 +0200)] 
MEDIUM: threads/stick-tables: handle multithreads on stick tables

The stick table API was slightly reworked:

A global spin lock on stick table was added to perform lookup and
insert in a thread safe way. The handling of refcount on entries
is now handled directly by stick tables functions under protection
of this lock and was removed from the code of callers.

The "stktable_store" function is no more externalized and users should
now use "stktable_set_entry" in any case of insertion. This last one performs
a lookup followed by a store if not found. So the code using "stktable_store"
was re-worked.

Lookup, and set_entry functions automatically increase the refcount
of the returned/stored entry.

The function "sticktable_touch" was renamed "sticktable_touch_local"
and is now able to decrease the refcount if last arg is set to true. It
is allowing to release the entry without taking the lock twice.

A new function "sticktable_touch_remote" is now used to insert
entries coming from remote peers at the right place in the update tree.
The code of peer update was re-worked to use this new function.
This function is also able to decrease the refcount if wanted.

The function "stksess_kill" also handle a parameter to decrease
the refcount on the entry.

A read/write lock is added on each entry to protect the data content
updates of the entry.

7 years agoMEDIUM: threads/lb: Make LB algorithms (lb_*.c) thread-safe
Christopher Faulet [Fri, 9 Jun 2017 12:17:53 +0000 (14:17 +0200)] 
MEDIUM: threads/lb: Make LB algorithms (lb_*.c) thread-safe

A lock for LB parameters has been added inside the proxy structure and atomic
operations have been used to update server variables releated to lb.

The only significant change is about lb_map. Because the servers status are
updated in the sync-point, we can call recalc_server_map function synchronously
in map_set_server_status_up/down function.

7 years agoMINOR: threads/server: Add a lock to deal with insert in updates_servers list
Christopher Faulet [Mon, 16 Oct 2017 10:00:40 +0000 (12:00 +0200)] 
MINOR: threads/server: Add a lock to deal with insert in updates_servers list

This list is used to save changes on the servers state. So when serveral threads
are used, it must be locked. The changes are then applied in the sync-point. To
do so, servers_update_status has be moved in the sync-point. So this is useless
to lock it at this step because the sync-point is a protected area by iteself.

7 years agoMEDIUM: threads/server: Add a lock per server and atomically update server vars
Christopher Faulet [Thu, 8 Jun 2017 12:04:45 +0000 (14:04 +0200)] 
MEDIUM: threads/server: Add a lock per server and atomically update server vars

The server's lock is use, among other things, to lock acces to the active
connection list of a server.

7 years agoMEDIUM: threads/server: Make connection list (priv/idle/safe) thread-safe
Christopher Faulet [Mon, 3 Jul 2017 13:41:01 +0000 (15:41 +0200)] 
MEDIUM: threads/server: Make connection list (priv/idle/safe) thread-safe

For now, we have a list of each type per thread. So there is no need to lock
them. This is the easiest solution for now, but not the best one because there
is no sharing between threads. An idle connection on a thread will not be able
be used by a stream on another thread. So it could be a good idea to rework this
patch later.

7 years agoMEDIUM: threads/proxy: Add a lock per proxy and atomically update proxy vars
Christopher Faulet [Fri, 2 Jun 2017 13:33:24 +0000 (15:33 +0200)] 
MEDIUM: threads/proxy: Add a lock per proxy and atomically update proxy vars

Now, each proxy contains a lock that must be used when necessary to protect
it. Moreover, all proxy's counters are now updated using atomic operations.

7 years agoMEDIUM: threads/listeners: Make listeners thread-safe
Christopher Faulet [Tue, 30 May 2017 13:36:50 +0000 (15:36 +0200)] 
MEDIUM: threads/listeners: Make listeners thread-safe

First, we use atomic operations to update jobs/totalconn/actconn variables,
listener's nbconn variable and listener's counters. Then we add a lock on
listeners to protect access to their information. And finally, listener queues
(global and per proxy) are also protected by a lock. Here, because access to
these queues are unusal, we use the same lock for all queues instead of a global
one for the global queue and a lock per proxy for others.

7 years agoMEDIUM: threads/signal: Add a lock to make signals thread-safe
Christopher Faulet [Tue, 30 May 2017 13:34:30 +0000 (15:34 +0200)] 
MEDIUM: threads/signal: Add a lock to make signals thread-safe

A global lock has been added to protect the signal processing. So when a signal
it triggered, only one thread will catch it.

7 years agoMAJOR: threads/task: handle multithread on task scheduler
Emeric Brun [Wed, 27 Sep 2017 12:59:38 +0000 (14:59 +0200)] 
MAJOR: threads/task: handle multithread on task scheduler

2 global locks have been added to protect, respectively, the run queue and the
wait queue. And a process mask has been added on each task. Like for FDs, this
mask is used to know which threads are allowed to process a task.

For many tasks, all threads are granted. And this must be your first intension
when you create a new task, else you have a good reason to make a task sticky on
some threads. This is then the responsibility to the process callback to lock
what have to be locked in the task context.

Nevertheless, all tasks linked to a session must be sticky on the thread
creating the session. It is important that I/O handlers processing session FDs
and these tasks run on the same thread to avoid conflicts.

7 years agoWIP: SQUASH WITH SYNC POINT
Christopher Faulet [Fri, 27 Oct 2017 21:01:38 +0000 (23:01 +0200)] 
WIP: SQUASH WITH SYNC POINT

7 years agoMINOR: threads/polling: pollers now handle FDs depending on the process mask
Christopher Faulet [Fri, 2 Jun 2017 12:36:39 +0000 (14:36 +0200)] 
MINOR: threads/polling: pollers now handle FDs depending on the process mask

7 years agoMINOR: threads/fd: Process cached events of FDs depending on the process mask
Christopher Faulet [Wed, 30 Aug 2017 08:56:25 +0000 (10:56 +0200)] 
MINOR: threads/fd: Process cached events of FDs depending on the process mask

7 years agoMEDIUM: threads/fd: Initialize the process mask during the call to fd_insert
Christopher Faulet [Tue, 30 May 2017 09:07:16 +0000 (11:07 +0200)] 
MEDIUM: threads/fd: Initialize the process mask during the call to fd_insert

Listeners will allow any threads to process the corresponding fd. But for other
FDs, we limit the processing to the current thread.

7 years agoMINOR: threads/fd: Add a mask of threads allowed to process on each fd in fdtab array
Christopher Faulet [Tue, 30 May 2017 09:05:09 +0000 (11:05 +0200)] 
MINOR: threads/fd: Add a mask of threads allowed to process on each fd in fdtab array

7 years agoMAJOR: threads/fd: Make fd stuffs thread-safe
Christopher Faulet [Mon, 29 May 2017 08:40:41 +0000 (10:40 +0200)] 
MAJOR: threads/fd: Make fd stuffs thread-safe

Many changes have been made to do so. First, the fd_updt array, where all
pending FDs for polling are stored, is now a thread-local array. Then 3 locks
have been added to protect, respectively, the fdtab array, the fd_cache array
and poll information. In addition, a lock for each entry in the fdtab array has
been added to protect all accesses to a specific FD or its information.

For pollers, according to the poller, the way to manage the concurrency is
different. There is a poller loop on each thread. So the set of monitored FDs
may need to be protected. epoll and kqueue are thread-safe per-se, so there few
things to do to protect these pollers. This is not possible with select and
poll, so there is no sharing between the threads. The poller on each thread is
independant from others.

Finally, per-thread init/deinit functions are used for each pollers and for FD
part for manage thread-local ressources.

Now, you must be carefull when a FD is created during the HAProxy startup. All
update on the FD state must be made in the threads context and never before
their creation. This is mandatory because fd_updt array is thread-local and
initialized only for threads. Because there is no pollers for the main one, this
array remains uninitialized in this context. For this reason, listeners are now
enabled in run_thread_poll_loop function, just like the worker pipe.

7 years agoMEDIUM: threads/pool: Make pool thread-safe by locking all access to a pool
Christopher Faulet [Tue, 29 Aug 2017 07:52:38 +0000 (09:52 +0200)] 
MEDIUM: threads/pool: Make pool thread-safe by locking all access to a pool

A lock has been added for each memory pool. It is used to protect the pool
during allocations and releases. It is also used when pool info are dumped.

7 years agoMEDIUM: threads/logs: Make logs thread-safe
Christopher Faulet [Fri, 2 Jun 2017 14:20:16 +0000 (16:20 +0200)] 
MEDIUM: threads/logs: Make logs thread-safe

log buffers and static variables used in log functions are now thread-local. So
there is no need to lock anything to log messages. Moreover, per-thread
init/deinit functions are now used to initialize these buffers.

7 years agoMEDIUM: threads/time: Many global variables from time.h are now thread-local
Christopher Faulet [Thu, 11 May 2017 09:00:15 +0000 (11:00 +0200)] 
MEDIUM: threads/time: Many global variables from time.h are now thread-local

7 years agoMEDIUM: threads/chunks: Transform trash chunks in thread-local variables
Christopher Faulet [Fri, 21 Apr 2017 14:47:03 +0000 (16:47 +0200)] 
MEDIUM: threads/chunks: Transform trash chunks in thread-local variables

So, per-thread init/deinit functions are registered to allocate/release them.

7 years agoMEDIUM: threads/buffers: Define and register per-thread init/deinit functions
Christopher Faulet [Tue, 29 Aug 2017 12:43:04 +0000 (14:43 +0200)] 
MEDIUM: threads/buffers: Define and register per-thread init/deinit functions

For now, only the swap_buffer is handled in these functions. Moreover,
swap_buffer has been changed to be a thread-local variable.

7 years agoMINOR: threads: Define the sync-point inside run_poll_loop
Christopher Faulet [Thu, 19 Oct 2017 09:59:44 +0000 (11:59 +0200)] 
MINOR: threads: Define the sync-point inside run_poll_loop

The function sync_poll_loop is called at the end of each loop inside
run_poll_loop function. It is a protected area where all threads have a chance
to execute tricky tasks with the warranty that no concurrent access is
possible. Of course, it comes with a cost because all threads must be
syncrhonized. So changes must be uncommon.

7 years agoMAJOR: threads: Start threads to experiment multithreading
Christopher Faulet [Tue, 29 Aug 2017 13:38:48 +0000 (15:38 +0200)] 
MAJOR: threads: Start threads to experiment multithreading

[WARNING] For now, HAProxy is not thread-safe, so from this commit, it will be
          broken for a while, when compiled with threads.

When nbthread parameter is greater than 1, HAProxy will create the corresponding
number of threads. If nbthread is set to 1, nothing should be done. So if there
are concurrency issues (and be sure there will be, unfortunatly), an obvious
workaround is to disable the multithreading...

Each created threads will run a polling loop. So, in a certain way, it is pretty
similar to the nbproc mode ("outside" the bugs and the lock
contention). Nevertheless, there are an init and a deinit steps for each thread
to deal with per-thread allocation.

Each thread has a tid (thread-id), numbered from 0 to (nbtread-1). It is used in
many place to do bitwise operations or to improve debugging information.

7 years agoMEDIUM: threads: Adds a set of functions to handle sync-point
Christopher Faulet [Thu, 19 Oct 2017 09:59:15 +0000 (11:59 +0200)] 
MEDIUM: threads: Adds a set of functions to handle sync-point

A sync-point is a protected area where you have the warranty that no concurrency
access is possible. It is implementated as a thread barrier to enter in the
sync-point and another one to exit from it. Inside the sync-point, all threads
that must do some syncrhonous processing will be called one after the other
while all other threads will wait. All threads will then exit from the
sync-point at the same time.

A sync-point will be evaluated only when necessary because it is a costly
operation. To limit the waiting time of each threads, we must have a mechanism
to wakeup all threads. This is done with a pipe shared by all threads. By
writting in this pipe, we will interrupt all threads blocked on a poller. The
pipe is then flushed before exiting from the sync-point.

7 years agoMINOR: threads: Add nbthread parameter
Christopher Faulet [Tue, 29 Aug 2017 13:37:10 +0000 (15:37 +0200)] 
MINOR: threads: Add nbthread parameter

It is only parsed and initialized for now. It will be used later. This parameter
is only available when support for threads was built in.

7 years agoMINOR: threads: Add mechanism to register per-thread init/deinit functions
Christopher Faulet [Tue, 25 Jul 2017 14:52:58 +0000 (16:52 +0200)] 
MINOR: threads: Add mechanism to register per-thread init/deinit functions

hap_register_per_thread_init and hap_register_per_thread_deinit functions has
been added to register functions to do, for each thread, respectively, some
initialization and deinitialization. These functions are added in the global
lists per_thread_init_list and per_thread_deinit_list.

These functions are called only when HAProxy is started with more than 1 thread
(global.nbthread > 1).

7 years agoMEDIUM: threads: Add hathreads header file
Christopher Faulet [Thu, 12 Oct 2017 14:09:09 +0000 (16:09 +0200)] 
MEDIUM: threads: Add hathreads header file

This file contains all functions and macros used to deal with concurrency in
HAProxy. It contains all high-level function to do atomic operation
(HA_ATOMIC_*). Note, for now, we rely on "__atomic" GCC builtins to do atomic
operation. So HAProxy can be compiled with the thread support iff these builtins
are available.

It also contains wrappers around plocks to use spin or read/write locks. These
wrappers are used to abstract the internal representation of the locking system
and to add information to help debugging, when compiled with suitable
options.

To add extra info on locks, you need to add DEBUG=-DDEBUG_THREAD or
DEBUG=-DDEBUG_FULL compilation option. In addition to timing info on locks, we
keep info on where a lock was acquired the last time (function name, file and
line). There are also the thread id and a flag to know if it is still locked or
not. This will be useful to debug deadlocks.

7 years agoMINOR: threads: Add atomic-ops and plock includes in import dir
Emeric Brun [Fri, 7 Jul 2017 08:26:46 +0000 (10:26 +0200)] 
MINOR: threads: Add atomic-ops and plock includes in import dir

atomic-ops header contains some low-level functions to do atomic
operations. These operations are used by the progressive locks (plock).

7 years agoMINOR: threads: Add THREAD_LOCAL macro
Christopher Faulet [Tue, 29 Aug 2017 07:51:52 +0000 (09:51 +0200)] 
MINOR: threads: Add THREAD_LOCAL macro

When compiled with threads support, this marco is set to __thread. Else it is
empty.

7 years agoMINOR: threads: Prepare makefile to link with pthread
Emeric Brun [Mon, 26 Jun 2017 16:41:42 +0000 (18:41 +0200)] 
MINOR: threads: Prepare makefile to link with pthread

USE_THREAD option has been added to enable the compilation with the experimental
support of threads . Of course for now, there is nothing. And for a while,
HAProxy will be unstable. When we will be confident enough, this option will be
removed.

For this implementation and probably for a while, only the pthread library will
be supported.

7 years agoMINOR: startup: Extend the scope the MODE_STARTING flag
Christopher Faulet [Tue, 24 Oct 2017 11:53:54 +0000 (13:53 +0200)] 
MINOR: startup: Extend the scope the MODE_STARTING flag

Now, MODE_STARTING is set at the begining to init function and it is removed
just before the polling loop. So more alerts or warnings are saved.

7 years agoMINOR: cli: Add "show startup-logs" command
Christopher Faulet [Tue, 24 Oct 2017 10:00:51 +0000 (12:00 +0200)] 
MINOR: cli: Add "show startup-logs" command

This command will dump all startup_logs buffer containing all alerts and
warnings emitted during HAProxy startup.

7 years agoMINOR: log: Save alerts and warnings emitted during HAProxy startup
Christopher Faulet [Tue, 24 Oct 2017 09:44:05 +0000 (11:44 +0200)] 
MINOR: log: Save alerts and warnings emitted during HAProxy startup

Because we can't always display the standard error messages when HAProxy is
started, all alerts and warnings emitted during the startup will now be saved in
a buffer. It can also be handy to store these messages just in case you
missed something during the startup

To implement this feature, Alert and Warning functions now relies on
display_message. The difference is just on conditions to call this function and
it remains unchanged. In display_message, if MODE_STARTING flag is set, we save
the message.

7 years agoMINOR: standard: Add memvprintf function
Christopher Faulet [Tue, 24 Oct 2017 09:25:33 +0000 (11:25 +0200)] 
MINOR: standard: Add memvprintf function

Now memprintf relies on memvprintf. This new function does exactly what
memprintf did before, but it must be called with a va_list instead of a variable
number of arguments. So there is no change for every functions using
memprintf. But it is now also possible to have same functionnality from any
function with variadic arguments.

7 years agoMINOR: mailers: Use pools to allocate email alerts and its tcpcheck_rules
Christopher Faulet [Mon, 23 Oct 2017 13:45:20 +0000 (15:45 +0200)] 
MINOR: mailers: Use pools to allocate email alerts and its tcpcheck_rules

7 years agoMEDIUM: mailers: Init alerts during conf parsing and refactor their processing
Christopher Faulet [Fri, 20 Oct 2017 19:34:32 +0000 (21:34 +0200)] 
MEDIUM: mailers: Init alerts during conf parsing and refactor their processing

Email alerts relies on checks to send emails. The link between a mailers section
and a proxy was resolved during the configuration parsing, But initialization was
done when the first alert is triggered. This implied memory allocations and
tasks creations. With this patch, everything is now initialized during the
configuration parsing. So when an alert is triggered, only the memory required
by this alert is dynamically allocated.

Moreover, alerts processing had a flaw. The task handler used to process alerts
to be sent to the same mailer, process_email_alert, was designed to give back
the control to the scheduler when an alert was sent. So there was a delay
between the sending of 2 consecutives alerts (the min of
"proxy->timeout.connect" and "mailer->timeout.mail"). To fix this problem, now,
we try to process as much queued alerts as possible when the task is woken up.

7 years agoBUG/MINOR: mailers: Fix a memory leak when email alerts are released
Christopher Faulet [Mon, 23 Oct 2017 13:38:19 +0000 (15:38 +0200)] 
BUG/MINOR: mailers: Fix a memory leak when email alerts are released

An email alert contains a list of tcpcheck_rule. Each one is dynamically
allocated, just like its internal members. So, when an email alerts is freed, we
must be sure to properly free each tcpcheck_rule too.

This patch must be backported in 1.7 and 1.6.

7 years agoMAJOR: dns: Refactor the DNS code
Christopher Faulet [Wed, 27 Sep 2017 09:00:59 +0000 (11:00 +0200)] 
MAJOR: dns: Refactor the DNS code

This is a huge patch with many changes, all about the DNS. Initially, the idea
was to update the DNS part to ease the threads support integration. But quickly,
I started to refactor some parts. And after several iterations, it was
impossible for me to commit the different parts atomically. So, instead of
adding tens of patches, often reworking the same parts, it was easier to merge
all my changes in a uniq patch. Here are all changes made on the DNS.

First, the DNS initialization has been refactored. The DNS configuration parsing
remains untouched, in cfgparse.c. But all checks have been moved in a post-check
callback. In the function dns_finalize_config, for each resolvers, the
nameservers configuration is tested and the task used to manage DNS resolutions
is created. The links between the backend's servers and the resolvers are also
created at this step. Here no connection are kept alive. So there is no needs
anymore to reopen them after HAProxy fork. Connections used to send DNS queries
will be opened on demand.

Then, the way DNS requesters are linked to a DNS resolution has been
reworked. The resolution used by a requester is now referenced into the
dns_requester structure and the resolution pointers in server and dns_srvrq
structures have been removed. wait and curr list of requesters, for a DNS
resolution, have been replaced by a uniq list. And Finally, the way a requester
is removed from a DNS resolution has been simplified. Now everything is done in
dns_unlink_resolution.

srv_set_fqdn function has been simplified. Now, there is only 1 way to set the
server's FQDN, independently it is done by the CLI or when a SRV record is
resolved.

The static DNS resolutions pool has been replaced by a dynamoc pool. The part
has been modified by Baptiste Assmann.

The way the DNS resolutions are triggered by the task or by a health-check has
been totally refactored. Now, all timeouts are respected. Especially
hold.valid. The default frequency to wake up a resolvers is now configurable
using "timeout resolve" parameter.

Now, as documented, as long as invalid repsonses are received, we really wait
all name servers responses before retrying.

As far as possible, resources allocated during DNS configuration parsing are
releases when HAProxy is shutdown.

Beside all these changes, the code has been cleaned to ease code review and the
doc has been updated.

7 years agoBUG/MINOR: dns: Fix CLI keyword declaration
Christopher Faulet [Tue, 3 Oct 2017 14:00:57 +0000 (16:00 +0200)] 
BUG/MINOR: dns: Fix CLI keyword declaration

The cli command to show resolvers stats is in conflict with the command to show
proxies and servers stats. When you use the command "show stat resolvers [id]",
instead of printing stats about resolvers, you get the stats about all proxies
and servers.

Now, to avoid conflict, to print resolvers stats, you must use the following
command:

     show resolvers [id]

This patch must be backported in 1.7.

7 years agoMEDIUM: spoe/rules: Process "send-spoe-group" action
Christopher Faulet [Fri, 22 Sep 2017 08:20:13 +0000 (10:20 +0200)] 
MEDIUM: spoe/rules: Process "send-spoe-group" action

The messages processing is done using existing functions. So here, the main task
is to find the SPOE engine to use. To do so, we loop on all filter instances
attached to the stream. For each, we check if it is a SPOE filter and, if yes,
if its name is the one used to declare the "send-spoe-group" action.

We also take care to return an error if the action processing is interrupted by
HAProxy (because of a timeout or an error at the HAProxy level). This is done by
checking if the flag ACT_FLAG_FINAL is set.

The function spoe_send_group is the action_ptr callback ot

7 years agoMINOR: spoe: Add a generic function to encode a list of SPOE message
Christopher Faulet [Thu, 21 Sep 2017 14:57:24 +0000 (16:57 +0200)] 
MINOR: spoe: Add a generic function to encode a list of SPOE message

So it will be possible to encode messages chained by event or by group. For now,
it is only possible to do it by event.

7 years agoMINOR: spoe: Add a type to qualify the message list during encoding
Christopher Faulet [Thu, 21 Sep 2017 14:50:56 +0000 (16:50 +0200)] 
MINOR: spoe: Add a type to qualify the message list during encoding

Because we can have messages chained by event or by group, we need to have a way
to know which kind of list we manipulate during the encoding. So 2 types of list
has been added, SPOE_MSGS_BY_EVENT and SPOE_MSGS_BY_GROUP. And the right type is
passed when spoe_encode_messages is called.

7 years agoMINOR: spoe: Move message encoding in its own function
Christopher Faulet [Thu, 21 Sep 2017 14:38:22 +0000 (16:38 +0200)] 
MINOR: spoe: Move message encoding in its own function

Instead of having a big function to encode a list of messages, now we have a
function to unroll the list and a function to encode the message itself.

7 years agoMEDIUM: spoe/rules: Add "send-spoe-group" action for tcp/http rules
Christopher Faulet [Thu, 21 Sep 2017 09:03:52 +0000 (11:03 +0200)] 
MEDIUM: spoe/rules: Add "send-spoe-group" action for tcp/http rules

This action is used to trigger sending of a group of SPOE messages. To do so,
the SPOE engine used to send messages must be defined, as well as the SPOE group
to send. Of course, the SPOE engine must refer to an existing SPOE filter. If
not engine name is provided on the SPOE filter line, the SPOE agent name must be
used. For example:

   http-request send-spoe-group my-engine some-group

This action is available for "tcp-request content", "tcp-response content",
"http-request" and "http-response" rulesets. It cannot be used for tcp
connection/session rulesets because actions for these rulesets cannot yield.

For now, the action keyword is parsed and checked. But it does nothing. Its
processing will be added in another patch.

7 years agoMEDIUM: spoe: Parse new "spoe-group" section in SPOE config file
Christopher Faulet [Thu, 21 Sep 2017 08:23:10 +0000 (10:23 +0200)] 
MEDIUM: spoe: Parse new "spoe-group" section in SPOE config file

For now, this section is only parsed. It should have the following format:

    spoe-group <grp-name>
      messages <msg-name> ...

And then SPOE groups must be referenced in spoe-agent section:

    spoe-agnt <name>
        ...
groups <grp-name> ...

The purpose of these groups is to trigger messages sending from TCP or HTTP
rules, directly from HAProxy configuration, and not on specific event. This part
will be added in another patch.

It is important to note that a message belongs at most to a group.

7 years agoMINOR: spoe: Check uniqness of SPOE engine names during config parsing
Christopher Faulet [Tue, 19 Sep 2017 09:08:28 +0000 (11:08 +0200)] 
MINOR: spoe: Check uniqness of SPOE engine names during config parsing

The engine name is now kept in "spoe_config" struture. Because a SPOE filter can
be declared without engine name, we use the SPOE agent name by default. Then,
its uniqness is checked against all others SPOE engines configured for the same
proxy.

  * TODO: Add documentation

7 years agoMEDIUM: spoe: Add support of ACLS to enable or disable sending of SPOE messages
Christopher Faulet [Mon, 4 Sep 2017 13:41:09 +0000 (15:41 +0200)] 
MEDIUM: spoe: Add support of ACLS to enable or disable sending of SPOE messages

Now, it is possible to conditionnaly send a SPOE message by adding an ACL-based
condition on the "event" line, in a "spoe-message" section. Here is the example
coming for the SPOE documentation:

    spoe-message get-ip-reputation
        args ip=src
        event on-client-session if ! { src -f /etc/haproxy/whitelist.lst }

To avoid mixin with proxy's ACLs, each SPOE message has its private ACL list. It
possible to declare named ACLs in "spoe-message" section, using the same syntax
than for proxies. So we can rewrite the previous example to use a named ACL:

    spoe-message get-ip-reputation
        args ip=src
acl ip-whitelisted src -f /etc/haproxy/whitelist.lst
        event on-client-session if ! ip-whitelisted

ACL-based conditions are executed in the context of the stream that handle the
client and the server connections.

7 years agoMINOR: acl: Pass the ACLs as an explicit parameter of build_acl_cond
Christopher Faulet [Fri, 22 Sep 2017 12:38:56 +0000 (14:38 +0200)] 
MINOR: acl: Pass the ACLs as an explicit parameter of build_acl_cond

So it is possible to use anothers ACLs to build ACL conditions than those of
proxies.

7 years agoMINOR: action: Factorize checks on rules calling check_ptr if defined
Christopher Faulet [Mon, 18 Sep 2017 12:51:41 +0000 (14:51 +0200)] 
MINOR: action: Factorize checks on rules calling check_ptr if defined

7 years agoMINOR: action: Add a functions to check http capture rules
Christopher Faulet [Mon, 18 Sep 2017 13:26:32 +0000 (15:26 +0200)] 
MINOR: action: Add a functions to check http capture rules

"check_http_req_capture" and "check_http_res_capture" functions have been added
to check validity of "http-request capture" and "http-response capture"
rules. Code for these functions come from cfgparse.c.

7 years agoMINOR: action: Add function to check rules using an action ACT_ACTION_TRK_*
Christopher Faulet [Mon, 18 Sep 2017 12:43:55 +0000 (14:43 +0200)] 
MINOR: action: Add function to check rules using an action ACT_ACTION_TRK_*

The function "check_trk_action" has been added to find and check the target
table for rules using an action ACT_ACTION_TRK_*.

7 years agoMINOR: action: Add a function pointer in act_rule struct to check its validity
Christopher Faulet [Mon, 18 Sep 2017 13:12:39 +0000 (15:12 +0200)] 
MINOR: action: Add a function pointer in act_rule struct to check its validity

It is possible to define the field "act_rule.check_ptr" if you want to check the
validity of a tcp/http rule.

7 years agoMINOR: action: Use trk_idx instead of tcp/http_trk_idx
Christopher Faulet [Mon, 18 Sep 2017 09:57:31 +0000 (11:57 +0200)] 
MINOR: action: Use trk_idx instead of tcp/http_trk_idx

So tcp_trk_idx and http_trk_idx have been removed.

7 years agoMINOR: action: Add trk_idx inline function
Christopher Faulet [Mon, 18 Sep 2017 09:54:51 +0000 (11:54 +0200)] 
MINOR: action: Add trk_idx inline function

It returns tracking index corresponding to an action ACT_ACTION_TRK_SC*. It will
replace http_trk_idx and tcp_trk_idx.

7 years agoBUG/MINOR: spoa: Update pointer on the end of the frame when a reply is encoded
Christopher Faulet [Tue, 26 Sep 2017 09:49:23 +0000 (11:49 +0200)] 
BUG/MINOR: spoa: Update pointer on the end of the frame when a reply is encoded

The same buffer is used for a request and its response. So we need to be sure
to correctly reset info when the response is encoded. And here there was a
bug. The pointer on the end of the frame was not updated.  So it was not
possible to encode a response bigger than the corresponding request.

7 years agoBUG/MINOR: spoe: Don't compare engine name and SPOE scope when both are NULL
Christopher Faulet [Tue, 19 Sep 2017 08:35:35 +0000 (10:35 +0200)] 
BUG/MINOR: spoe: Don't compare engine name and SPOE scope when both are NULL

SPOE filter can be declared without engine name. This is an optional
parameter. But in this case, no scope must be used in the SPOE configuration
file. So engine name and scope are both undefined, and, obviously, we must not
try to compare them.

This patch must be backported in 1.7.

7 years agoMINOR: h1: store the status code in the H1 message
Willy Tarreau [Tue, 31 Oct 2017 07:02:24 +0000 (08:02 +0100)] 
MINOR: h1: store the status code in the H1 message

It was painful not to have the status code available, especially when
it was computed. Let's store it and ensure we don't claim content-length
anymore on 1xx, only 0 body bytes.

7 years agoMINOR: shctx: rename lock functions
William Lallemand [Mon, 30 Oct 2017 22:44:40 +0000 (23:44 +0100)] 
MINOR: shctx: rename lock functions

Rename lock functions to shctx_lock() and shctx_unlock() to be coherent
with the new API.

7 years agoMEDIUM: shctx: separate ssl and shctx
William Lallemand [Mon, 30 Oct 2017 19:08:51 +0000 (20:08 +0100)] 
MEDIUM: shctx: separate ssl and shctx

This patch reorganize the shctx API in a generic storage API, separating
the shared SSL session handling from its core.

The shctx API only handles the generic data part, it does not know what
kind of data you use with it.

A shared_context is a storage structure allocated in a shared memory,
allowing its usage in a multithread or a multiprocess context.

The structure use 2 linked list, one containing the available blocks,
and another for the hot locked blocks. At initialization the available
list is filled with <maxblocks> blocks of size <blocksize>. An <extra>
space is initialized outside the list in case you need some specific
storage.

+-----------------------+--------+--------+--------+--------+----
| struct shared_context | extra  | block1 | block2 | block3 | ...
+-----------------------+--------+--------+--------+--------+----
                                 <--------  maxblocks  --------->
                                            * blocksize

The API allows to store content on several linked blocks. For example,
if you allocated blocks of 16 bytes, and you want to store an object of
60 bytes, the object will be allocated in a row of 4 blocks.

The API was made for LRU usage, each time you get an object, it pushes
the object at the end of the list. When it needs more space, it discards

The functions name have been renamed in a more logical way, the part
regarding shctx have been prefixed by shctx_ and the functions for the
shared ssl session cache have been prefixed by sh_ssl_sess_.

7 years agoREORG: shctx: move ssl functions to ssl_sock.c
William Lallemand [Mon, 30 Oct 2017 18:36:36 +0000 (19:36 +0100)] 
REORG: shctx: move ssl functions to ssl_sock.c

Move the ssl callback functions of the ssl shared session cache to
ssl_sock.c. The shctx functions still needs to be separated of the ssl
tree and data.

7 years agoMEDIUM: shctx: allow the use of multiple shctx
William Lallemand [Mon, 9 Oct 2017 14:30:50 +0000 (16:30 +0200)] 
MEDIUM: shctx: allow the use of multiple shctx

Add an shctx argument which permits to create new independent shctx
area.

7 years agoREORG: shctx: move lock functions and struct
William Lallemand [Mon, 9 Oct 2017 12:17:39 +0000 (14:17 +0200)] 
REORG: shctx: move lock functions and struct

Move locks functions to proto/shctx.h, and structures to types/shctx.h
in order to simplify the split ssl/shctx.

7 years agoMEDIUM: lists: list_for_each_entry{_safe}_from functions
William Lallemand [Sun, 24 Sep 2017 09:26:02 +0000 (11:26 +0200)] 
MEDIUM: lists: list_for_each_entry{_safe}_from functions

Add list_for_each_entry_from and list_for_each_entry_safe_from which
allows to iterate in a list starting from a specific item.

7 years agoCLEANUP: shctx: get ride of the shsess_packet{_hdr} structures
William Lallemand [Mon, 18 Sep 2017 15:37:07 +0000 (17:37 +0200)] 
CLEANUP: shctx: get ride of the shsess_packet{_hdr} structures

This patch removes remaining structures and fields which were never used
in the shctx code.

7 years agoMEDIUM: h1: ensure that 1xx, 204 and 304 don't have a payload body
Willy Tarreau [Mon, 30 Oct 2017 18:31:59 +0000 (19:31 +0100)] 
MEDIUM: h1: ensure that 1xx, 204 and 304 don't have a payload body

It's important for the H2 to H1 gateway that the response parser properly
clears the H1 message's body_len when seeing these status codes so that we
don't hang waiting to transfer data that will not come.

7 years agoMINOR: add ALPN information to send-proxy-v2
Emmanuel Hocdet [Tue, 24 Oct 2017 08:55:14 +0000 (10:55 +0200)] 
MINOR: add ALPN information to send-proxy-v2

Send ALPN information in proxy-protocol-v2 if an alpn have been
negotiated.

7 years agoMINOR: merge ssl_sock_get calls for log and ppv2
Emmanuel Hocdet [Fri, 13 Oct 2017 14:59:49 +0000 (16:59 +0200)] 
MINOR: merge ssl_sock_get calls for log and ppv2

Merge ssl_sock_get_version and ssl_sock_get_proto_version.
Change ssl_sock_get_cipher to be used in ppv2.

7 years agoMINOR: update proxy-protocol-v2 #define
Emmanuel Hocdet [Fri, 13 Oct 2017 10:15:28 +0000 (12:15 +0200)] 
MINOR: update proxy-protocol-v2 #define

Report #define from doc/proxy-protocol.txt.

7 years agoMINOR: ssl: Don't abuse ssl_options.
Olivier Houchard [Fri, 27 Oct 2017 12:58:08 +0000 (14:58 +0200)] 
MINOR: ssl: Don't abuse ssl_options.

A bind_conf does contain a ssl_bind_conf, which already has a flag to know
if early data are activated, so use that, instead of adding a new flag in
the ssl_options field.

7 years agoBUG/MINOR: lua: const attribute of a string is overridden
Thierry FOURNIER [Fri, 27 Oct 2017 12:13:51 +0000 (14:13 +0200)] 
BUG/MINOR: lua: const attribute of a string is overridden

If HAProxy is compiled without PCRE regexes, this can cause
a write in const memory. The probability of a consequence is
very low.

7 years agoMINOR: ssl/proto_http: Add keywords to take care of early data.
Olivier Houchard [Mon, 2 Oct 2017 09:51:03 +0000 (11:51 +0200)] 
MINOR: ssl/proto_http: Add keywords to take care of early data.

Add a new sample fetch, "ssl_fc_has_early", a boolean that will be true
if early data were sent, and a new action, "wait-for-handshake", if used,
the request won't be forwarded until the SSL handshake is done.

7 years agoBUILD: Makefile: disable -Wunused-label
Willy Tarreau [Fri, 27 Oct 2017 09:06:11 +0000 (11:06 +0200)] 
BUILD: Makefile: disable -Wunused-label

It's becoming extremely tricky not to make gcc warn about unused labels
with support for openssl 1.1 and 1.1.1, because some error paths only exist
for certain versions. Latest patch causes a warning for me on 1.0.2. There
is no real point it warning about an unused error label so let's disable
this warning.

7 years agoMEDIUM: ssl: Handle early data with OpenSSL 1.1.1
Olivier Houchard [Fri, 22 Sep 2017 16:26:28 +0000 (18:26 +0200)] 
MEDIUM: ssl: Handle early data with OpenSSL 1.1.1

When compiled with Openssl >= 1.1.1, before attempting to do the handshake,
try to read any early data. If any early data is present, then we'll create
the session, read the data, and handle the request before we're doing the
handshake.

For this, we add a new connection flag, CO_FL_EARLY_SSL_HS, which is not
part of the CO_FL_HANDSHAKE set, allowing to proceed with a session even
before an SSL handshake is completed.

As early data do have security implication, we let the origin server know
the request comes from early data by adding the "Early-Data" header, as
specified in this draft from the HTTP working group :

    https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-replay

7 years agoMINOR: ssl: generated certificate is missing in switchctx early callback
Emmanuel Hocdet [Mon, 14 Aug 2017 09:01:25 +0000 (11:01 +0200)] 
MINOR: ssl: generated certificate is missing in switchctx early callback

Openssl 1.1.1 supports switchctx early callback and generated certificate.
Generated certificate calls must be available in switchctx early callback.

7 years agoMINOR: ssl: support Openssl 1.1.1 early callback for switchctx
Emmanuel Hocdet [Wed, 16 Aug 2017 09:33:17 +0000 (11:33 +0200)] 
MINOR: ssl: support Openssl 1.1.1 early callback for switchctx

Use Openssl-1.1.1 SSL_CTX_set_client_hello_cb to mimic BoringSSL early callback.
Native multi certificate and SSL/TLS method per certificate is now supported by
Openssl >= 1.1.1.

7 years agoMEDIUM: ssl: convert CBS (BoringSSL api) usage to neutral code
Emmanuel Hocdet [Wed, 16 Aug 2017 09:28:44 +0000 (11:28 +0200)] 
MEDIUM: ssl: convert CBS (BoringSSL api) usage to neutral code

switchctx early callback is only supported for BoringSSL. To prepare
the support of openssl 1.1.1 early callback, convert CBS api to neutral
code to work with any ssl libs.

7 years agoMINOR: http: Mark the 425 code as "Too Early".
Olivier Houchard [Mon, 2 Oct 2017 14:12:07 +0000 (16:12 +0200)] 
MINOR: http: Mark the 425 code as "Too Early".

This adds a new status code for use with the "http-request deny" ruleset.
The use case for this code is currently handled by this draft dedicated
to 0-RTT processing :

   https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-replay

7 years agoMINOR: hlua: Add regex class
Thierry FOURNIER [Wed, 25 Oct 2017 10:59:51 +0000 (12:59 +0200)] 
MINOR: hlua: Add regex class

This patch simply brings HAProxy internal regex system to the Lua API.
Lua doesn't embed regexes, now it inherits from the regexes compiled
with haproxy.

7 years agoMINOR: lua: add uuid to the Class Proxy
Baptiste Assmann [Thu, 26 Oct 2017 19:51:58 +0000 (21:51 +0200)] 
MINOR: lua: add uuid to the Class Proxy

the proxy UUID parameter is not set in the Lua Proxy Class.
This patches adds it.

7 years agoMEDIUM: cfgparse: post parsing registration
William Lallemand [Mon, 23 Oct 2017 12:36:34 +0000 (14:36 +0200)] 
MEDIUM: cfgparse: post parsing registration

Allow to register a function which will be called after the
configuration file parsing, at the end of the check_config_validity().

It's useful fo checking dependencies between sections or for resolving
keywords, pointers or values.

7 years agoMEDIUM: cfgparse: post section callback
William Lallemand [Mon, 16 Oct 2017 09:06:50 +0000 (11:06 +0200)] 
MEDIUM: cfgparse: post section callback

This commit implements a post section callback. This callback will be
used at the end of a section parsing.

Every call to cfg_register_section must be modified to use the new
prototype:

    int cfg_register_section(char *section_name,
                             int (*section_parser)(const char *, int, char **, int),
                             int (*post_section_parser)());

7 years agoBUG/MEDIUM: prevent buffers being overwritten during build_logline() execution
Dragan Dosen [Thu, 26 Oct 2017 09:25:10 +0000 (11:25 +0200)] 
BUG/MEDIUM: prevent buffers being overwritten during build_logline() execution

Calls to build_logline() are audited in order to use dynamic trash buffers
allocated by alloc_trash_chunk() instead of global trash buffers.

This is similar to commits 07a0fec ("BUG/MEDIUM: http: Prevent
replace-header from overwriting a buffer") and 0d94576 ("BUG/MEDIUM: http:
prevent redirect from overwriting a buffer").

This patch should be backported in 1.7, 1.6 and 1.5. It relies on commit
b686afd ("MINOR: chunks: implement a simple dynamic allocator for trash
buffers") for the trash allocator, which has to be backported as well.

7 years agoMINOR: buffer: add the buffer input manipulation functions
Willy Tarreau [Thu, 26 Oct 2017 13:26:17 +0000 (15:26 +0200)] 
MINOR: buffer: add the buffer input manipulation functions

We used to have bo_{get,put}_{chr,blk,str} to retrieve/send data to
the output area of a buffer, but not the equivalent ones for the input
area. This will be needed to copy uploaded data frames in HTTP/2.

7 years agoBUG/MINOR: checks: Don't forget to release the connection on error case.
Olivier Houchard [Tue, 24 Oct 2017 17:03:30 +0000 (19:03 +0200)] 
BUG/MINOR: checks: Don't forget to release the connection on error case.

When switching the check code to a non-permanent connection, the new code
forgot to free the connection if an error happened and was returned by
connect_conn_chk(), leading to the check never be ran again.

7 years agoMINOR: ssl_sock: make use of CO_FL_WILL_UPDATE
Willy Tarreau [Wed, 25 Oct 2017 07:32:15 +0000 (09:32 +0200)] 
MINOR: ssl_sock: make use of CO_FL_WILL_UPDATE

Now when ssl_sock_{to,from}_buf are called, if the connection doesn't
feature CO_FL_WILL_UPDATE, they will first retrieve the updated flags
using conn_refresh_polling_flags() before changing any flag, then call
conn_cond_update_sock_polling() before leaving, to commit such changes.

7 years agoMINOR: raw_sock: make use of CO_FL_WILL_UPDATE
Willy Tarreau [Wed, 25 Oct 2017 07:30:13 +0000 (09:30 +0200)] 
MINOR: raw_sock: make use of CO_FL_WILL_UPDATE

Now when raw_sock_{to,from}_{pipe,buf} are called, if the connection
doesn't feature CO_FL_WILL_UPDATE, they will first retrieve the updated
flags using conn_refresh_polling_flags() before changing any flag, then
call conn_cond_update_sock_polling() before leaving, to commit such
changes. Note that the only real call to one of the __conn_* functions
is in fact in conn_sock_read0() which is called from here.

7 years agoMEDIUM: connection: make use of CO_FL_WILL_UPDATE in conn_sock_shutw()
Willy Tarreau [Wed, 25 Oct 2017 07:59:22 +0000 (09:59 +0200)] 
MEDIUM: connection: make use of CO_FL_WILL_UPDATE in conn_sock_shutw()

This one may be called by upper layers (eg: si_shutw()) or lower layers
(si_shutw() as well during stream_int_notify()) so we want it to take
care of updating the connection's flags if it's not going to be done
by the caller.

7 years agoMINOR: connection: add flag CO_FL_WILL_UPDATE to indicate when updates are granted
Willy Tarreau [Wed, 25 Oct 2017 07:22:43 +0000 (09:22 +0200)] 
MINOR: connection: add flag CO_FL_WILL_UPDATE to indicate when updates are granted

In transport-layer functions (snd_buf/rcv_buf), it's very problematic
never to know if polling changes made to the connection will be propagated
or not. This has led to some conn_cond_update_polling() calls being placed
at a few places to cover both the cases where the function is called from
the upper layer and when it's called from the lower layer. With the arrival
of the MUX, this becomes even more complicated, as the upper layer will not
have to manipulate anything from the connection layer directly and will not
have to push such updates directly either. But the snd_buf functions will
need to see their updates committed when called from upper layers.

The solution here is to introduce a connection flag set by the connection
handler (and possibly any other similar place) indicating that the caller
is committed to applying such changes on return. This way, the called
functions will be able to apply such changes by themselves before leaving
when the flag is not set, and the upper layer will not have to care about
that anymore.

7 years agoMINOR: connection: move the cleanup of flag CO_FL_WAIT_ROOM
Willy Tarreau [Wed, 25 Oct 2017 08:28:45 +0000 (10:28 +0200)] 
MINOR: connection: move the cleanup of flag CO_FL_WAIT_ROOM

This flag is only used when reading using splicing for now, and is only
set when a pipe full condition is met, so we can simplify its reset
condition in conn_refresh_polling_flags so that it's cleared at the
same time as the other ones, only when the control layer is ready.

This flag could be used more, to mark that a buffer full condition was
met with any receive method in order to simplify polling management.
This should probably be revisited after 1.8.

7 years agoMINOR: ssl: don't abort after sending 16kB
Willy Tarreau [Wed, 25 Oct 2017 13:34:39 +0000 (15:34 +0200)] 
MINOR: ssl: don't abort after sending 16kB

SSL records are 16kB max. When trying to send larger data chunks at once,
SSL_read() only processes 16kB and ssl_sock_from_buf() believes it means
the system buffers are full, which is not the case, contrary to raw_sock.
This is particularly noticeable with HTTP/2 when using a 64kB buffer with
multiple streams, as the mux buffer can start to fill up pretty quickly
in this situation, slowing down the data delivery.

7 years agoMINOR: stream-int: stop checking for useless connection flags in chk_snd_conn
Willy Tarreau [Wed, 25 Oct 2017 12:22:28 +0000 (14:22 +0200)] 
MINOR: stream-int: stop checking for useless connection flags in chk_snd_conn

We've been keep this test for a connection being established since 1.5-dev14
when the stream-interface was still accessing the FD directly. The test on
CO_FL_HANDSHAKE and L{4,6}_CONN is totally useless here, and can even be
counter-productive on pure TCP where it could prevent a request from being
sent on a connection still attempting to complete its establishment. And it
creates an abnormal dependency between the layers that will complicate the
implementation of the mux, so let's get rid of it now.