]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
7 years agoBUG/MEDIUM: log: check result details truncated.
Emeric Brun [Thu, 19 Oct 2017 12:42:30 +0000 (14:42 +0200)] 
BUG/MEDIUM: log: check result details truncated.

Fix regression introduced by commit:
'MAJOR: servers: propagate server status changes asynchronously.'

The building of the log line was re-worked to be done at the
postponed point without lack of data.

[wt: this only affects 1.8-dev, no backport needed]

7 years agoMINOR: ist: add ist0() to add a trailing zero to a string.
Willy Tarreau [Thu, 19 Oct 2017 04:28:23 +0000 (06:28 +0200)] 
MINOR: ist: add ist0() to add a trailing zero to a string.

This function modifies the string to add a zero after the end, and returns
the start pointer. The purpose is to use it on strings extracted by parsers
from larger strings cut with delimiters that are not important and can be
destroyed. It allows any such string to be used with regular string
functions. It's also convenient to use with printf() to show data extracted
from writable areas.

7 years agoMINOR: channel: make the channel be a const in all {ci,co}_get* functions
Willy Tarreau [Thu, 19 Oct 2017 12:58:40 +0000 (14:58 +0200)] 
MINOR: channel: make the channel be a const in all {ci,co}_get* functions

There's no point having the channel marked writable as these functions
only extract data from the channel. The code was retrieved from their
ci/co ancestors.

7 years agoMINOR: channel: make use of bo_getblk{,_nc} for their channel equivalents
Willy Tarreau [Thu, 19 Oct 2017 12:57:54 +0000 (14:57 +0200)] 
MINOR: channel: make use of bo_getblk{,_nc} for their channel equivalents

Let's reuse the buffer-level functions to perform the operations.

7 years agoMINOR: buffer: add bo_getblk() and bo_getblk_nc()
Willy Tarreau [Thu, 19 Oct 2017 12:56:49 +0000 (14:56 +0200)] 
MINOR: buffer: add bo_getblk() and bo_getblk_nc()

These functions respectively extract a block from an output buffer by
copying it or by just passing pointers and lengths for zero copy operation.

7 years agoREORG: channel: finally rename the last bi_* / bo_* functions
Willy Tarreau [Thu, 19 Oct 2017 12:32:15 +0000 (14:32 +0200)] 
REORG: channel: finally rename the last bi_* / bo_* functions

For HTTP/2 we'll need some buffer-only equivalent functions to some of
the ones applying to channels and still squatting the bi_* / bo_*
namespace. Since these names have kept being misleading for quite some
time now and are really getting annoying, it's time to rename them. This
commit will use "ci/co" as the prefix (for "channel in", "channel out")
instead of "bi/bo". The following ones were renamed :

  bi_getblk_nc, bi_getline_nc, bi_putblk, bi_putchr,
  bo_getblk, bo_getblk_nc, bo_getline, bo_getline_nc, bo_inject,
  bi_putchk, bi_putstr, bo_getchr, bo_skip, bi_swpbuf

7 years agoMINOR: buffer: add buffer_space_wraps()
Willy Tarreau [Mon, 16 Oct 2017 12:01:18 +0000 (14:01 +0200)] 
MINOR: buffer: add buffer_space_wraps()

This function returns true if the available buffer space wraps. This
will be used to detect if it's worth realigning a buffer when it lacks
contigous space.

7 years agoMINOR: buffer: add two functions to inject data into buffers
Willy Tarreau [Fri, 22 Sep 2017 13:47:51 +0000 (15:47 +0200)] 
MINOR: buffer: add two functions to inject data into buffers

bi_istput() injects the ist string into the input region of the buffer,
it will be used to feed small data chunks into the conn_stream. bo_istput()
does the same into the output region of the buffer, it will be used to send
data via the transport layer and assumes there's no input data.

7 years agoMINOR: buffer: add a function to match against string patterns
Willy Tarreau [Fri, 22 Sep 2017 13:02:54 +0000 (15:02 +0200)] 
MINOR: buffer: add a function to match against string patterns

In order to match known patterns in wrapping buffer, we'll introduce new
string manipulation functions for buffers. The new function b_isteq()
relies on an ist string for the pattern and compares it against any
location in the buffer relative to <p>. The second function bi_eat()
is specially designed to match input contents.

7 years agoMINOR: buffer: add bo_del() to delete a number of characters from output
Willy Tarreau [Wed, 18 Oct 2017 06:32:12 +0000 (08:32 +0200)] 
MINOR: buffer: add bo_del() to delete a number of characters from output

This simply reduces the amount of output data from the buffer after
they have been transferred, in a way that is more natural than by
fiddling with buf->o. b_del() was renamed to bi_del() to avoid any
ambiguity (it's not yet used).

7 years agoBUG/MAJOR: lua: scheduled task is freezing.
Emeric Brun [Tue, 17 Oct 2017 16:58:40 +0000 (18:58 +0200)] 
BUG/MAJOR: lua: scheduled task is freezing.

Since commit 'MAJOR: task: task scheduler rework'
0194897e540cec67d7d1e9281648b70efe403f08. LUA's
scheduling tasks are freezing.

A running task should not handle the scheduling itself
but let the task scheduler to handle it based on the
'expire' field.

[wt: no backport needed]

7 years agoBUG/MINOR: stats: Clear a bit more counters with in cli_parse_clear_counters().
Olivier Houchard [Tue, 17 Oct 2017 17:23:25 +0000 (19:23 +0200)] 
BUG/MINOR: stats: Clear a bit more counters with in cli_parse_clear_counters().

Clear MaxSslRate, SslFrontendMaxKeyRate and SslBackendMaxKeyRate when
clear counters is used, it was probably forgotten when those counters were
added.

[wt: this can probably be backported as far as 1.5 in dumpstats.c]

7 years agoBUG/MINOR: tools: fix my_htonll() on x86_64
Willy Tarreau [Wed, 18 Oct 2017 09:39:33 +0000 (11:39 +0200)] 
BUG/MINOR: tools: fix my_htonll() on x86_64

Commit 36eb3a3 ("MINOR: tools: make my_htonll() more efficient on x86_64")
brought an incorrect asm statement missing the input constraints, causing
the input value not necessarily to be placed into the same register as the
output one, resulting in random output. It happens to work when building at
-O0 but not above. This was only detected in the HTTP/2 parser, but in
mainline it could only affect the integer to binary sample cast.

No backport is needed since this bug was only introduced in the development
branch.

7 years agoMINOR: checks: Add a new keyword to specify a SNI when doing SSL checks.
Olivier Houchard [Tue, 17 Oct 2017 15:33:43 +0000 (17:33 +0200)] 
MINOR: checks: Add a new keyword to specify a SNI when doing SSL checks.

Add a new keyword, "check-sni", to be able to specify the SNI to be used when
doing health checks over SSL.

7 years agoMINOR: server: Handle weight increase in consistent hash.
Olivier Houchard [Tue, 17 Oct 2017 13:52:59 +0000 (15:52 +0200)] 
MINOR: server: Handle weight increase in consistent hash.

When the server weight is rised using the CLI, extra nodes have to be
allocated, or the weight will be effectively the same as the original one.

[wt: given that the doc made no explicit mention about this limitation,
this patch could even be backported as it fixes an unexpected behaviour]

7 years agoBUG/MINOR: stream-int: don't set MSG_MORE on SHUTW_NOW without AUTO_CLOSE
Willy Tarreau [Tue, 17 Oct 2017 14:33:46 +0000 (16:33 +0200)] 
BUG/MINOR: stream-int: don't set MSG_MORE on SHUTW_NOW without AUTO_CLOSE

Since around 1.5-dev12, we've been setting MSG_MORE on send() on various
conditions, including the fact that SHUTW_NOW is present, but we don't
check that it's accompanied with AUTO_CLOSE. The result is that on requests
immediately followed by a close (where AUTO_CLOSE is not set), the request
gets delayed in the TCP stack before being sent to the server. This is
visible with the H2 code where the end-of-stream flag is set on requests,
but probably happens when a POLL_HUP is detected along with the request.
The (lack of) presence of option abortonclose has no effect here since we
never send the SHUTW along with the request.

This fix can be backported to 1.7, 1.6 and 1.5.

7 years agoBUG/MEDIUM: ssl: fix OCSP expiry calculation
Frederik Deweerdt [Mon, 16 Oct 2017 14:37:31 +0000 (07:37 -0700)] 
BUG/MEDIUM: ssl: fix OCSP expiry calculation

The hour part of the timezone offset was multiplied by 60 instead of
3600, resulting in an inaccurate expiry. This bug was introduced in
1.6-dev1 by commit 4f3c87a ("BUG/MEDIUM: ssl: Fix to not serve expired
OCSP responses."), so this fix must be backported into 1.7 and 1.6.

7 years agoMAJOR: servers: propagate server status changes asynchronously.
Emeric Brun [Tue, 3 Oct 2017 12:46:45 +0000 (14:46 +0200)] 
MAJOR: servers: propagate server status changes asynchronously.

In order to prepare multi-thread development, code was re-worked
to propagate changes asynchronoulsy.

Servers with pending status changes are registered in a list
and this one is processed and emptied only once 'run poll' loop.

Operational status changes are performed before administrative
status changes.

In a case of multiple operational status change or admin status
change in the same 'run poll' loop iteration, those changes are
merged to reach only the targeted status.

7 years agoMINOR: payload: add new sample fetch functions to process distcc protocol
Willy Tarreau [Fri, 13 Oct 2017 09:03:15 +0000 (11:03 +0200)] 
MINOR: payload: add new sample fetch functions to process distcc protocol

When using haproxy in front of distccd, it's possible to provide significant
improvements by only connecting when the preprocessing is completed, and by
selecting different farms depending on the payload size. This patch provides
two new sample fetch functions :

      distcc_param(<token>[,<occ>]) : integer
      distcc_body(<token>[,<occ>]) : binary

7 years agoMINOR: server: add the srv_queue() sample fetch method
Willy Tarreau [Fri, 13 Oct 2017 09:46:26 +0000 (11:46 +0200)] 
MINOR: server: add the srv_queue() sample fetch method

srv_queue([<backend>/]<server>) : integer
  Returns an integer value corresponding to the number of connections currently
  pending in the designated server's queue. If <backend> is omitted, then the
  server is looked up in the current backend. It can sometimes be used together
  with the "use-server" directive to force to use a known faster server when it
  is not much loaded. See also the "srv_conn", "avg_queue" and "queue" sample
  fetch methods.

7 years agoDOC: fix some typos
Patrick Starr [Mon, 9 Oct 2017 06:17:12 +0000 (13:17 +0700)] 
DOC: fix some typos

[wt: ~25 typos, most of which should be eligible for backporting]

7 years agoMINOR: session: remove the list of streams from struct session
Willy Tarreau [Sun, 8 Oct 2017 19:32:53 +0000 (21:32 +0200)] 
MINOR: session: remove the list of streams from struct session

Commit bcb86ab ("MINOR: session: add a streams field to the session
struct") added this list of streams that is not needed anymore. Let's
get rid of it now.

7 years agoMINOR: compiler: restore the likely() wrapper for gcc 5.x
Willy Tarreau [Sun, 8 Oct 2017 20:26:03 +0000 (22:26 +0200)] 
MINOR: compiler: restore the likely() wrapper for gcc 5.x

After some tests, gcc 5.x produces better code with likely()
than without, contrary to gcc 4.x where it was better to disable
it. Let's re-enable it for 5 and above.

7 years agoDOC: 51d: Updated git URL and instructions for getting Hash Trie data files.
Ben51Degrees [Thu, 5 Oct 2017 18:54:18 +0000 (19:54 +0100)] 
DOC: 51d: Updated git URL and instructions for getting Hash Trie data files.

Use branch, not tag for download URL, and recommend switching to Hash Trie.

7 years agoDOC: 51d: add 51Degrees git URL that points to release version 3.2.12.12
Dragan Dosen [Wed, 27 Sep 2017 10:55:07 +0000 (12:55 +0200)] 
DOC: 51d: add 51Degrees git URL that points to release version 3.2.12.12

The 51Degrees C library version 3.2.12.12 has support for a new Hash Trie
algorithm.

This patch can be backported in 1.7.

7 years agoBUILD/MINOR: 51d: fix warning when building with 51Degrees release version 3.2.12.12
Dragan Dosen [Wed, 27 Sep 2017 10:46:44 +0000 (12:46 +0200)] 
BUILD/MINOR: 51d: fix warning when building with 51Degrees release version 3.2.12.12

The warning appears when building with 51Degrees release that uses a new
Hash Trie algorithm (release version 3.2.12.12):

src/51d.c: In function init_51degrees:
src/51d.c:566:2: warning: enumeration value DATA_SET_INIT_STATUS_TOO_MANY_OPEN_FILES not handled in switch [-Wswitch]
  switch (_51d_dataset_status) {
  ^

This patch can be backported in 1.7.

7 years agoBUG/MAJOR: stream-int: don't re-arm recv if send fails
Bin Wang [Fri, 15 Sep 2017 06:56:40 +0000 (14:56 +0800)] 
BUG/MAJOR: stream-int: don't re-arm recv if send fails

When
    1) HAProxy configured to enable splice on both directions
    2) After some high load, there are 2 input channels with their socket buffer
       being non-empty and pipe being full at the same time, sitting in `fd_cache`
       without any other fds.

The 2 channels will repeatedly be stopped for receiving (pipe full) and waken
for receiving (data in socket), thus getting out and in of `fd_cache`, making
their fd swapping location in `fd_cache`.

There is a `if (entry < fd_cache_num && fd_cache[entry] != fd) continue;`
statement in `fd_process_cached_events` to prevent frequent polling, but since
the only 2 fds are constantly swapping location, `fd_cache[entry] != fd` will
always hold true, thus HAProxy can't make any progress.

The root cause of the issue is dual :
  - there is a single fd_cache, for next events and for the ones being
    processed, while using two distinct arrays would avoid the problem.

  - the write side of the stream interface wakes the read side up even
    when it couldn't write, and this one really is a bug.

Due to CF_WRITE_PARTIAL not being cleared during fast forwarding, a failed
send() attempt will still cause ->chk_rcv() to be called on the other side,
re-creating an entry for its connection fd in the cache, causing the same
sequence to be repeated indefinitely without any opportunity to make progress.

CF_WRITE_PARTIAL used to be used for what is present in these tests : check
if a recent write operation was performed. It's part of the CF_WRITE_ACTIVITY
set and is tested to check if timeouts need to be updated. It's also used to
detect if a failed connect() may be retried.

What this patch does is use CF_WROTE_DATA() to check for a successful write
for connection retransmits, and to clear CF_WRITE_PARTIAL before preparing
to send in stream_int_notify(). This way, timeouts are still updated each
time a write succeeds, but chk_rcv() won't be called anymore after a failed
write.

It seems the fix is required all the way down to 1.5.

Without this patch, the only workaround at this point is to disable splicing
in at least one direction. Strictly speaking, splicing is not absolutely
required, as regular forwarding could theorically cause the issue to happen
if the timing is appropriate, but in practice it appears impossible to
reproduce it without splicing, and even with splicing it may vary.

The following config manages to reproduce it after a few attempts (haproxy
going 100% CPU and having to be killed) :

  global
      maxpipes 50000
      maxconn 10000

  listen srv1
      option splice-request
      option splice-response
      bind :8001
      server s1 127.0.0.1:8002

  server$ tcploop 8002 L N20 A R10 S1000000 R10 S1000000 R10 S1000000 R10 S1000000 R10 S1000000
  client$ tcploop 8001 N20 C T S1000000 R10 J

7 years agoBUG/MEDIUM: http: Return an error when url_dec sample converter failed
Christopher Faulet [Thu, 5 Oct 2017 08:03:12 +0000 (10:03 +0200)] 
BUG/MEDIUM: http: Return an error when url_dec sample converter failed

url_dec sample converter uses url_decode function to decode an URL. This
function fails by returning -1 when an invalid character is found. But the
sample converter never checked the return value and it used it as length for the
decoded string. Because it always succeeded, the invalid sample (with a string
length set to -1) could be used by other sample fetches or sample converters,
leading to undefined behavior like segfault.

The fix is pretty simple, url_dec sample converter just needs to return an error
when url_decode fails.

This patch must be backported in 1.7 and 1.6.

7 years agoBUG/MEDIUM: cli: fix "show fd" crash when dumping closed FDs
Willy Tarreau [Wed, 4 Oct 2017 18:24:54 +0000 (20:24 +0200)] 
BUG/MEDIUM: cli: fix "show fd" crash when dumping closed FDs

I misplaced the "if (!fdt.owner)" test so it can occasionally crash
when dumping an fd that's already been closed but still appears in
the table. It's not critical since this was not pushed into any
release nor backported though.

7 years agoMEDIUM: checks: do not allocate a permanent connection anymore
Willy Tarreau [Wed, 4 Oct 2017 16:05:01 +0000 (18:05 +0200)] 
MEDIUM: checks: do not allocate a permanent connection anymore

Health check currently cheat, they allocate a connection upon startup and never
release it, it's only recycled. The problem with doing this is that this code
is preventing the connection code from evolving towards multiplexing.

This code ensures that it's safe for the checks to run without a connection
all the time. Given that the code heavily relies on CO_FL_ERROR to signal
check errors, it is not trivial but in practice this is the principle adopted
here :

  - the connection is not allocated anymore on startup

  - new checks are not supposed to have a connection, so an attempt is made
    to allocate this connection in the check task's context. If it fails,
    the check is aborted on a resource error, and the rare code on this path
    verifying the connection was adjusted to check for its existence (in
    practice, avoid to close it)

  - returning checks necessarily have a valid connection (which may possibly
    be closed).

  - a "tcp-check connect" rule tries to allocate a new connection before
    releasing the previous one (but after closing it), so that if it fails,
    it still keeps the previous connection in a closed state. This ensures
    a connection is always valid here

Now it works well on all tested cases (regular and TCP checks, even with
multiple reconnections), including when the connection is forced to NULL or
randomly allocated.

7 years agoMEDIUM: checks: make tcpcheck_main() indicate if it recycled a connection
Willy Tarreau [Wed, 4 Oct 2017 16:41:00 +0000 (18:41 +0200)] 
MEDIUM: checks: make tcpcheck_main() indicate if it recycled a connection

The tcp-checks are very fragile. They can modify a connection's FD by
closing and reopening a socket without informing the connection layer,
which may then possibly touch the wrong fd. Given that the events are
only cleared and that the fd is just created, there should be no visible
side effect because the old fd is deleted so even if its flags get cleared
they were already, and the new fd already has them cleared as well so it's
a NOP. Regardless, this is too fragile and will not resist to threads.

In order to address this situation, this patch makes tcpcheck_main()
indicate if it closed a connection and report it to wake_srv_chk(), which
will then report it to the connection's fd handler so that it refrains
from updating the connection polling and the fd. Instead the connection
polling status is updated in the wake() function.

7 years agoMINOR: checks: don't create then kill a dummy connection before tcp-checks
Willy Tarreau [Wed, 4 Oct 2017 14:21:19 +0000 (16:21 +0200)] 
MINOR: checks: don't create then kill a dummy connection before tcp-checks

When tcp-checks are in use, a connection starts to be created, then it's
destroyed so that tcp-check can recreate its own. Now we directly move
to tcpcheck_main() when it's detected that tcp-check is in use.

7 years agoMINOR: tcp-check: make tcpcheck_main() take a check, not a connection
Willy Tarreau [Wed, 4 Oct 2017 14:22:49 +0000 (16:22 +0200)] 
MINOR: tcp-check: make tcpcheck_main() take a check, not a connection

We want this one to allocate its own connection so it must not take a
connection but a check.

7 years agoTESTS: checks: add a simple test config for tcp-checks
Willy Tarreau [Wed, 4 Oct 2017 14:28:34 +0000 (16:28 +0200)] 
TESTS: checks: add a simple test config for tcp-checks

tcp-check.cfg tests various arrangements of initial tcp-check rules.

7 years agoBUG/MINOR: tcp-check: don't initialize then break a connection starting with a comment
Willy Tarreau [Wed, 4 Oct 2017 13:58:52 +0000 (15:58 +0200)] 
BUG/MINOR: tcp-check: don't initialize then break a connection starting with a comment

The following config :

    backend tcp9000
        option tcp-check
        tcp-check comment "this is a comment"
        tcp-check connect port 10000
        server srv 127.0.0.1:9000 check inter 1s

will result in a connection being first made to port 9000 then immediately
destroyed and re-created on port 10000, because the first rule is a comment
and doesn't match the test for the first rule being a connect(). It's
mostly harmless (unless the server really must not receive empty
connections) and the workaround simply consists in removing the comment.

Let's proceed like in other places where we simply skip leading comments.
A new function was made to make this lookup les boring. The fix should be
backported to 1.7 and 1.6.

7 years agoTESTS: checks: add a simple test config for external checks
Willy Tarreau [Wed, 4 Oct 2017 13:42:00 +0000 (15:42 +0200)] 
TESTS: checks: add a simple test config for external checks

ext-check.cfg tests both for success and failure in two different backends.

7 years agoCLEANUP: checks: do not allocate a connection for process checks
Willy Tarreau [Wed, 4 Oct 2017 13:25:38 +0000 (15:25 +0200)] 
CLEANUP: checks: do not allocate a connection for process checks

Since this connection is not used at all anymore, do not allocate it.
It was verified that check successes and failures (both synchronous
and asynchronous) continue to be properly reported.

7 years agoCLEANUP: checks: don't report report the fork() error twice
Willy Tarreau [Wed, 4 Oct 2017 13:19:26 +0000 (15:19 +0200)] 
CLEANUP: checks: don't report report the fork() error twice

Upon fork() error, a first report is immediately made by connect_proc_chk()
via set_server_check_status(), then process_chk_proc() detects the error
code and makes up a dummy connection error to call chk_report_conn_err(),
which tries to retrieve the errno code from the connection, fails, then
saves the status message from the check, fails all "if" tests on its path
related to the connection then resets the check's state to the current one
with the current status message. All this useless chain is the only reason
why process checks require a connection! Let's simply get rid of this second
useless call.

7 years agoCLEANUP: checks: remove misleading comments and statuses for external process
Willy Tarreau [Wed, 4 Oct 2017 13:07:02 +0000 (15:07 +0200)] 
CLEANUP: checks: remove misleading comments and statuses for external process

The external process check code abused a little bit from copy-pasting to
the point of making think it requires a connection... The initialization
code only returns SF_ERR_NONE and SF_ERR_RESOURCE, so the other one can
be folded there. The code now only uses the connection to report the
error status.

7 years agoMINOR: checks: make chk_report_conn_err() take a check, not a connection
Willy Tarreau [Wed, 4 Oct 2017 12:47:29 +0000 (14:47 +0200)] 
MINOR: checks: make chk_report_conn_err() take a check, not a connection

Amazingly, this function takes a connection to report an error and is used
by process checks, placing a hard dependency between the connection and the
check preventing the mux from being completely implemented. Let's first get
rid of this.

7 years agoBUG/MINOR: unix: properly check for octal digits in the "mode" argument
Willy Tarreau [Wed, 4 Oct 2017 12:43:44 +0000 (14:43 +0200)] 
BUG/MINOR: unix: properly check for octal digits in the "mode" argument

A config containing "stats socket /path/to/socket mode admin" used to
silently start and be unusable (mode 0, level user) because the "mode"
parser doesn't take care of non-digits. Now it properly reports :

   [ALERT] 276/144303 (7019) : parsing [ext-check.cfg:4] : 'stats socket' : ''mode' : missing or invalid mode 'admin' (octal integer expected)'

This can probably be backported to 1.7, 1.6 and 1.5, though reporting
parsing errors in very old versions probably isn't a good idea if the
feature was left unused for years.

7 years agoBUG/MEDIUM: tcp-check: don't call tcpcheck_main() from the I/O handlers!
Willy Tarreau [Wed, 4 Oct 2017 09:58:22 +0000 (11:58 +0200)] 
BUG/MEDIUM: tcp-check: don't call tcpcheck_main() from the I/O handlers!

This function can destroy a socket and create a new one, resulting in a
change of FD on the connection between recv() and send() for example,
which is absolutely not permitted, and can result in various funny games
like polling not being properly updated (or with the flags from a previous
fd) etc.

Let's only call this from the wake() callback which is more tolerant.
Ideally the operations should be made even more reliable by returning
a specific value to indicate that the connection was released and that
another one was created. But this is hasardous for stable releases as
it may reveal other issues.

This fix should be backported to 1.7 and 1.6.

7 years agoBUG/MINOR: tcp-check: don't quit with pending data in the send buffer
Willy Tarreau [Wed, 4 Oct 2017 09:38:08 +0000 (11:38 +0200)] 
BUG/MINOR: tcp-check: don't quit with pending data in the send buffer

In the rare case where the "tcp-check send" directive is the last one in
the list, it leaves the loop without sending the data. Fortunately, the
polling is still enabled on output, resulting in the connection handler
calling back to send what remains, but this is ugly and not very reliable.

This may be backported to 1.7 and 1.6.

7 years agoBUG/MEDIUM: tcp-check: properly indicate polling state before performing I/O
Willy Tarreau [Wed, 4 Oct 2017 06:45:19 +0000 (08:45 +0200)] 
BUG/MEDIUM: tcp-check: properly indicate polling state before performing I/O

While porting the connection to use the mux layer, it appeared that
tcp-checks wouldn't receive anymore because the polling is not enabled
before attempting to call xprt->rcv_buf() nor xprt->snd_buf(), and it
is illegal to call these functions with polling disabled as they
directly manipulate the FD state, resulting in an inconsistency where
the FD is enabled and the connection's polling flags disabled.

Till now it happened to work only because when recv() fails on EAGAIN
it calls fd_cant_recv() which enables polling while signaling the
failure, so that next time the message is received. But the connection's
polling is never enabled, and any tiny change resulting in a call to
conn_data_update_polling() immediately disables reading again.

It's likely that this problem already happens on some corner cases
such as multi-packet responses. It definitely breaks as soon as the
response buffer is full but we don't support consuming more than one
response buffer.

This fix should be backported to 1.7 and 1.6. In order to check for the
proper behaviour, this tcp-check must work and clearly show an SSH
banner in recvfrom() as observed under strace, otherwise it's broken :

   tcp-check connect port 22
   tcp-check expect rstring SSH
   tcp-check send blah

7 years agoCLEANUUP: checks: don't set conn->handle.fd to -1
Willy Tarreau [Wed, 4 Oct 2017 05:48:56 +0000 (07:48 +0200)] 
CLEANUUP: checks: don't set conn->handle.fd to -1

This used to be needed to know whether there was a check in progress a
long time ago (before tcp_checks) but this is not true anymore and even
becomes wrong after the check is reused as conn_init() initializes it
to DEAD_FD_MAGIC.

7 years agoBUG/MEDIUM: tcp/http: set-dst-port action broken
Baptiste Assmann [Tue, 3 Oct 2017 21:16:36 +0000 (23:16 +0200)] 
BUG/MEDIUM: tcp/http: set-dst-port action broken

A regression has been introduced in commit
00005ce5a14310d248c9f20af9ef258d245d43b1: the port being changed is the
one from 'cli_conn->addr.from' instead of 'cli_conn->addr.to'.

This patch fixes the regression.

Backport status: should be backported to HAProxy 1.7 and above.

7 years agoBUG/MINOR: contrib/halog: fixing small memory leak
Ilya Shipitsin [Fri, 22 Sep 2017 17:33:16 +0000 (22:33 +0500)] 
BUG/MINOR: contrib/halog: fixing small memory leak

Issue was identified by cppcheck

7 years agoBUG/MINOR: log: fixing small memory leak in error code path.
David Carlier [Thu, 21 Sep 2017 14:36:43 +0000 (14:36 +0000)] 
BUG/MINOR: log: fixing small memory leak in error code path.

since we do not log the sample fetch when it is invalid, we can
free the log data.

7 years agoBUG/MEDIUM: server: unwanted behavior leaving maintenance mode on tracked stopping...
Willy Tarreau [Thu, 21 Sep 2017 15:37:38 +0000 (17:37 +0200)] 
BUG/MEDIUM: server: unwanted behavior leaving maintenance mode on tracked stopping server (take2)

Previous patch got accidently broken. This one fixes it.

7 years agoBUG/MEDIUM: server: unwanted behavior leaving maintenance mode on tracked stopping...
Emeric Brun [Thu, 21 Sep 2017 13:45:44 +0000 (15:45 +0200)] 
BUG/MEDIUM: server: unwanted behavior leaving maintenance mode on tracked stopping server

Leaving the maintenance state and if the server remains in stopping mode due
to a tracked one:

- We mistakenly try to grab some pending conns and shutdown backup sessions.
- The proxy down time and last change were also mistakenly updated

7 years agoMINOR: ist: add a macro to ease const array initialization
Willy Tarreau [Thu, 21 Sep 2017 13:24:10 +0000 (15:24 +0200)] 
MINOR: ist: add a macro to ease const array initialization

It's not possible to use strlen() in const arrays even with const
strings, but we can use sizeof-1 via a macro. Let's provide this in
the IST() macro, as it saves the developer from having to count the
characters.

7 years agoMINOR: connection: adjust CO_FL_NOTIFY_DATA after removal of flags
Willy Tarreau [Wed, 20 Sep 2017 15:46:46 +0000 (17:46 +0200)] 
MINOR: connection: adjust CO_FL_NOTIFY_DATA after removal of flags

After the removal of CO_FL_DATA_RD_SH and CO_FL_DATA_WR_SH, the
aggregate mask CO_FL_NOTIFY_DATA was not updated. It happens that
now CO_FL_NOTIFY_DATA and CO_FL_NOTIFY_DONE are similar, which may
reveal some overlap between the ->wake and ->xprt_done callbacks.
We'll see after the mux changes if both are still required.

7 years agoMINOR: net_helper: add 64-bit read/write functions
Willy Tarreau [Wed, 20 Sep 2017 06:14:52 +0000 (08:14 +0200)] 
MINOR: net_helper: add 64-bit read/write functions

These ones are the same as the previous ones but for 64 bit values.
We're using my_ntohll() and my_htonll() from standard.h for the byte
order conversion.

7 years agoMINOR: net_helper: add write functions
Willy Tarreau [Tue, 19 Sep 2017 15:27:05 +0000 (17:27 +0200)] 
MINOR: net_helper: add write functions

These ones are the equivalent of the read_* functions. They support
writing unaligned words, possibly wrapping, in host and network order.
The write_i*() functions were not implemented since the caller can
already use the unsigned version.

7 years agoMINOR: net_helper: add functions to read from vectors
Willy Tarreau [Tue, 19 Sep 2017 12:59:52 +0000 (14:59 +0200)] 
MINOR: net_helper: add functions to read from vectors

This patch adds the ability to read from a wrapping memory area (ie:
buffers). The new functions are called "readv_<type>". The original
ones were renamed to start with "read_" to make the difference more
obvious between the read method and the returned type.

It's worth noting that the memory barrier in readv_bytes() is critical,
as otherwise gcc decides that it doesn't need the resulting data, but
even worse, removes the length checks in readv_u64() and happily
performs an out-of-bounds unaligned read using read_u64()! Such
"optimizations" are a bit borderline, especially when they impact
security like this...

7 years agoMINOR: buffer: add b_end() and b_to_end()
Willy Tarreau [Tue, 19 Sep 2017 19:14:08 +0000 (21:14 +0200)] 
MINOR: buffer: add b_end() and b_to_end()

These ones return respectively the pointer to the end of the buffer and
the distance between b->p and the end. These will simplify a bit some
new code needed to parse directly from a wrapping buffer.

7 years agoMINOR: buffer: add b_del() to delete a number of characters
Willy Tarreau [Tue, 19 Sep 2017 12:18:46 +0000 (14:18 +0200)] 
MINOR: buffer: add b_del() to delete a number of characters

This will be used by code which directly parses buffers with no channel
in the middle (eg: h2, might be used by checks as well).

7 years agoMINOR: tools: make my_htonll() more efficient on x86_64
Willy Tarreau [Wed, 20 Sep 2017 06:18:49 +0000 (08:18 +0200)] 
MINOR: tools: make my_htonll() more efficient on x86_64

The current construct was made when developing on a 32-bit machine.
Having a simple bswap operation replaced with 2 bswap, 2 shift and
2 or is quite of a waste of precious cycles... Let's provide a trivial
asm-based implementation for x86_64.

7 years agoBUG/MINOR: contrib/modsecurity: close the va_list ap before return
Dragan Dosen [Mon, 18 Sep 2017 07:20:43 +0000 (09:20 +0200)] 
BUG/MINOR: contrib/modsecurity: close the va_list ap before return

Make sure the va_list ap is closed before return in case the function
vsnprintf() returned an error.

7 years agoBUG/MINOR: contrib/mod_defender: close the va_list argp before return
Dragan Dosen [Mon, 18 Sep 2017 06:20:33 +0000 (08:20 +0200)] 
BUG/MINOR: contrib/mod_defender: close the va_list argp before return

Fix the case when the va_list argp could be left open if the function
vsnprintf() returned a negative value.

7 years agoMINOR: ssl: Remove useless checks on bind_conf or bind_conf->is_ssl
Christopher Faulet [Fri, 15 Sep 2017 07:52:49 +0000 (09:52 +0200)] 
MINOR: ssl: Remove useless checks on bind_conf or bind_conf->is_ssl

bind_conf always exists at these steps and it is always for SSL listeners.

7 years agoBUG/MINOR: dns: Fix check on nameserver in snr_resolution_cb
Christopher Faulet [Fri, 15 Sep 2017 09:55:45 +0000 (11:55 +0200)] 
BUG/MINOR: dns: Fix check on nameserver in snr_resolution_cb

snr_resolution_cb can be called with <nameserver> parameter set to NULL. So we
must check it before using it. This is done most of time, except when we deal
with invalid DNS response.

7 years agoBUG/MINOR: spoe: Don't rely on SPOE ctx in debug message when its creation failed
Christopher Faulet [Fri, 15 Sep 2017 09:51:18 +0000 (11:51 +0200)] 
BUG/MINOR: spoe: Don't rely on SPOE ctx in debug message when its creation failed

If the SPOE context creation failed, we must not try to use it in the debug
message used to notice the error.

This patch must be backported in 1.7.

7 years agoBUG/MINOR: compression: Check response headers before http-response rules eval
Christopher Faulet [Fri, 15 Sep 2017 09:39:36 +0000 (11:39 +0200)] 
BUG/MINOR: compression: Check response headers before http-response rules eval

This is required if we want to use res.comp or res.comp_algo sample fetches in
http-response rules.

This patch must be backported in 1.7.

7 years agoBUG/MEDIUM: compression: Fix check on txn in smp_fetch_res_comp_algo
Christopher Faulet [Fri, 15 Sep 2017 08:14:43 +0000 (10:14 +0200)] 
BUG/MEDIUM: compression: Fix check on txn in smp_fetch_res_comp_algo

The check was totally messed up. In the worse case, it led to a crash, when
res.comp_algo sample fetch was retrieved on uncompressed response (with the
compression enabled).

This patch must be backported in 1.7.

7 years agoMEDIUM: session: count the frontend's connections at a single place
Willy Tarreau [Fri, 15 Sep 2017 08:25:14 +0000 (10:25 +0200)] 
MEDIUM: session: count the frontend's connections at a single place

There are several places where we see feconn++, feconn--, totalconn++ and
an increment on the frontend's number of connections and connection rate.
This is done exactly once per session in each direction, so better take
care of this counter in the session and simplify the callers. At least it
ensures a better symmetry. It also ensures consistency as till now the
lua/spoe/peers frontend didn't have these counters properly set, which can
be useful at least for troubleshooting.

7 years agoMEDIUM: session: factor out duplicated code for conn_complete_session
Willy Tarreau [Fri, 15 Sep 2017 08:06:28 +0000 (10:06 +0200)] 
MEDIUM: session: factor out duplicated code for conn_complete_session

session_accept_fd() may either successfully complete a session creation,
or defer it to conn_complete_session() depending of whether a handshake
remains to be performed or not. The problem is that all the code after
the handshake was duplicated between the two functions.

This patch make session_accept_fd() synchronously call
conn_complete_session() to finish the session creation. It is only needed
to check if the session's task has to be released or not at the end, which
is fairly minimal. This way there is now a single place where the sessions
are created.

7 years agoMINOR: session: small cleanup of conn_complete_session()
Willy Tarreau [Fri, 15 Sep 2017 07:49:59 +0000 (09:49 +0200)] 
MINOR: session: small cleanup of conn_complete_session()

Commit 8e3c6ce ("MEDIUM: connection: get rid of data->init() which was
not for data") simplified conn_complete_session() but introduced a
confusing check which cannot happen on CO_FL_HANDSHAKE. Make it clear
that this call is final and will either succeed and complete the
session or fail.

7 years agoMINOR: listener: new function listener_release
Willy Tarreau [Fri, 15 Sep 2017 07:19:58 +0000 (09:19 +0200)] 
MINOR: listener: new function listener_release

Instead of duplicating some sensitive listener-specific code in the
session and in the stream code, let's call listener_release() when
releasing a connection attached to a listener.

7 years agoMEDIUM: session: take care of incrementing/decrementing jobs
Willy Tarreau [Fri, 15 Sep 2017 07:07:56 +0000 (09:07 +0200)] 
MEDIUM: session: take care of incrementing/decrementing jobs

Each user of a session increments/decrements the jobs variable at its
own place, resulting in a real mess and inconsistencies between them.
Let's have session_new() increment jobs and session_free() decrement
it.

7 years agoMINOR: listeners: make listeners count consistent with reality
Willy Tarreau [Fri, 15 Sep 2017 06:18:11 +0000 (08:18 +0200)] 
MINOR: listeners: make listeners count consistent with reality

Some places call delete_listener() then decrement the number of
listeners and jobs. At least one other place calls delete_listener()
without doing so, but since it's in deinit(), it's harmless and cannot
risk to cause zombie processes to survive. Given that the number of
listeners and jobs is incremented when creating the listeners, it's
much more logical to symmetrically decrement them when deleting such
listeners.

7 years agoMINOR: listeners: new function create_listeners
Willy Tarreau [Fri, 15 Sep 2017 06:10:44 +0000 (08:10 +0200)] 
MINOR: listeners: new function create_listeners

This function is used to create a series of listeners for a specific
address and a port range. It automatically calls the matching protocol
handlers to add them to the relevant lists. This way cfgparse doesn't
need to manipulate listeners anymore. As an added bonus, the memory
allocation is checked.

7 years agoMINOR: unix: remove the now unused proto_uxst.h file
Willy Tarreau [Fri, 15 Sep 2017 05:59:31 +0000 (07:59 +0200)] 
MINOR: unix: remove the now unused proto_uxst.h file

Since everything is self contained in proto_uxst.c there's no need to
export anything. The same should be done for proto_tcp.c but the file
contains other stuff that's not related to the TCP protocol itself
and which should first be moved somewhere else.

7 years agoMINOR: protocols: register the ->add function and stop calling them directly
Willy Tarreau [Fri, 15 Sep 2017 05:55:51 +0000 (07:55 +0200)] 
MINOR: protocols: register the ->add function and stop calling them directly

cfgparse has no business directly calling each individual protocol's 'add'
function to create a listener. Now that they're all registered, better
perform a protocol lookup on the family and have a standard ->add method
for all of them.

7 years agoMINOR: protocols: always pass a "port" argument to the listener creation
Willy Tarreau [Fri, 15 Sep 2017 05:44:44 +0000 (07:44 +0200)] 
MINOR: protocols: always pass a "port" argument to the listener creation

It's a shame that cfgparse() has to make special cases of each protocol
just to cast the port to the target address family. Let's pass the port
in argument to the function. The unix listener simply ignores it.

7 years agoMINOR: frontend: don't retrieve ALPN on the critical path
Willy Tarreau [Fri, 15 Sep 2017 09:43:32 +0000 (11:43 +0200)] 
MINOR: frontend: don't retrieve ALPN on the critical path

It's pointless to read it on each and every accept(), as we only need
it for reporting in debugging mode a few lines later. Let's move this
part to the relevant block.

7 years agoMINOR: peers: don't reference the incoming listener on outgoing connections
Willy Tarreau [Fri, 15 Sep 2017 09:01:04 +0000 (11:01 +0200)] 
MINOR: peers: don't reference the incoming listener on outgoing connections

Since v1.7 it's pointless to reference a listener when greating a session
for an outgoing connection, it only complicates the code. SPOE and Lua were
cleaned up in 1.8-dev1 but the peers code was forgotten. This patch fixes
this by not assigning such a listener for outgoing connections. It also has
the extra benefit of not discounting the outgoing connections from the number
of allowed incoming connections (the code currently adds a safety marging of
3 extra connections to take care of this).

7 years agoBUILD: Makefile: improve detection of support for compiler warnings
Willy Tarreau [Thu, 14 Sep 2017 17:05:45 +0000 (19:05 +0200)] 
BUILD: Makefile: improve detection of support for compiler warnings

Some compiler versions don't emit an error when facing an unknown
no-warning unless another error is reported, resulting in all -Wno-*
options being enabled by default and being reported as wrong with
build errors. Let's create a new "cc-nowarn" function to disable
warnings only after checking that the positive one is supported.

7 years agoBUILD: Makefile: shut certain gcc/clang stupid warnings
Willy Tarreau [Wed, 13 Sep 2017 14:58:27 +0000 (16:58 +0200)] 
BUILD: Makefile: shut certain gcc/clang stupid warnings

The recent gcc and clang are utterly broken and apparently written by
people who don't use them anymore, because they emit warnings that are
impossible to disable in the code, which is the opposite of what a
warning should do. It is however possible to disable these warnings on
the command line.

This patch adds when supported :
   -Wno-format-truncation: bogus warning which is triggered on each
    snprintf() call based on the input type instead of the variables
    ranges, resulting in the impossibility to use "%02d" and similar.

   -Wno-address-of-packed-member: emitted for each and every line in
    ebtree.h by recent clang. Probably that the warning's author has
    never understood the use cases of packed structs and should be
    taught the use cases of the language he writes the compiler for.

   -Wno-null-dereference: emitted by clang on *(int *)0 = 0. The code
    will be updated to use a volatile instead but this recent change
    of behaviour will certainly cause quite some bugs in decades of
    existing code.

Feel free to report new such stupid warnings and to propose patches
to complete this list.

7 years agoBUILD: Makefile: add a function to detect support by the compiler of certain options
Willy Tarreau [Wed, 13 Sep 2017 14:54:28 +0000 (16:54 +0200)] 
BUILD: Makefile: add a function to detect support by the compiler of certain options

The recent gcc and clang are utterly broken and apparently written by
people who don't use them anymore, because they emit warnings that are
impossible to disable in the code, which is the opposite of what a
warning should do. It is however possible to disable these warnings on
the command line, but not in a backwards-compatible way.

Thus here we create a new function which detect if the compiler supports
certain options, and which adds them if supported.

7 years agoMINOR: add severity information to cli feedback messages
Andjelko Iharos [Thu, 20 Jul 2017 14:49:14 +0000 (16:49 +0200)] 
MINOR: add severity information to cli feedback messages

7 years agoMINOR: cli: add socket commands and config to prepend informational messages with...
Andjelko Iharos [Thu, 20 Jul 2017 09:59:48 +0000 (11:59 +0200)] 
MINOR: cli: add socket commands and config to prepend informational messages with severity

Adds cli commands to change at runtime whether informational messages
are prepended with severity level or not, with support for numeric and
worded severity in line with syslog severity level.

Adds stats socket config keyword severity-output to set default behavior
per socket on startup.

7 years agoMINOR: net_helper: Inline functions meant to be inlined.
Olivier Houchard [Wed, 13 Sep 2017 09:49:22 +0000 (11:49 +0200)] 
MINOR: net_helper: Inline functions meant to be inlined.

7 years agoMINOR: tasks: Move Lua notification from Lua to tasks
Thierry FOURNIER [Wed, 12 Jul 2017 12:31:10 +0000 (14:31 +0200)] 
MINOR: tasks: Move Lua notification from Lua to tasks

These notification management function and structs are generic and
it will be better to move in common parts.

The notification management functions and structs have names
containing some "lua" references because it was written for
the Lua. This patch removes also these references.

7 years agoMEDIUM: xref/lua: Use xref for referencing cosocket relation between stream and lua
Thierry FOURNIER [Mon, 11 Sep 2017 16:37:23 +0000 (18:37 +0200)] 
MEDIUM: xref/lua: Use xref for referencing cosocket relation between stream and lua

This relation will ensure that each was informed about death of another one.

7 years agoMINOR: xref: Add a new xref system
Thierry FOURNIER [Thu, 31 Aug 2017 18:35:18 +0000 (20:35 +0200)] 
MINOR: xref: Add a new xref system

xref is used to create a relation between two elements.
Once an element is released, it breaks the relation. If the
relation is already broken, it frees the xref struct.
The pointer between two elements is a sort of refcount with
max value 1. The relation is only between two elements.
The pointer and the type of element a and b are conventional.

Note that xref is initialised from Lua files because Lua is
the only one user.

7 years agoBUG/MINOR: Lua: The socket may be destroyed when we try to access.
Thierry FOURNIER [Tue, 11 Jul 2017 16:38:39 +0000 (18:38 +0200)] 
BUG/MINOR: Lua: The socket may be destroyed when we try to access.

When we try to access to other proxy context, we must check
its existence because haproxy can kill it between the creation
and the usage.

This patch should be backported in 1.6 and 1.7

7 years agoBUG/MEDIUM: http: Close streams for connections closed before a redirect
Christopher Faulet [Mon, 11 Sep 2017 07:27:29 +0000 (09:27 +0200)] 
BUG/MEDIUM: http: Close streams for connections closed before a redirect

A previous fix was made to prevent the connection to a server if a redirect was
performed during the request processing when we wait to keep the client
connection alive. This fix introduced a pernicious bug. If a client closes its
connection immediately after sending a request, it is possible to keep stream
alive infinitely. This happens when the connection closure is caught when the
request is received, before the request parsing.

To be more specific, this happens because the close event is not "forwarded",
first because of the call to "channel_dont_connect" in the function
"http_apply_redirect_rule", then because we want to keep the client connection
alive, we explicitly call "channel_dont_close" in the function
"http_request_forward_body".

So, to fix the bug, instead of blocking the server connection, we force its
shutdown. This will force the stream to re-evaluate all connexions states. So it
will detect the client has closed its connection.

This patch must be backported in 1.7.

7 years agoMINOR: ssl: rework smp_fetch_ssl_fc_cl_str without internal ssl use
Emmanuel Hocdet [Fri, 1 Sep 2017 15:32:08 +0000 (17:32 +0200)] 
MINOR: ssl: rework smp_fetch_ssl_fc_cl_str without internal ssl use

smp_fetch_ssl_fc_cl_str as very limited usage (only work with openssl == 1.0.2
compiled with the option enable-ssl-trace). It use internal cipher.algorithm_ssl
attribut and SSL_CIPHER_standard_name (available with ssl-trace).
This patch implement this (debug) function in a standard way. It used common
SSL_CIPHER_get_name to display cipher name. It work with openssl >= 1.0.2
and boringssl.

7 years agoRevert "BUG/MINOR: server: Remove FQDN requirement for using init-addr and state...
Willy Tarreau [Wed, 6 Sep 2017 12:22:45 +0000 (14:22 +0200)] 
Revert "BUG/MINOR: server: Remove FQDN requirement for using init-addr and state file"

This reverts commit 19e8aa58f7c42e602a95b4ceb4b254c424aed11c.

It causes some trouble reported by Manu :
   listen tls
     [...]
     server bla 127.0.0.1:8080

   [ALERT] 248/130258 (21960) : parsing [/etc/haproxy/test.cfg:53] : 'server bla' : no method found to resolve address '(null)'
   [ALERT] 248/130258 (21960) : Failed to initialize server(s) addr.

According to Nenad :
  "It's not a good way to fix the issue we were experiencing
   before. It will need a bigger rewrite, because the logic in
   srv_iterate_initaddr needs to be changed."

7 years agoBUG/MINOR: server: Remove FQDN requirement for using init-addr and state file
Nenad Merdanovic [Tue, 5 Sep 2017 13:32:47 +0000 (15:32 +0200)] 
BUG/MINOR: server: Remove FQDN requirement for using init-addr and state file

Historically the DNS was the only way of updating the server IP dynamically
and the init-addr processing and state file load required the server to have
an FQDN defined. Given that we can now update the IP through the socket as
well and also can have different init-addr values (like IP and 'none') - this
requirement needs to be removed.

This patch should be backported to 1.7.

7 years agoMINOR: polling: Use fd_update_events to update events seen for a fd
Christopher Faulet [Wed, 30 Aug 2017 08:34:36 +0000 (10:34 +0200)] 
MINOR: polling: Use fd_update_events to update events seen for a fd

Now, the same function is used by all pollers to update events seen for a
fd. This will ease the threads support integration.

7 years agoMINOR: fd: Add fd_update_events function
Christopher Faulet [Wed, 30 Aug 2017 08:30:04 +0000 (10:30 +0200)] 
MINOR: fd: Add fd_update_events function

This function should be called by the poller to set FD_POLL_* flags on an FD and
update its state if needed. This function has been added to ease threads support
integration.

7 years agoBUG/MEDIUM: epoll: ensure we always consider HUP and ERR
Willy Tarreau [Tue, 5 Sep 2017 13:32:56 +0000 (15:32 +0200)] 
BUG/MEDIUM: epoll: ensure we always consider HUP and ERR

Since commit 5be2f35 ("MAJOR: polling: centralize calls to I/O callbacks")
that came into 1.6-dev1, each poller deals with its own events and decides
to signal ability to receive or send on a file descriptor based on the
active events on the file descriptor.

The commit above was incorrectly done for the epoll code. Instead of
checking the active events on the fd, it checks for the new events. In
general these ones are the same for POLL_IN and POLL_OUT since they
are always cleared prior to being computed, but it is possible that
POLL_HUP and POLL_ERR were initially reported and are not reported
again (especially for HUP). This could happen for example if POLL_HUP
and POLL_IN were received together, the pending data exactly correspond
to a full buffer which is read at once, preventing the POLL_HUP from
being dealt with in the same call, and on the next call only POLL_OUT
is reported (eg: to emit some response or peers protocol ACKs). In this
case fd_may_recv() will not be enabled anymore and the close event will
be missed.

It seems quite hard to trigger this case, though it might explain some
of the rare missed close events that were detected in the past on the
peers.

This fix needs to be backported to 1.6 and 1.7.

7 years agoMEDIUM: check: server states and weight propagation re-work
Emeric Brun [Thu, 31 Aug 2017 12:41:55 +0000 (14:41 +0200)] 
MEDIUM: check: server states and weight propagation re-work

The server state and weight was reworked to handle
"pending" values updated by checks/CLI/LUA/agent.
These values are commited to be propagated to the
LB stack.

In further dev related to multi-thread, the commit
will be handled into a sync point.

Pending values are named using the prefix 'next_'
Current values used by the LB stack are named 'cur_'

7 years agoMINOR: freq_ctr: Return the new value after an update
Christopher Faulet [Fri, 1 Sep 2017 10:18:36 +0000 (12:18 +0200)] 
MINOR: freq_ctr: Return the new value after an update

This will ease threads support integration.

7 years agoMINOR: fd: Move (de)allocation of fdtab and fdinfo in (de)init_pollers
Christopher Faulet [Thu, 31 Aug 2017 15:52:09 +0000 (17:52 +0200)] 
MINOR: fd: Move (de)allocation of fdtab and fdinfo in (de)init_pollers

This will be useful for the threads support integration.

7 years agoMINOR: fd: Use inlined functions to check fd state in fd_*_send/recv functions
Christopher Faulet [Wed, 30 Aug 2017 08:07:47 +0000 (10:07 +0200)] 
MINOR: fd: Use inlined functions to check fd state in fd_*_send/recv functions

It these functions, the test is inverted and we rely on fd_recv/send_* function
to check the fd state. This will ease threads support integration.

7 years agoMINOR: fd: Add fd_active function
Christopher Faulet [Wed, 30 Aug 2017 07:59:38 +0000 (09:59 +0200)] 
MINOR: fd: Add fd_active function

This inlined function is used to check if a fd is active for receive or send. It
will ease threads support integration.

7 years agoMINOR: http: Use a trash chunk to store decoded string of the HTTP auth header
Christopher Faulet [Thu, 27 Jul 2017 13:18:52 +0000 (15:18 +0200)] 
MINOR: http: Use a trash chunk to store decoded string of the HTTP auth header

This string is used in sample fetches so it is safe to use a preallocated trash
chunk instead of a buffer dynamically allocated during HAProxy startup.