]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
6 years agoMINOR: server: the mux_proto entry in the server is const
Willy Tarreau [Sun, 2 Dec 2018 12:08:34 +0000 (13:08 +0100)] 
MINOR: server: the mux_proto entry in the server is const

Same as previous commit. We'll have to update this one soon, let's
avoid any cast and mark it const as it really is.

6 years agoMINOR: connection: create conn_get_best_mux_entry()
Willy Tarreau [Sun, 2 Dec 2018 12:04:43 +0000 (13:04 +0100)] 
MINOR: connection: create conn_get_best_mux_entry()

We currently have conn_get_best_mux() to return the best mux for a
given protocol name, side and proxy mode. But we need the mux entry
as well in order to fix the bind_conf and servers at the end of the
config parsing. Let's split the function in two parts. It's worth
noting that the <conn> argument is never used anymore so this part
is eligible to some cleanup.

6 years agoMINOR: listener: the mux_proto entry in the bind_conf is const
Willy Tarreau [Sun, 2 Dec 2018 12:03:57 +0000 (13:03 +0100)] 
MINOR: listener: the mux_proto entry in the bind_conf is const

We'll have to update this one soon, let's avoid any cast and mark it
const as it really is.

6 years agoBUG/MEDIUM: mux-h2: remove the HTX EOM block on H2 response headers
Willy Tarreau [Sun, 2 Dec 2018 11:28:01 +0000 (12:28 +0100)] 
BUG/MEDIUM: mux-h2: remove the HTX EOM block on H2 response headers

If we decided to emit the end of stream flag on the H2 response headers
frame, we must remove the EOM block from the HTX stream, otherwise it
will lead to an extra DATA frame being sent with the ES flag and will
violate the protocol.

6 years agoBUG/MEDIUM: mux-h2: don't lose the first response header in HTX mode
Willy Tarreau [Sun, 2 Dec 2018 11:11:16 +0000 (12:11 +0100)] 
BUG/MEDIUM: mux-h2: don't lose the first response header in HTX mode

When converting response headers from HTX to H2, we accidently skipped
the first header block.

6 years agoBUG/MINOR: cfgparse: Fix the call to post parser of the last sections parsed
Christopher Faulet [Sun, 2 Dec 2018 08:37:38 +0000 (09:37 +0100)] 
BUG/MINOR: cfgparse: Fix the call to post parser of the last sections parsed

Wrong variable was used to know if we need to call the callback
post_section_parser() or not. We must use 'cs' and not 'pcs'.

This patch must be backported in 1.8 with the commit 7805e2b ("BUG/MINOR:
cfgparse: Fix transition between 2 sections with the same name").

6 years agoMEDIUM: mux-h2: support passing H2 DATA frames to HTX blocks
Willy Tarreau [Sat, 1 Dec 2018 22:23:04 +0000 (23:23 +0100)] 
MEDIUM: mux-h2: support passing H2 DATA frames to HTX blocks

This is used for uploads, we can now convert H2 DATA frames to HTX
DATA blocks. It's uncertain whether it's better to reuse the same
function or to split it in two at this point. For now the same
function was added with some paths specific to HTX. In this mode
we loop back to the same or next frame in order to try to complete
DATA blocks.

6 years agoMEDIUM: mux-h2: implement the emission of DATA frames from HTX DATA blocks
Willy Tarreau [Sat, 1 Dec 2018 18:25:56 +0000 (19:25 +0100)] 
MEDIUM: mux-h2: implement the emission of DATA frames from HTX DATA blocks

At the moment the way it's done is not optimal. We should aggregate multiple
blocks into a single DATA frame, and we should merge the ES flag with the
last one when we already know we've reached the end. For now and for an
easier tracking of the HTX stream, an individual empty DATA frame is sent
with the ES bit when EOM is met.

The DATA function is called for DATA, EOD and EOM since these stats indicate
that a previous frame was already produced without the ES flag (typically a
headers frame or another DATA frame). Thus it makes sense to handle all these
blocks there.

There's still an uncertainty on the way the EOD and EOM HTX blocks must be
accounted for, as they're counted as one byte in the HTX stream, but if we
count that byte off when parsing these blocks, we end up sending too much
and desynchronizing the HTX stream. Maybe it hides an issue somewhere else.

At least it's possible to reliably retrieve payloads up to 1 GB over H2/HTX
now. It's still unclear why larger ones are interrupted at 1 GB.

6 years agoMEDIUM: mux-h2: implement emission of H2 headers frames from HTX blocks
Willy Tarreau [Sat, 1 Dec 2018 18:17:53 +0000 (19:17 +0100)] 
MEDIUM: mux-h2: implement emission of H2 headers frames from HTX blocks

When using HTX, we need a separate function to emit a headers frame.
The code is significantly different from the H1 to H2 conversion, though
it borrows some parts there. It looks like the part building the H2 frame
from the headers list could be factored out, however some of the logic
around dealing with end of stream or block sizes remains different.

With this patch it becomes possible to retrieve bodyless HTTP responses
using H2 over HTX.

6 years agoMEDIUM: mux-h2: add basic H2->HTX transcoding support for headers
Willy Tarreau [Tue, 27 Nov 2018 08:29:36 +0000 (09:29 +0100)] 
MEDIUM: mux-h2: add basic H2->HTX transcoding support for headers

When the proxy is configured to use HTX mode, the headers frames
will be converted to HTX header blocks instead of HTTP/1 messages.
This requires very little modifications to the existing function
so it appeared better to do it this way than to duplicate it.

Only the request headers are handled, responses are not processed
yet and data frames are not processed yet either. The return value
is inaccurate but this is not an issue since we're using it as a
boolean : data received or not.

6 years agoMEDIUM: mux-h2: make h2_snd_buf() HTX-aware
Willy Tarreau [Sat, 1 Dec 2018 17:59:00 +0000 (18:59 +0100)] 
MEDIUM: mux-h2: make h2_snd_buf() HTX-aware

Now h2_snd_buf() will check the proxy's mode to decide whether to use
HTX-specific send functions or legacy functions. In HTX mode, the HTX
blocks of the output buffer will be parsed and the related functions
will be called accordingly based on the block type, and unimplemented
blocks will be skipped. For now all blocks are skipped, this is only
helpful for debugging.

6 years agoMEDIUM: mux-h2: make h2_rcv_buf() support HTX transfers
Willy Tarreau [Sat, 1 Dec 2018 22:19:43 +0000 (23:19 +0100)] 
MEDIUM: mux-h2: make h2_rcv_buf() support HTX transfers

The function needs to be slightly adapted to transfer HTX blocks, since
it may face a full buffer on the receive path, thus it needs to transfer
HTX blocks between the two sides ignoring the <count> argument in this
mode.

6 years agoMEDIUM: mux-h2: register mux for both HTTP and HTX modes
Willy Tarreau [Fri, 30 Nov 2018 15:49:47 +0000 (16:49 +0100)] 
MEDIUM: mux-h2: register mux for both HTTP and HTX modes

The H2 mux will now be called for both HTTP and HTX modes. For now the
data transferr functions are not HTX-aware so this will lead to problems
if used as-is but it's convenient for development and debugging.

6 years agoMINOR: h2: implement H2->HTX request header frame transcoding
Willy Tarreau [Tue, 27 Nov 2018 14:34:18 +0000 (15:34 +0100)] 
MINOR: h2: implement H2->HTX request header frame transcoding

Till now we could only produce an HTTP/1 request from a list of H2
request headers. Now the new function h2_make_htx_request() does the
same but using the HTX encoding instead, while respecting the H2
semantics. The code is not much different from the first version,
only the encoding differs.

For now it's not used.

6 years agoMEDIUM: compression: Adapt to be compatible with the HTX representation
Christopher Faulet [Fri, 30 Nov 2018 21:29:48 +0000 (22:29 +0100)] 
MEDIUM: compression: Adapt to be compatible with the HTX representation

Functions analyzing request and response headers have been duplicated and
adapted to support HTX messages. The callback http_payload have been implemented
to handle the data compression itself. It loops on HTX blocks and replace
uncompressed value of DATA block by compressed one. Unlike the HTTP legacy
version, there is no chunk at all. So HTX version is significantly easier.

6 years agoMINOR: flt_trace: Adapt to be compatible with the HTX representation
Christopher Faulet [Fri, 30 Nov 2018 21:23:32 +0000 (22:23 +0100)] 
MINOR: flt_trace: Adapt to be compatible with the HTX representation

The callback http_headers has been updated to dump HTX headers when the HTX
internal representation is in use. And the callback http_payload has been
implemented with its hexdump function.

6 years agoMEDIUM: proto_htx/filters: Add data filtering during the forwarding
Christopher Faulet [Fri, 30 Nov 2018 21:22:32 +0000 (22:22 +0100)] 
MEDIUM: proto_htx/filters: Add data filtering during the forwarding

If there is data filters registered on the stream, the function
flt_http_payload() is called before forwarding any data. And the function
flt_http_end() is called when all data are forwarded. While at least one data
filter reamins registered on the stream, no fast forwarding is used.

6 years agoMAJOR: filters: Adapt filters API to be compatible with the HTX represenation
Christopher Faulet [Fri, 30 Nov 2018 14:18:09 +0000 (15:18 +0100)] 
MAJOR: filters: Adapt filters API to be compatible with the HTX represenation

First, to be called on HTX streams, a filter must explicitly be declared as
compatible by setting the flag STRM_FLT_FL_HAS_FILTERS on the filter's config at
HAProxy startup. This flag is checked when a filter implementation is attached
to a stream.

Then, some changes have been made on HTTP callbacks. The callback http_payload
has been added to filter HTX data. It will be called on HTX streams only. It
replaces the callbacks http_data, http_chunk_trailers and http_forward_data,
called on legacy HTTP streams only and marked as deprecated. The documention
(once updated)) will give all information to implement this new callback. Other
HTTP callbacks will be called for HTX and HTTP legacy streams. So it is the
filter's responsibility to known which kind of data it handles. The macro
IS_HTX_STRM should be used in such cases.

There is at least a noticeable changes in the way data are forwarded. In HTX,
after the call to the callback http_headers, all the headers are considered as
forwarded. So, in http_payload, only the body and eventually the trailers will
be filtered.

6 years agoMINOR: mux-h1: Capture bad H1 messages
Christopher Faulet [Thu, 29 Nov 2018 22:01:45 +0000 (23:01 +0100)] 
MINOR: mux-h1: Capture bad H1 messages

First of all, an dedicated error snapshot, h1_snapshot, has been added. It
contains more or less the some info than http_snapshot but adapted for H1
messages. Then, the function h1_capture_bad_message() has been added to capture
bad H1 messages. And finally, the function h1_show_error_snapshot() is used to
dump these errors. Only Headers or data parsing are captured.

6 years agoMINOR: mux-h1: Change client conn_mode on an explicit close for the response
Christopher Faulet [Thu, 29 Nov 2018 08:55:22 +0000 (09:55 +0100)] 
MINOR: mux-h1: Change client conn_mode on an explicit close for the response

in h1_set_cli_conn_mode(), on the response path, If the response's connection
header is explicitly set to close and if the request is unfinished (state !=
DONE), then the client connection is marked as WANT_CLO.

6 years agoMINOR: mux-h1: Process conn_mode on the EOH when no connection header is found
Christopher Faulet [Wed, 28 Nov 2018 15:32:50 +0000 (16:32 +0100)] 
MINOR: mux-h1: Process conn_mode on the EOH when no connection header is found

Instead of looking for a connection header just after the start line to know if
we must process the conn_mode by hand or if we wait to parse the connection
header, we now delay this processing when the end of headers is reached. A flag
is used to know if it was already done (or skipped) or not. This save a lookup
on headers.

6 years agoMEDIUM: proto_htx: Convert all HTTP error messages into HTX
Christopher Faulet [Thu, 29 Nov 2018 15:48:49 +0000 (16:48 +0100)] 
MEDIUM: proto_htx: Convert all HTTP error messages into HTX

During startup, after the configuration parsing, all HTTP error messages
(errorloc, errorfile or default messages) are converted into HTX messages and
stored in dedicated buffers. We use it to return errors in the HTX analyzers
instead of using ugly OOB blocks.

6 years agoMINOR: proto_htx: Send valid HTX message to send 30x responses
Christopher Faulet [Wed, 28 Nov 2018 21:58:13 +0000 (22:58 +0100)] 
MINOR: proto_htx: Send valid HTX message to send 30x responses

The function htx_apply_redirect_rule() has been rewritten to send a valid
HTX message.

6 years agoMINOR: proto_htx: Send valid HTX message when redir mode is enabled on a server
Christopher Faulet [Wed, 28 Nov 2018 16:46:40 +0000 (17:46 +0100)] 
MINOR: proto_htx: Send valid HTX message when redir mode is enabled on a server

The function htx_perform_server_redirect() has been rewritten to send a valid
HTX message.

6 years agoMINOR: proto_htx: Use full HTX messages to send 401 and 407 responses
Christopher Faulet [Wed, 28 Nov 2018 14:59:42 +0000 (15:59 +0100)] 
MINOR: proto_htx: Use full HTX messages to send 401 and 407 responses

Instead of replying by adding an OOB block in the HTX structure, we now add a
valid HTX message. The old code relied on the function http_reply_and_close() to
send 401/407 responses. Now, we push it in the response's buffer. So we take
care to drain the request's channel and to shutdown the response's channel for
the read.

6 years agoMINOR: proto_htx: Use full HTX messages to send 103-Early-Hints responses
Christopher Faulet [Wed, 28 Nov 2018 12:55:14 +0000 (13:55 +0100)] 
MINOR: proto_htx: Use full HTX messages to send 103-Early-Hints responses

Instead of replying by adding an OOB block in the HTX structure, we now add a
valid HTX message. A header block is added to each early-hint rule, prefixed by
the start line if it is the first one. The response is terminated and forwarded
when the rules execution is stopped or when a rule of another type is applied.

6 years agoMINOR: proto_htx: Use full HTX messages to send 100-Continue responses
Christopher Faulet [Wed, 28 Nov 2018 09:01:23 +0000 (10:01 +0100)] 
MINOR: proto_htx: Use full HTX messages to send 100-Continue responses

Instead of replying by adding an OOB block in the HTX structure, we now add a
valid HTX message.

6 years agoMINOR: htx: Add BODYLESS flags on the HTX start-line and the HTTP message
Christopher Faulet [Tue, 27 Nov 2018 15:51:09 +0000 (16:51 +0100)] 
MINOR: htx: Add BODYLESS flags on the HTX start-line and the HTTP message

the flags HTX_SL_F_BODYLESS and HTTP_MSGF_BODYLESS have been added. These flags
are set when the corresponding HTTP message has no body at all.

6 years agoMINOR: proto-htx: Use the start-line flags to set the HTTP messsage ones
Christopher Faulet [Tue, 27 Nov 2018 10:21:21 +0000 (11:21 +0100)] 
MINOR: proto-htx: Use the start-line flags to set the HTTP messsage ones

the flags of the HTX start-line (HTX_SL_F_*) are mapped on ones of the HTTP
message (HTTP_MSGS_*). So we can easily retrieve info from the parsing in HTX
analyzers.

6 years agoMEDIUM: htx: Don't rely on h1_sl anymore except during H1 header parsing
Christopher Faulet [Mon, 26 Nov 2018 20:37:08 +0000 (21:37 +0100)] 
MEDIUM: htx: Don't rely on h1_sl anymore except during H1 header parsing

Instead, we now use the htx_sl coming from the HTX message. It avoids to have
too H1 specific code in version-agnostic parts. Of course, the concept of the
start-line is higly influenced by the H1, but the structure htx_sl can be
adapted, if necessary. And many things depend on a start-line during HTTP
analyzis. Using the structure htx_sl also avoid boring conversions between HTX
version and H1 version.

6 years agoMINOR: htx: Add the start-line offset for the HTX message in the HTX structure
Christopher Faulet [Mon, 26 Nov 2018 14:05:52 +0000 (15:05 +0100)] 
MINOR: htx: Add the start-line offset for the HTX message in the HTX structure

If there is no start-line, this offset is set to -1. Otherwise, it is the
relative address where the start-line is stored in the data block. When the
start-line is added, replaced or removed, this offset is updated accordingly. On
remove, if the start-line is no set and if the next block is a start-line, the
offset is updated. Finally, when an HTX structure is defragmented, the offset is
also updated accordingly.

6 years agoMEDIUM: htx: Change htx_sl to be a struct instead of an union
Christopher Faulet [Mon, 26 Nov 2018 10:13:57 +0000 (11:13 +0100)] 
MEDIUM: htx: Change htx_sl to be a struct instead of an union

The HTX start-line is now a struct. It will be easier to extend, if needed. Same
info can be found, of course. In addition it is now possible to set flags on
it. It will be used to set some infos about the message.

Some macros and functions have been added in proto/htx.h to help accessing
different parts of the start-line.

6 years agoMINOR: stats: Don't add end-of-data marker and trailers in the HTX response
Christopher Faulet [Wed, 21 Nov 2018 12:51:07 +0000 (13:51 +0100)] 
MINOR: stats: Don't add end-of-data marker and trailers in the HTX response

Because the mux H1 is able to handle these blocks by itself, it is easier to
ignore them in the stats applet.

6 years agoMINOR: htx: Add a function to find the HTX block corresponding to a data offset
Christopher Faulet [Thu, 22 Nov 2018 10:28:18 +0000 (11:28 +0100)] 
MINOR: htx: Add a function to find the HTX block corresponding to a data offset

The function htx_find_blk() returns the HTX block containing data with a given
offset, relatively to the beginning of the HTX message. It is a good way to skip
outgoing data and find the first HTX block not already processed.

6 years agoMINOR: htx: Add function to iterate on an HTX message using HTX blocks
Christopher Faulet [Thu, 22 Nov 2018 10:23:23 +0000 (11:23 +0100)] 
MINOR: htx: Add function to iterate on an HTX message using HTX blocks

the functions htx_get_next() and htx_get_prev() are used to iterate on an HTX
message using blocks position. With htx_get_next_blk() and htx_get_prev_blk(),
it is possible to do the same, but with HTX blocks. Of course, internally, we
rely on position's versions to do so. But it is handy for callers to not take
care of the blocks position.

6 years agoMINOR: htx: Add function to add an HTX block just before another one
Christopher Faulet [Thu, 22 Nov 2018 10:20:43 +0000 (11:20 +0100)] 
MINOR: htx: Add function to add an HTX block just before another one

The function htx_add_data_before() can be used to add an HTX block before
another one. For instance, it could be used to add some data before the
end-of-message marker.

6 years agoMEDIUM: mux-h1: Add keep-alive outgoing connections in connections list
Christopher Faulet [Fri, 23 Nov 2018 22:10:39 +0000 (23:10 +0100)] 
MEDIUM: mux-h1: Add keep-alive outgoing connections in connections list

With the legacy representation, keep-alive outgoing connections are added in
private/idle/safe connections list when the transaction is cleaned up. But this
stage does not exist with the HTX representaion because a new stream, and
therefore a new transaction, is created for each request. So it is now handled
when the stream is detached from the connection.

6 years agoMINOR: mux-h1: Consume channel's data in a loop in h1_snd_buf()
Christopher Faulet [Thu, 22 Nov 2018 09:58:42 +0000 (10:58 +0100)] 
MINOR: mux-h1: Consume channel's data in a loop in h1_snd_buf()

In h1_snd_buf(), the data sending is done synchronously, as much as possible. So
if some data remains in the channel's buffer, because there was not enougth
place in the output buffer, it may be good the retry after a send because some
space may have been released when sending. Most of time the output buffer is
empty and all channel's data are consumed the first time. And if no data are
sent, we don't retry to do more. So the loop is just here to optimize edge cases
without any cost for all others.

6 years agoMINOR: mux-h1: Subscribe to send in h1_snd_buf() when not all data have been sent
Christopher Faulet [Tue, 20 Nov 2018 17:38:01 +0000 (18:38 +0100)] 
MINOR: mux-h1: Subscribe to send in h1_snd_buf() when not all data have been sent

After a call to snd_buf, if some data remain in the channel's buffer, this means
the system buffers are full or we are unable to fully consume an HTX block for
any reason. In the last case, we need to wakeup the stream to process more data
as soon as possible. We do it subscribing to send at the end of h1_snd_buf().

6 years agoMINOR: mux-h1: Be prepare to fail when EOM is added during trailers parsing
Christopher Faulet [Thu, 22 Nov 2018 10:44:35 +0000 (11:44 +0100)] 
MINOR: mux-h1: Be prepare to fail when EOM is added during trailers parsing

When trailers are parsed, we must add the corrresponsing HTX block and then we
must add the block end-of-message. But this last operation can failed because
there is not enough space the HTX message. This case was left aside till
now. Now, we stay in the state H1_MSG_TRAILERS with the warranty we will be able
to restart at the right stage.

6 years agoMINOR: mux-h1: Write last chunk and trailers if not found in the HTX message
Christopher Faulet [Tue, 20 Nov 2018 17:21:43 +0000 (18:21 +0100)] 
MINOR: mux-h1: Write last chunk and trailers if not found in the HTX message

For chunked messages, during output process, the mux is now able to write the
last empty chunk and empty trailers when corrsponding blocks have not been found
in the HTX message. It is handy for filters changing a not-chunked message into
a chunked one (like the compression filter).

6 years agoMINOR: mux-h1: Don't rely on the stream anymore in h1_set_srv_conn_mode()
Christopher Faulet [Thu, 22 Nov 2018 09:19:50 +0000 (10:19 +0100)] 
MINOR: mux-h1: Don't rely on the stream anymore in h1_set_srv_conn_mode()

In h1_set_srv_conn_mode(), we need to get the frontend proxy of a server
connection. untill now, we relied on the stream to get it. But it was a bit
dirty. The stream always exists at this stage but to get it, we also need to get
the stream-interface. Since the commit 7c6f8b146 ("MAJOR: connections: Detach
connections from streams."), the connection's owner is always the session, even
for outgoing connections. So now, we rely on the session to get the frontend
proxy in h1_set_srv_conn_mode().

Use the session instead of the stream to get
the frontend on the server connection

6 years agoMINOR: proto_htx: Use conn_stream's info to set t_idle duration when possible
Christopher Faulet [Thu, 29 Nov 2018 14:23:46 +0000 (15:23 +0100)] 
MINOR: proto_htx: Use conn_stream's info to set t_idle duration when possible

On the client side, if si_get_cs_info() returns valid info, we use it to set
t_idle duration. Otherwise, we compute it using the stream's logs info.

6 years agoMINOR: stream: Rely on CS's info if it exists and fallback on session's ones
Christopher Faulet [Thu, 29 Nov 2018 14:19:05 +0000 (15:19 +0100)] 
MINOR: stream: Rely on CS's info if it exists and fallback on session's ones

When the stream is created, If si_get_cs_info() returns valid info for the client
connection stream, we use it. Otherwise we use session' info.

6 years agoMINOR: mux-h1: Implement get_cs_info() callback
Christopher Faulet [Thu, 29 Nov 2018 14:12:34 +0000 (15:12 +0100)] 
MINOR: mux-h1: Implement get_cs_info() callback

When the connection client is accepted, the info of the client conn_stream are
filled with the session info (accept_date, tv_accept and t_handshake). For all
other conn_streams, on client and server side, their info are filled using
global values (date and now).

6 years agoMEDIUM: conn_stream: Add a way to get mux's info on a CS from the upper layer
Christopher Faulet [Thu, 29 Nov 2018 10:29:26 +0000 (11:29 +0100)] 
MEDIUM: conn_stream: Add a way to get mux's info on a CS from the upper layer

Time to time, the need arises to get some info owned by the multiplexer about a
connection stream from the upper layer. Today we really need to get some dates
and durations specific to the conn_stream. It is only true for the mux H1 and
H2. Otherwise it will be impossible to have correct times reported in the logs.

To do so, the structure cs_info has been defined to provide all info we ever
need on a conn_stream from the upper layer. Of course, it is the first step. So
this structure will certainly envloved. But for now, only the bare minimum is
referenced. On the mux side, the callback get_cs_info() has been added in the
structure mux_ops. Multiplexers can now implement it, if necessary, to return a
pointer on a structure cs_info. And finally, the function si_get_cs_info()
should be used from the upper layer. If the stream interface is not attached to
a connection stream, this function returns NULL, likewise if the callback
get_cs_info() is not defined for the corresponding mux.

6 years agoMINOR: htx: add a function to cut the beginning of a DATA block
Willy Tarreau [Fri, 30 Nov 2018 13:29:31 +0000 (14:29 +0100)] 
MINOR: htx: add a function to cut the beginning of a DATA block

htx_cut_data_blk() is used to cut the beginning of a DATA block after a
part of it was tranferred. It simply advances the address, reduces the
advertised length and updates the htx's total data count.

6 years agoBUG/MINOR: connection: report mux modes when HTX is supported
Willy Tarreau [Fri, 30 Nov 2018 15:52:32 +0000 (16:52 +0100)] 
BUG/MINOR: connection: report mux modes when HTX is supported

It looks like we forgot to report HTX when listing the muxes and their
respective protocols, leading to "NONE" being displayed. Let's report
"HTX" and "HTTP|HTX" since both will exist. Also fix a minor typo in
the output message.

6 years agoBUG/MINOR: htx: Stop a header or a start line lookup on the first EOH or EOM
Christopher Faulet [Wed, 28 Nov 2018 15:55:12 +0000 (16:55 +0100)] 
BUG/MINOR: htx: Stop a header or a start line lookup on the first EOH or EOM

Because several messages can be stored in the HTX structure, it is important to
restrict searches to the current message.

6 years agoBUG/MINOR: proto_htx: Send outgoing data to client to start response processing
Christopher Faulet [Wed, 28 Nov 2018 15:44:44 +0000 (16:44 +0100)] 
BUG/MINOR: proto_htx: Send outgoing data to client to start response processing

In http_wait_for_response(), we wait that all outgoing data have really been
sent (from the channel's point of view) to start the processing of the
response. In fact, it is used to send all intermediate 10x responses. For now
the HTX api is not really handy when multiple messages are stored in the HTX
structure.

6 years agoBUG/MEDIUM: mux-h1: Reset the H1 parser when an outgoing message is processed
Christopher Faulet [Wed, 28 Nov 2018 15:06:57 +0000 (16:06 +0100)] 
BUG/MEDIUM: mux-h1: Reset the H1 parser when an outgoing message is processed

Because multiple HTTP messages can be stored in an HTX structure, it is
important to not forget to reset the H1 parser at the beginning of each
one. With the current version, this case only happens on the response, when
multiple HTTP-1XX responses are forwarded to the client (for instance
103-Early-Hints). So strickly speaking, it is the same message. But for now,
internally, each one is a standalone message. Note that it might change in a
future version of the HTX.

6 years agoBUG/MINOR: mux-h1: Fix processing of "Connection: " header on outgoing messages
Christopher Faulet [Tue, 27 Nov 2018 09:46:09 +0000 (10:46 +0100)] 
BUG/MINOR: mux-h1: Fix processing of "Connection: " header on outgoing messages

in h1_process_output(), before formatting the headers, we need to find and check
the "Connection: " header to update the connection mode. But, the context used
to do so was not correctly initialized. We must explicitly set ctx.value to NULL
to be sure to rescan the current header.

6 years agoBUG/MINOR: htx: Fix block size calculation when a start-line is added/replaced
Christopher Faulet [Mon, 26 Nov 2018 14:02:30 +0000 (15:02 +0100)] 
BUG/MINOR: htx: Fix block size calculation when a start-line is added/replaced

What we store in the buffer is a union htx_sl, not an h1_sl, so the
computed size was not correct.

6 years agoBUG/MINOR: http: Use out buffer instead of trash to display error snapshot
Christopher Faulet [Thu, 29 Nov 2018 21:53:30 +0000 (22:53 +0100)] 
BUG/MINOR: http: Use out buffer instead of trash to display error snapshot

the function http_show_error_snapshot() must not use the trash buffer to append
the HTTP error description. Instead, it must use the <out> buffer, its first
argument. Note that concretely, this function always succeeds because <out> is
always the trash buffer.

6 years agoBUG/MINOR: cfgparse: Fix transition between 2 sections with the same name
Christopher Faulet [Fri, 30 Nov 2018 12:50:47 +0000 (13:50 +0100)] 
BUG/MINOR: cfgparse: Fix transition between 2 sections with the same name

When a section's parser is registered, it can also define a post section
callback, called at the end of the section parsing. But when 2 sections with the
same name followed each other, the transition between them was missed. This
induced 2 bugs. First, the call to the post section callback was skipped. Then,
the parsing of the second section was mixed with the first one.

This patch must be backported in 1.8.

6 years agoBUG/MEDIUM: Special-case http_proxy when dealing with outgoing connections.
Olivier Houchard [Sat, 1 Dec 2018 16:03:38 +0000 (17:03 +0100)] 
BUG/MEDIUM: Special-case http_proxy when dealing with outgoing connections.

http_proxy is special, because it creates its connection and conn_stream
earlier. So in assign_server(), check that the connection associated with
the conn_stream has a destination address set, and in connect_server(),
use the connection and the conn_stream already attached to the
stream_interface, instead of looking for a connection in the session, and
creating a new conn_stream.

6 years agoMEDIUM: server: Be smarter about deciding to reuse the last server.
Olivier Houchard [Sat, 1 Dec 2018 13:40:40 +0000 (14:40 +0100)] 
MEDIUM: server: Be smarter about deciding to reuse the last server.

Instead of parsing all the available connections owned by the session
each time we choose a server, even if prefer-last-server is not set,
just do it if prefer-last-server is used, and check if the server is usable,
before checking the connections.

6 years agoMEDIUM: session: Steal owner-less connections on end of transaction.
Olivier Houchard [Fri, 30 Nov 2018 16:31:52 +0000 (17:31 +0100)] 
MEDIUM: session: Steal owner-less connections on end of transaction.

When a transaction ends, if we want to do keepalive, and the connection we
used didn't have an owner, attach the connection to the session, so that we
don't have to destroy it, and we can reuse it later.

6 years agoMAJOR: sessions: Store multiple outgoing connections in the session.
Olivier Houchard [Fri, 30 Nov 2018 16:24:55 +0000 (17:24 +0100)] 
MAJOR: sessions: Store multiple outgoing connections in the session.

Instead of just storing the last connection in the session, store all of
the connections, for at most MAX_SRV_LIST (currently 5) targets.
That way we can do keepalive on more than 1 outgoing connection when the
client uses HTTP/2.

6 years agoMEDIUM: h2: Destroy a connection with no stream if it has no owner.
Olivier Houchard [Fri, 30 Nov 2018 14:39:16 +0000 (15:39 +0100)] 
MEDIUM: h2: Destroy a connection with no stream if it has no owner.

In h2_detach(), if the connection has no stream left, and no associated
owner, then destroy it, as nobody else will be able to.

6 years agoMEDIUM: connections: Put H2 connections in the idle list if http-reuse always.
Olivier Houchard [Thu, 29 Nov 2018 16:08:53 +0000 (17:08 +0100)] 
MEDIUM: connections: Put H2 connections in the idle list if http-reuse always.

When creating a new outgoing H2 connection, put it in the idle list so that
it's immediately available for others to use, if http-reuse always is used.

6 years agoBUG/MEDIUM: mux_pt: Don't try to send if handshake is not done.
Olivier Houchard [Fri, 30 Nov 2018 12:17:48 +0000 (13:17 +0100)] 
BUG/MEDIUM: mux_pt: Don't try to send if handshake is not done.

While it is true the SSL code will do the right thing if the SSL handshake
is not done, we have other types of handshake to deal with (proxy protocol,
netscaler, ...). For those we definitively don't want to try to send data
before it's done. All handshakes but SSL will go through the mux_pt, so in
mux_pt_snd_buf, don't try to send while a handshake is pending.

6 years agoBUG/MEDIUM: session: properly clean the outgoing connection before freeing.
Olivier Houchard [Thu, 29 Nov 2018 17:05:05 +0000 (18:05 +0100)] 
BUG/MEDIUM: session: properly clean the outgoing connection before freeing.

In session_free(), make sure the outgoing connection is not in the idle list
anymore, and it does no longer have an owner, so that it will properly be
destroyed and nobody will be able to access it.

6 years agoBUG/MEDIUM: connections: Remove the connection from the idle list before destroy.
Olivier Houchard [Thu, 29 Nov 2018 17:04:12 +0000 (18:04 +0100)] 
BUG/MEDIUM: connections: Remove the connection from the idle list before destroy.

Before calling the destroy() method, remove the connection from the idle list,
so that no new session will pick it.

6 years agoBUG/MEDIUM: connections: Don't assume we have a mux in connect_server().
Olivier Houchard [Thu, 29 Nov 2018 17:03:21 +0000 (18:03 +0100)] 
BUG/MEDIUM: connections: Don't assume we have a mux in connect_server().

When dealing with the previous connection, don't assume it has a mux, as it
may not yet be the case if we're waiting for the ALPN.

6 years agoBUG/MEDIUM: streams: Don't assume we have a CS in sess_update_st_con_tcp.
Olivier Houchard [Thu, 29 Nov 2018 17:01:46 +0000 (18:01 +0100)] 
BUG/MEDIUM: streams: Don't assume we have a CS in sess_update_st_con_tcp.

We can reach sess_update_st_con_tcp() while we still have a connection
attached, so take that into account, and free the connection, instead of
assuming it's always a conn_stream.

6 years agoBUG/MEDIUM: session: Remove the session from the session_list in session_free.
Olivier Houchard [Thu, 29 Nov 2018 16:50:45 +0000 (17:50 +0100)] 
BUG/MEDIUM: session: Remove the session from the session_list in session_free.

When freeing the session, we may fail to free the outgoing connection,
because it still has streams attached. So remove ourself from the session
list, so that the connection doesn't try to access it later.

6 years agoREGTEST: lua: check socket functionality from a lua-task
PiBa-NL [Fri, 30 Nov 2018 20:01:01 +0000 (21:01 +0100)] 
REGTEST: lua: check socket functionality from a lua-task

Adding a new test /reg-tests/lua/b00004.vtc which checks if the core.tcp()
socket basic functions properly when used from a lua-task

6 years agoREGTEST: Fix several issues.
Frédéric Lécaille [Thu, 29 Nov 2018 20:41:42 +0000 (21:41 +0100)] 
REGTEST: Fix several issues.

Use #!bin/sh more portable shebang.
Support filenames with spaces.
Set HAPROXY_PROGRAM environment variable value to ${PWD}/haproxy.
exit(1) if we could not creat the higher level temporary working directory
or create its sub-directory with mktemp utility.
As defined by POSIX, use six characters for the mktemp template.

6 years agoBUG/MEDIUM: h2: Call h2_process() if there's an error on the connection.
Olivier Houchard [Thu, 29 Nov 2018 16:06:17 +0000 (17:06 +0100)] 
BUG/MEDIUM: h2: Call h2_process() if there's an error on the connection.

In h2_recv(), return 1 if there's an error on the connection, not just if
there's a read0 pending, so that h2_process() can be called and act as a
janitor.

6 years agoBUG/MEDIUM: stream_interface: Make sure we read all the data available.
Olivier Houchard [Thu, 29 Nov 2018 16:02:41 +0000 (17:02 +0100)] 
BUG/MEDIUM: stream_interface: Make sure we read all the data available.

In si_cs_recv(), when there's an error on the connection or the conn_stream,
don't give up if CS_FL_RCV_MORE is set on the conn_stream, as it means there's
still data available.

6 years agoBUG/MEDIUM: stream_interface: Don't check if the handshake is done.
Olivier Houchard [Thu, 29 Nov 2018 16:00:38 +0000 (17:00 +0100)] 
BUG/MEDIUM: stream_interface: Don't check if the handshake is done.

In si_cs_send(), don't give up and subscribe if the connection is still
waiting for a SSL handshake. We will never be woken up once the handshake is
done if we're using HTTP/2. Instead, directly try to send data. When using
the mux_pt, if the handshake is not done yet, snd_buf() would return 0 and
we will subscribe anyway.

6 years agoBUG/MEDIUM: connections: Don't forget to detach the connection from the SI.
Olivier Houchard [Thu, 29 Nov 2018 15:58:49 +0000 (16:58 +0100)] 
BUG/MEDIUM: connections: Don't forget to detach the connection from the SI.

When we're deferring the mux choice until the ALPN is negociated, we
attach the connection to the stream_interface until it's done, so that we
can destroy it if something goes wrong and the stream is destroy.
Before calling si_attach_cs() to attach the conn_stream once we have it,
call si_detach_endpoint(), or is_attach_cs() would destroy the connection.

6 years agoBUG/MEDIUM: connections: Wake the stream once the mux is chosen.
Olivier Houchard [Thu, 29 Nov 2018 15:57:32 +0000 (16:57 +0100)] 
BUG/MEDIUM: connections: Wake the stream once the mux is chosen.

When we defer the mux choice until the ALPN is negociated, don't forget
to wake the stream once it's done, or it will never have the opportunity
to send data.

6 years agoBUG/MINOR: ssl: ssl_sock_parse_clienthello ignores session id
Baptiste Assmann [Wed, 28 Nov 2018 14:20:25 +0000 (15:20 +0100)] 
BUG/MINOR: ssl: ssl_sock_parse_clienthello ignores session id

In ssl_sock_parse_clienthello(), the code considers that SSL Sessionid
size is '1', and then considers that the SSL cipher suite is availble
right after the session id size information.
This actually works in a single case, when the client does not send a
session id.

This patch fixes this issue by introducing the a propoer way to parse
the session id and move forward the cursor by the session id length when
required.

Need to be backported to 1.8.

6 years agoBUG/MEDIUM: mux_pt: Don't forget to unsubscribe() on attach.
Olivier Houchard [Thu, 29 Nov 2018 12:49:59 +0000 (13:49 +0100)] 
BUG/MEDIUM: mux_pt: Don't forget to unsubscribe() on attach.

In the mux_pt, when we're attaching a new conn_stream, don't forget to
unsubscribe from the connection. Failure to do so may lead to the mux_pt
freeing the connection while the conn_stream can still want to access it.

6 years agoREGTEST: Add a basic test for the cache.
Frédéric Lécaille [Wed, 28 Nov 2018 10:36:48 +0000 (11:36 +0100)] 
REGTEST: Add a basic test for the cache.

The client makes the same HTTP request four times.
The varnishtest HTTP server serves the first client request and quits.
So, the three last requests are handled by the haproxy cache.

6 years agoREGTEST/MINOR: script: add run-regtests.sh script
PiBa-NL [Tue, 27 Nov 2018 21:26:38 +0000 (22:26 +0100)] 
REGTEST/MINOR: script: add run-regtests.sh script

Some tests require a minimal haproxy version or compilation options to be
able to run successfully. This script allows to add 'requirements' to tests
to check so they will automatically be skipped if a requirement is not met.
The script supports several parameters to slightly modify its behavior
including the directories to search for tests.

Also some features are not available for certain OS's these can also
be 'excluded', this should allow for the complete set of test cases to be
run on any OS against any haproxy release without 'expected failures'.

The test .vtc files will need to be modified to include their 'requirements'
by listing including text options as shown below:
    #EXCLUDE_TARGETS=dos,freebsd,windows
    #REQUIRE_OPTIONS=ZLIB,OPENSSL,LUA
    #REQUIRE_VERSION=0.0
    #REQUIRE_VERSION_BELOW=99.9,
When excluding a OS by its TARGET, please do make a comment why the test
can not succeed on that TARGET.

6 years agoBUG/MEDIUM: h2: Don't bogusly error if the previous stream was closed.
Olivier Houchard [Wed, 28 Nov 2018 12:26:11 +0000 (13:26 +0100)] 
BUG/MEDIUM: h2: Don't bogusly error if the previous stream was closed.

In h2_process_demux(), if we're demuxing multiple frames, and the previous
frame led to a stream getting closed, don't bogusly consider that an error,
and destroy the next stream, as there are valid cases where the stream could
be closed.

6 years agoBUILD: Makefile: Disable -Wcast-function-type if it exists.
Olivier Houchard [Tue, 27 Nov 2018 13:47:58 +0000 (14:47 +0100)] 
BUILD: Makefile: Disable -Wcast-function-type if it exists.

Disable -Wcast-function-type for recent gcc, if we're casting a function
type to another one, it is assumed we know what we're doing.

6 years agoCLEANUP: http: Fix typo in init_http's comment
Tim Duesterhus [Sat, 15 Sep 2018 22:42:30 +0000 (00:42 +0200)] 
CLEANUP: http: Fix typo in init_http's comment

It read "non-zero" where it should read zero.

6 years agoBUG/MEDIUM: listeners: CLOEXEC flag is not correctly set
William Lallemand [Tue, 27 Nov 2018 11:02:39 +0000 (12:02 +0100)] 
BUG/MEDIUM: listeners: CLOEXEC flag is not correctly set

The CLOEXEC flag was set using a F_SETFL which can't work.
To set the CLOEXEC flag F_SETFD should be used, the problem is that it
needs a new call to fcntl() and it's on the path of every accept.

This flag was only needed in the case of the master, so the patch was
reverted and the flag set only in this case.

The bug was introduced by 0b3e849 ("MEDIUM: listeners: set O_CLOEXEC on
the accepted FDs").

No backport needed.

6 years agoREORG: mworker: declare master variable in global.h
William Lallemand [Tue, 27 Nov 2018 11:02:38 +0000 (12:02 +0100)] 
REORG: mworker: declare master variable in global.h

This variable is used at several places, better declare it in global.h.

6 years agoBUG/MEDIUM: mworker: avoid leak of client socket
William Lallemand [Tue, 27 Nov 2018 11:02:37 +0000 (12:02 +0100)] 
BUG/MEDIUM: mworker: avoid leak of client socket

If the master was reloaded and there was a established connection to a
server, the FD resulting from the accept was leaking.

There was no CLOEXEC flag set on the FD of the socketpair created during
a connect call. This is specific to the socketpair in the master process
but it should be applied to every protocol in case we use them in the
master at some point.

No backport needed.

6 years agoMINOR: h2: make struct h2_ops static
Willy Tarreau [Tue, 27 Nov 2018 06:30:17 +0000 (07:30 +0100)] 
MINOR: h2: make struct h2_ops static

There's no reason to export this descriptor, it used to be needed during
early H2 development and will complicate porting to HTX.

6 years agoBUG/MINOR: proto_htx: only mark connections private if NTLM is detected
Christopher Faulet [Fri, 23 Nov 2018 15:23:45 +0000 (16:23 +0100)] 
BUG/MINOR: proto_htx: only mark connections private if NTLM is detected

The commit fd9b68c48 ("BUG/MINOR: only mark connections private if NTLM is
detected") was forgotten when HTX analyzers were added.

6 years agoMINOR: ssl: free ctx when libssl doesn't support NPN
Lukas Tribus [Mon, 26 Nov 2018 21:57:17 +0000 (22:57 +0100)] 
MINOR: ssl: free ctx when libssl doesn't support NPN

The previous fix da95fd90 ("BUILD/MINOR: ssl: fix build with non-alpn/
non-npn libssl") does fix the build in old OpenSSL release, but I
overlooked that the ctx is only freed when NPN is supported.

Fix this by moving the #endif to the proper place (this was broken in
c7566001 ("MINOR: server: Add "alpn" and "npn" keywords")).

6 years agoMEDIUM: memory: make the pool cache an array and not a thread_local
Willy Tarreau [Mon, 26 Nov 2018 16:09:46 +0000 (17:09 +0100)] 
MEDIUM: memory: make the pool cache an array and not a thread_local

Having a thread_local for the pool cache is messy as we need to
initialize all elements upon startup, but we can't until the threads
are created, and once created it's too late. For this reason, the
allocation code used to check for the pool's initialization, and
it was the release code which used to detect the first call and to
initialize the cache on the fly, which is not exactly optimal.

Now that we have initcalls, let's turn this into a per-thread array.
This array is initialized very early in the boot process (STG_PREPARE)
so that pools are always safe to use. This allows to remove the tests
from the alloc/free calls.

Doing just this has removed 2.5 kB of code on all cumulated pool_alloc()
and pool_free() paths.

6 years agoMEDIUM: initcall: use initcalls for a few initialization functions
Willy Tarreau [Mon, 26 Nov 2018 15:31:20 +0000 (16:31 +0100)] 
MEDIUM: initcall: use initcalls for a few initialization functions

signal_init(), init_log(), init_stream(), and init_task() all used to
only preset some values and lists. This needs to be done very early to
provide a reliable interface to all other users. The calls used to be
explicit in haproxy.c:init(). Now they're placed in initcalls at the
STG_PREPARE stage. The functions are not exported anymore.

6 years agoMEDIUM: memory: use pool_destroy_all() to destroy all pools on deinit()
Willy Tarreau [Mon, 26 Nov 2018 14:57:34 +0000 (15:57 +0100)] 
MEDIUM: memory: use pool_destroy_all() to destroy all pools on deinit()

Instead of exporting a number of pools and having to manually delete
them in deinit() or to have dedicated destructors to remove them, let's
simply kill all pools on deinit().

For this a new function pool_destroy_all() was introduced. As its name
implies, it destroys and frees all pools (provided they don't have any
user anymore of course).

This allowed to remove 4 implicit destructors, 2 explicit ones, and 11
individual calls to pool_destroy(). In addition it properly removes
the mux_pt_ctx pool which was not cleared on exit (no backport needed
here since it's 1.9 only). The sig_handler pool doesn't need to be
exported anymore and became static now.

6 years agoMEDIUM: init: use initcall for all fixed size pool creations
Willy Tarreau [Mon, 26 Nov 2018 10:58:30 +0000 (11:58 +0100)] 
MEDIUM: init: use initcall for all fixed size pool creations

This commit replaces the explicit pool creation that are made in
constructors with a pool registration. Not only this simplifies the
pools declaration (it can be done on a single line after the head is
declared), but it also removes references to pools from within
constructors. The only remaining create_pool() calls are those
performed in init functions after the config is parsed, so there
is no more user of potentially uninitialized pool now.

It has been the opportunity to remove no less than 12 constructors
and 6 init functions.

6 years agoMINOR: memory: add a callback function to create a pool
Willy Tarreau [Mon, 26 Nov 2018 10:44:35 +0000 (11:44 +0100)] 
MINOR: memory: add a callback function to create a pool

The new function create_pool_callback() takes 3 args including the
return pointer, and creates a pool with the specified name and size.
In case of allocation error, it emits an error message and returns.

The new macro REGISTER_POOL() registers a callback using this function
and will be usable to request some pools creation and guarantee that
the allocation will be checked. An even simpler approach is to use
DECLARE_POOL() and DECLARE_STATIC_POOL() which declare and register
the pool.

6 years agoMINOR: initcall: use initcalls for section parsers
Willy Tarreau [Mon, 26 Nov 2018 10:33:13 +0000 (11:33 +0100)] 
MINOR: initcall: use initcalls for section parsers

The two calls to cfg_register_section() and cfg_register_postparser()
are now supported by initcalls. This allowed to remove two other
constructors.

6 years agoMINOR: initcall: use initcalls for most post_{check,deinit} and per_thread*
Willy Tarreau [Mon, 26 Nov 2018 10:21:50 +0000 (11:21 +0100)] 
MINOR: initcall: use initcalls for most post_{check,deinit} and per_thread*

Most calls to hap_register_post_check(), hap_register_post_deinit(),
hap_register_per_thread_init(), hap_register_per_thread_deinit() can
be done using initcalls and will not require a constructor anymore.
Let's create a set of simplified macros for this, called respectively
REGISTER_POST_CHECK, REGISTER_POST_DEINIT, REGISTER_PER_THREAD_INIT,
and REGISTER_PER_THREAD_DEINIT.

Some files were not modified because they wouldn't benefit from this
or because they conditionally register (e.g. the pollers).

6 years agoMINOR: initcall: apply initcall to all register_build_opts() calls
Willy Tarreau [Mon, 26 Nov 2018 09:19:54 +0000 (10:19 +0100)] 
MINOR: initcall: apply initcall to all register_build_opts() calls

Most register_build_opts() calls use static strings. These ones were
replaced with a trivial REGISTER_BUILD_OPTS() statement adding the string
and its call to the STG_REGISTER section. A dedicated section could be
made for this if needed, but there are very few such calls for this to
be worth it. The calls made with computed strings however, like those
which retrieve OpenSSL's version or zlib's version, were moved to a
dedicated function to guarantee they are called late in the process.
For example, the SSL call probably requires that SSL_library_init()
has been called first.

6 years agoMEDIUM: init: use self-initializing spinlocks and rwlocks
Willy Tarreau [Sun, 25 Nov 2018 19:12:18 +0000 (20:12 +0100)] 
MEDIUM: init: use self-initializing spinlocks and rwlocks

This patch replaces a number of __decl_hathread() followed by HA_SPIN_INIT
or HA_RWLOCK_INIT by the new __decl_spinlock() or __decl_rwlock() which
automatically registers the lock for initialization in during the STG_LOCK
init stage. A few static modifiers were lost in the process, but since they
were not essential at all it was not worth extending the API to provide such
a variant.

6 years agoMINOR: threads: add new macros to declare self-initializing locks
Willy Tarreau [Sun, 25 Nov 2018 18:46:08 +0000 (19:46 +0100)] 
MINOR: threads: add new macros to declare self-initializing locks

Using __decl_spinlock(), __decl_rwlock(), __decl_aligned_spinlock()
and __decl_aligned_rwlock(), one can now simply declare a spinlock
or an rwlock which will automatically be initialized at boot time
by calling the ha_spin_init() or ha_rwlock_init() callback. The
"aligned" variants enforce a 64-byte alignment on the lock.

6 years agoMINOR: thread: provide a set of lock initialisers
Willy Tarreau [Sun, 25 Nov 2018 18:28:23 +0000 (19:28 +0100)] 
MINOR: thread: provide a set of lock initialisers

This patch adds ha_spin_init() and ha_rwlock_init() which are used as
a callback to initialise locks at boot time. They perform exactly the
same as HA_SPIN_INIT() or HA_RWLOCK_INIT() but from within a real
function.

6 years agoMEDIUM: init: convert all trivial registration calls to initcalls
Willy Tarreau [Sun, 25 Nov 2018 18:14:37 +0000 (19:14 +0100)] 
MEDIUM: init: convert all trivial registration calls to initcalls

This switches explicit calls to various trivial registration methods for
keywords, muxes or protocols from constructors to INITCALL1 at stage
STG_REGISTER. All these calls have in common to consume a single pointer
and return void. Doing this removes 26 constructors. The following calls
were addressed :

- acl_register_keywords
- bind_register_keywords
- cfg_register_keywords
- cli_register_kw
- flt_register_keywords
- http_req_keywords_register
- http_res_keywords_register
- protocol_register
- register_mux_proto
- sample_register_convs
- sample_register_fetches
- srv_register_keywords
- tcp_req_conn_keywords_register
- tcp_req_cont_keywords_register
- tcp_req_sess_keywords_register
- tcp_res_cont_keywords_register
- flt_register_keywords

6 years agoMINOR: init: process all initcalls in order at boot time
Willy Tarreau [Sun, 25 Nov 2018 17:43:29 +0000 (18:43 +0100)] 
MINOR: init: process all initcalls in order at boot time

main() now iterates over all initcall stages at boot time. This will allow
to move init code from constructors to initcalls.