]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
11 years agoMEDIUM: connection: add check for readiness in I/O handlers
Willy Tarreau [Mon, 20 Jan 2014 14:13:07 +0000 (15:13 +0100)] 
MEDIUM: connection: add check for readiness in I/O handlers

The recv/send callbacks must check for readiness themselves instead of
having their callers do it. This will strengthen the test and will also
ensure we never refrain from calling a handshake handler because a
direction is being polled while the other one is ready.

11 years agoMEDIUM: connection: remove conn_{data,sock}_poll_{recv,send}
Willy Tarreau [Wed, 22 Jan 2014 19:02:06 +0000 (20:02 +0100)] 
MEDIUM: connection: remove conn_{data,sock}_poll_{recv,send}

We simply remove these functions and replace their calls with the
appropriate ones :

  - if we're in the data phase, we can simply report wait on the FD
  - if we're in the socket phase, we may also have to signal the
    desire to read/write on the socket because it might not be
    active yet.

11 years agoMAJOR: connection: remove the CO_FL_WAIT_{RD,WR} flags
Willy Tarreau [Wed, 22 Jan 2014 18:46:33 +0000 (19:46 +0100)] 
MAJOR: connection: remove the CO_FL_WAIT_{RD,WR} flags

These flags were used to report the readiness of the file descriptor.
Now this readiness is directly checked at the file descriptor itself.
This removes the need for constantly synchronizing updates between the
file descriptor and the connection and ensures that all layers share
the same level of information.

For now, the readiness is updated in conn_{sock,data}_poll_* by directly
touching the file descriptor. This must move to the lower layers instead
so that these functions can disappear as well. In this state, the change
works but is incomplete. It's sensible enough to avoid making it more
complex.

Now the sock/data updates become much simpler because they just have to
enable/disable access to a file descriptor and not to care anymore about
its readiness.

11 years agoMAJOR: polling: rework the whole polling system
Willy Tarreau [Fri, 10 Jan 2014 15:58:45 +0000 (16:58 +0100)] 
MAJOR: polling: rework the whole polling system

This commit heavily changes the polling system in order to definitely
fix the frequent breakage of SSL which needs to remember the last
EAGAIN before deciding whether to poll or not. Now we have a state per
direction for each FD, as opposed to a previous and current state
previously. An FD can have up to 8 different states for each direction,
each of which being the result of a 3-bit combination. These 3 bits
indicate a wish to access the FD, the readiness of the FD and the
subscription of the FD to the polling system.

This means that it will now be possible to remember the state of a
file descriptor across disable/enable sequences that generally happen
during forwarding, where enabling reading on a previously disabled FD
would result in forgetting the EAGAIN flag it met last time.

Several new state manipulation functions have been introduced or
adapted :
  - fd_want_{recv,send} : enable receiving/sending on the FD regardless
    of its state (sets the ACTIVE flag) ;

  - fd_stop_{recv,send} : stop receiving/sending on the FD regardless
    of its state (clears the ACTIVE flag) ;

  - fd_cant_{recv,send} : report a failure to receive/send on the FD
    corresponding to EAGAIN (clears the READY flag) ;

  - fd_may_{recv,send}  : report the ability to receive/send on the FD
    as reported by poll() (sets the READY flag) ;

Some functions are used to report the current FD status :

  - fd_{recv,send}_active
  - fd_{recv,send}_ready
  - fd_{recv,send}_polled

Some functions were removed :
  - fd_ev_clr(), fd_ev_set(), fd_ev_rem(), fd_ev_wai()

The POLLHUP/POLLERR flags are now reported as ready so that the I/O layers
knows it can try to access the file descriptor to get this information.

In order to simplify the conditions to add/remove cache entries, a new
function fd_alloc_or_release_cache_entry() was created to be used from
pollers while scanning for updates.

The following pollers have been updated :

   ev_select() : done, built, tested on Linux 3.10
   ev_poll()   : done, built, tested on Linux 3.10
   ev_epoll()  : done, built, tested on Linux 3.10 & 3.13
   ev_kqueue() : done, built, tested on OpenBSD 5.2

11 years agoREORG: polling: rename "fd_process_spec_events()" to "fd_process_cached_events()"
Willy Tarreau [Sat, 25 Jan 2014 18:24:15 +0000 (19:24 +0100)] 
REORG: polling: rename "fd_process_spec_events()" to "fd_process_cached_events()"

This is in order to be coherent with the rest.

11 years agoREORG: polling: rename the cache allocation functions
Willy Tarreau [Sat, 25 Jan 2014 18:20:35 +0000 (19:20 +0100)] 
REORG: polling: rename the cache allocation functions

- alloc_spec_entry() becomes fd_alloc_cache_entry()
- release_spec_entry() becomes fd_release_cache_entry()

11 years agoREORG: polling: rename "fd_spec" to "fd_cache"
Willy Tarreau [Sat, 25 Jan 2014 18:10:48 +0000 (19:10 +0100)] 
REORG: polling: rename "fd_spec" to "fd_cache"

So fd_spec was renamed "fd_cache" as it's becoming an event cache, and
fd_nbspec becomes fd_cache_num.

11 years agoREORG: polling: rename "spec_e" to "state" and "spec_p" to "cache"
Willy Tarreau [Mon, 20 Jan 2014 10:09:39 +0000 (11:09 +0100)] 
REORG: polling: rename "spec_e" to "state" and "spec_p" to "cache"

We're completely changing the way FDs will be polled. There will be no
more speculative I/O since we'll know the exact FD state, so these will
only be cached events.

First, let's fix a few field names which become confusing. "spec_e" was
used to store a speculative I/O event state. Now we'll store the whole
R/W states for the FD there. "spec_p" was used to store a speculative
I/O cache position. Now let's clearly call it "cache".

11 years agoDOC: add a diagram showing polling state transitions
Willy Tarreau [Fri, 17 Jan 2014 18:40:43 +0000 (19:40 +0100)] 
DOC: add a diagram showing polling state transitions

This is internal stuff.

11 years agoCLEANUP: polling: rename "spec_e" to "state"
Willy Tarreau [Mon, 20 Jan 2014 10:02:59 +0000 (11:02 +0100)] 
CLEANUP: polling: rename "spec_e" to "state"

We're completely changing the way FDs will be polled. First, let's fix
a few field names which become confusing. "spec_e" was used to store a
speculative I/O event state. Now we'll store the whole R/W states for
the FD there.

11 years agoBUILD: fix VERDATE exclusion regex
Willy Tarreau [Sat, 25 Jan 2014 23:39:22 +0000 (00:39 +0100)] 
BUILD: fix VERDATE exclusion regex

A backslash was missing. It used to work well with GNU grep anyway but
better fix it.

11 years agoBUG/MEDIUM: stream-interface: don't wake the task up before end of transfer
Willy Tarreau [Sat, 25 Jan 2014 01:33:21 +0000 (02:33 +0100)] 
BUG/MEDIUM: stream-interface: don't wake the task up before end of transfer

Recent commit d7ad9f5 ("MAJOR: channel: add a new flag CF_WAKE_WRITE to
notify the task of writes") was not correct. It used to wake up the task
as soon as there was some write activity and the flag was set, even if there
were still some data to be forwarded. This resulted in process_session()
being called a lot when transfering chunk-encoded HTTP responses made of
very large chunks.

The purpose of the flag is to wake up only a task waiting for some
room and not the other ones, so it's totally counter-productive to
wake it up as long as there are data to forward because the task
will not be allowed to write anyway.

Also, the commit above was taking some risks by not considering
certain events anymore (eg: state != SI_ST_EST). While such events
are not used at the moment, if some new features were developped
in the future relying on these, it would be better that they could
be notified when subscribing to the WAKE_WRITE event, so let's
restore the condition.

11 years agoBUG/MAJOR: fix freezes during compression
Willy Tarreau [Sat, 25 Jan 2014 01:26:39 +0000 (02:26 +0100)] 
BUG/MAJOR: fix freezes during compression

Recent commit d7ad9f5 ("MAJOR: channel: add a new flag CF_WAKE_WRITE to
notify the task of writes") introduced this new CF_WAKE_WRITE flag that
an analyser which requires some free space to write must set if it wants
to be notified.

Unfortunately, some places were missing. More specifically, the
compression engine can rarely be stuck by a lack of output space,
especially when dealing with non-compressible data. It then has to
stop until some pending data are flushed and for this it must set
the CF_WAKE_WRITE flag. But these cases were missed by the commit
above.

Fortunately, this change was introduced very recently and never
released, so the impact was limited.

Huge thanks to Sander Klein who first reported this issue and who kindly
and patiently provided lots of traces and test data that made it possible
to reproduce, analyze, then fix this issue.

11 years agoDOC: fix misleading information about SIGQUIT
Willy Tarreau [Sat, 25 Jan 2014 17:19:32 +0000 (18:19 +0100)] 
DOC: fix misleading information about SIGQUIT

SIGQUIT dumps the pools state to stderr, not to the logs. Thanks to
Jim Freeman for reporting this.

11 years agoBUG/MEDIUM: unique_id: HTTP request counter is not stable
Willy Tarreau [Sat, 25 Jan 2014 10:01:50 +0000 (11:01 +0100)] 
BUG/MEDIUM: unique_id: HTTP request counter is not stable

Patrick Hemmer reported that using unique_id_format and logs did not
report the same unique ID counter since commit 9f09521 ("BUG/MEDIUM:
unique_id: HTTP request counter must be unique!"). This is because
the increment was done while producing the log message, so it was
performed twice.

A better solution consists in fetching a new value once per request
and saving it in the request or session context for all of this
request's life.

It happens that sessions already have a unique ID field which is used
for debugging and reporting errors, and which differs from the one
sent in logs and unique_id header.

So let's change this to reuse this field to have coherent IDs everywhere.
As of now, a session gets a new unique ID once it is instanciated. This
means that TCP sessions will also benefit from a unique ID that can be
logged. And this ID is renewed for each extra HTTP request received on
an existing session. Thus, all TCP sessions and HTTP requests will have
distinct IDs that will be stable along all their life, and coherent
between all places where they're used (logs, unique_id header,
"show sess", "show errors").

This feature is 1.5-specific, no backport to 1.4 is needed.

11 years agoBUG/MINOR: payload: the patterns of the acl "req.ssl_ver" are no parsed with the...
Thierry FOURNIER [Fri, 24 Jan 2014 11:41:51 +0000 (12:41 +0100)] 
BUG/MINOR: payload: the patterns of the acl "req.ssl_ver" are no parsed with the good function.

The fetch "req.ssl_ver" is not declared as explicit acl. If it is used
as implicit ACL, the acl engine detect SMP_T_UINT output type and choose
to use the default interger parser: pat_parse_int(). This fetch needs the
parser pat_parse_dotted_ver().

This patch declare explicit ACL named "req.ssl_ver" that use the good
parser function pat_parse_dotted_ver().

11 years agoMEDIUM: checks: make use of chk_report_conn_err() for connection errors
Willy Tarreau [Fri, 24 Jan 2014 15:10:57 +0000 (16:10 +0100)] 
MEDIUM: checks: make use of chk_report_conn_err() for connection errors

Checks used not to precisely report the errors that were detected at the
connection layer (eg: too many SSL connections). Using chk_report_conn_err()
makes this possible.

11 years agoMEDIUM: tcp: report connection error at the connection level
Willy Tarreau [Fri, 24 Jan 2014 15:08:19 +0000 (16:08 +0100)] 
MEDIUM: tcp: report connection error at the connection level

Now when a connection error happens, it is reported in the connection
so that upper layers know exactly what happened. This is particularly
useful with health checks and resources exhaustion.

11 years agoMINOR: connection: add more error codes to report connection errors
Willy Tarreau [Fri, 24 Jan 2014 15:06:50 +0000 (16:06 +0100)] 
MINOR: connection: add more error codes to report connection errors

It is quite often that an connection error only reports "socket error" with
no more information. This is especially problematic with health checks where
many causes are possible, including resource exhaustion which do not lead to
a valid errno code. So let's add explicit codes to cover these cases.

11 years agoMINOR: standard: The parse_binary() returns the length consumed and his documentation...
Thierry FOURNIER [Tue, 21 Jan 2014 10:36:14 +0000 (11:36 +0100)] 
MINOR: standard: The parse_binary() returns the length consumed and his documentation is updated

Actually the values returned by this function is never used. All the
callers just check if the resultat is non-zero. Before this patch, the
function returns the length of the produced content. This value is not
useful because is returned twice: the first time in the return value and
the second time in the <binstrlen> argument. Now the function returns
the number of bytes consumed from <source>.

11 years agoMINOR: pattern: move functions for grouping pat_match_* and pat_parse_* and add docum...
Thierry FOURNIER [Tue, 21 Jan 2014 10:25:41 +0000 (11:25 +0100)] 
MINOR: pattern: move functions for grouping pat_match_* and pat_parse_* and add documentation.

11 years agoBUG/MEDIUM: pattern: Segfault in binary parser
Thierry FOURNIER [Tue, 21 Jan 2014 09:59:24 +0000 (10:59 +0100)] 
BUG/MEDIUM: pattern: Segfault in binary parser

The functions pat_parse_* must return 0 if fail and the number of
elements eated from **text if not fail. The function pat_parse_bin()
returns 0 or the length parsed. This causes a segfault. I just apply the
double operator "!" on the result of the function pat_parse_bin() and
the return value value match the expected value.

11 years agoMEDIUM: connection: update callers of ctrl->drain() to use conn_drain()
Willy Tarreau [Mon, 20 Jan 2014 11:10:52 +0000 (12:10 +0100)] 
MEDIUM: connection: update callers of ctrl->drain() to use conn_drain()

Now we can more safely rely on the connection state to decide how to
drain and what to do when data are drained. Callers don't need to
manipulate the file descriptor's state anymore.

Note that it also removes the need for the fix ea90063 ("BUG/MEDIUM:
stream-int: fix the keep-alive idle connection handler") since conn_drain()
correctly sets the polling flags.

11 years agoMEDIUM: tcp: report in tcp_drain() that lingering is already disabled on close
Willy Tarreau [Mon, 20 Jan 2014 10:56:37 +0000 (11:56 +0100)] 
MEDIUM: tcp: report in tcp_drain() that lingering is already disabled on close

When an incoming shutdown or error is detected, we know that we
can safely close without disabling lingering. Do it in tcp_drain()
so that we don't have to do it from each and every caller.

11 years agoMINOR: connection: add a new conn_drain() function
Willy Tarreau [Mon, 20 Jan 2014 10:41:52 +0000 (11:41 +0100)] 
MINOR: connection: add a new conn_drain() function

Till now there was no way to know from a connection if a previous
call to drain() had done any change. This function is used to drain
incoming data and to update the connection's flags at the same time.
It also correctly sets the polling flags on the connection if the
drain function indicates inability to receive. This function will
be used preferably over ctrl->drain() when a connection is used.

11 years agoMINOR: protocol: improve the proto->drain() API
Willy Tarreau [Mon, 20 Jan 2014 10:26:12 +0000 (11:26 +0100)] 
MINOR: protocol: improve the proto->drain() API

It was not possible to know if the drain() function had hit an
EAGAIN, so now we change the API of this function to return :
  < 0 if EAGAIN was met
  = 0 if some data remain
  > 0 if a shutdown was received

11 years agoMEDIUM: listener: fix polling management in the accept loop
Willy Tarreau [Mon, 20 Jan 2014 20:21:30 +0000 (21:21 +0100)] 
MEDIUM: listener: fix polling management in the accept loop

The accept loop used to force fd_poll_recv() even in places where it
was not completely appropriate (eg: unexpected errors). It does not
yet cause trouble but will do with the upcoming polling changes. Let's
use it only where relevant now. EINTR/ECONNABORTED do not result in
poll() anymore but the failed connection is simply skipped (this code
dates from 1.1.32 when error codes were first considered).

11 years agoBUG/MEDIUM: polling: ensure we update FD status when there's no more activity
Willy Tarreau [Mon, 20 Jan 2014 19:18:59 +0000 (20:18 +0100)] 
BUG/MEDIUM: polling: ensure we update FD status when there's no more activity

Some rare unexplained busy loops were observed on versions up to 1.5-dev19.
It happens that if a file descriptor happens to be disabled for both read and
write while it was speculatively enabled for both and this without creating a
new update entry, there will be no way to remove it from the speculative I/O
list until some other changes occur. It is suspected that a double sequence
such as enable_both/disable_both could have led to this situation where an
update cancels itself and does not clear the spec list in the poll loop.
While it is unclear what I/O sequence may cause this situation to arise, it
is safer to always add the FD to the update list if nothing could be done on
it so that the next poll round will automatically take care of it.

This is 1.5-specific, no backport is needed.

11 years agoBUG/MAJOR: ssl: fix breakage caused by recent fix abf08d9
Willy Tarreau [Fri, 17 Jan 2014 10:09:40 +0000 (11:09 +0100)] 
BUG/MAJOR: ssl: fix breakage caused by recent fix abf08d9

Recent commit abf08d9 ("BUG/MAJOR: connection: fix mismatch between rcv_buf's
API and usage") accidentely broke SSL by relying on an uninitialized value to
enter the read loop.

Many thanks to Cyril Bonté and Steve Ruiz for reporting this issue.

11 years agoBUG/MEDIUM: map: segmentation fault with the stats's socket command "set map ..."
Thierry FOURNIER [Wed, 15 Jan 2014 17:09:36 +0000 (18:09 +0100)] 
BUG/MEDIUM: map: segmentation fault with the stats's socket command "set map ..."

The value of the variable "appctx->ctx.map.ent" is used after the loop,
but its value has changed. The variable "value" is initialized and
contains the good value.

This is a recent bug, no backport is needed.

11 years agoBUILD: listener: fix recent accept4() again
Willy Tarreau [Wed, 15 Jan 2014 15:45:17 +0000 (16:45 +0100)] 
BUILD: listener: fix recent accept4() again

Recent commit 4448925 ("BUILD/MINOR: listener: remove a glibc warning on accept4()")
broke accept4() on some systems because the glibc's version may now conflict with
the local one.

11 years agoBUG/MAJOR: connection: fix mismatch between rcv_buf's API and usage
Willy Tarreau [Tue, 14 Jan 2014 10:31:27 +0000 (11:31 +0100)] 
BUG/MAJOR: connection: fix mismatch between rcv_buf's API and usage

Steve Ruiz reported some reproducible crashes with HTTP health checks
on a certain page returning a huge length. The traces he provided
clearly showed that the recv() call was performed twice for a total
size exceeding the buffer's length.

Cyril Bonté tracked down the problem to be caused by the full buffer
size being passed to rcv_buf() in event_srv_chk_r() instead of passing
just the remaining amount of space. Indeed, this change happened during
the connection rework in 1.5-dev13 with the following commit :

f150317 MAJOR: checks: completely use the connection transport layer

But one of the problems is also that the comments at the top of the
rcv_buf() functions suggest that the caller only has to ensure the
requested size doesn't overflow the buffer's size.

Also, these functions already have to care about the buffer's size to
handle wrapping free space when there are pending data in the buffer.
So let's change the API instead to more closely match what could be
expected from these functions :

- the caller asks for the maximum amount of bytes it wants to read ;
This means that only the caller is responsible for enforcing the
reserve if it wants to (eg: checks don't).

- the rcv_buf() functions fix their computations to always consider
this size as a max, and always perform validity checks based on
the buffer's free space.

As a result, the code is simplified and reduced, and made more robust
for callers which now just have to care about whether they want the
buffer to be filled or not.

Since the bug was introduced in 1.5-dev13, no backport to stable versions
is needed.

11 years agoBUILD/MINOR: listener: remove a glibc warning on accept4()
Willy Tarreau [Tue, 14 Jan 2014 16:52:01 +0000 (17:52 +0100)] 
BUILD/MINOR: listener: remove a glibc warning on accept4()

The accept4() Linux syscall requires _GNU_SOURCE on ix86, otherwise
it emits a warning. On other archs including x86_64, this problem
doesn't happen. Thanks to Charles Carter from Sigma Software for
reporting this.

11 years agoBUG/MINOR: pattern: pattern comparison executed twice
Thierry FOURNIER [Tue, 14 Jan 2014 12:38:40 +0000 (13:38 +0100)] 
BUG/MINOR: pattern: pattern comparison executed twice

If the pattern is set as case insensitive, the string comparison
is executed twice. The first time is insensitive comparison, the
second is sensitive.

This is a recent bug, no backport is needed.

11 years agoBUG: Revert "OPTIM: poll: restore polling after a poll/stop/want sequence"
Willy Tarreau [Mon, 13 Jan 2014 10:34:42 +0000 (11:34 +0100)] 
BUG: Revert "OPTIM: poll: restore polling after a poll/stop/want sequence"

This reverts commit 12082663561aa2189d243328060c399f2fd95860.

It randomly breaks SSL. What happens is that if the SSL response is
read at once by the SSL stack and is partially delivered to the buffer,
then there's no way to read the next parts because we wait for some
polling first.

So we'll fix this after the polling rework.

11 years agoMEDIUM: config: report a warning when multiple servers have the same name
Willy Tarreau [Fri, 3 Jan 2014 11:14:34 +0000 (12:14 +0100)] 
MEDIUM: config: report a warning when multiple servers have the same name

A config where multiple servers have the same name in the same backend is
prone to a number of issues : logs are not really exploitable, stats get
really tricky and even harder to change, etc...

In fact, it can be safe to have the same name between multiple servers only
when their respective IDs are known and used. So now we detect this situation
and emit a warning for the first conflict detected per server if any of the
servers uses an automatic ID.

11 years agoOPTIM: session: put unlikely() around the freewheeling code
Willy Tarreau [Tue, 31 Dec 2013 22:56:46 +0000 (23:56 +0100)] 
OPTIM: session: put unlikely() around the freewheeling code

The code which enables tunnel mode or TCP transfers is rarely used
and at most once per session. Putting it in an unlikely() clause
reduces the length of the hot path of process_session() which is
already quite long, and also slightly reduces its overall size.
Some measurements show a steady gain of about 0.2% thanks to this.

11 years agoMINOR: checks: use an inline function for health_adjust()
Willy Tarreau [Tue, 31 Dec 2013 22:47:37 +0000 (23:47 +0100)] 
MINOR: checks: use an inline function for health_adjust()

This function is called twice per request, and does almost always nothing.
Better use an inline version to avoid entering it when we can.

About 0.5% additional performance was gained this way.

11 years agoMEDIUM: stream-int: make si_connect() return an established state when possible
Willy Tarreau [Tue, 31 Dec 2013 22:32:12 +0000 (23:32 +0100)] 
MEDIUM: stream-int: make si_connect() return an established state when possible

si_connect() used to only return SI_ST_CON. But it already detect the
connection reuse and is the function which avoids calling connect().
So it already knows the connection is valid and reuse. Thus we make it
return SI_ST_EST when a connection is reused. This means that
connect_server() can return this state and sess_update_stream_int()
as well.

Thanks to this change, we don't need to leave process_session() in
SI_ST_CON state to immediately enter it again to switch to SI_ST_EST.
Implementing this removes one call to process_session() per request
in keep-alive mode. We're now at 2 calls per request, which is the
minimum (one for the request and another one for the response). The
number of calls to http_wait_for_response() has also dropped from 2
to one.

Tests indicate a performance gain of about 2.6% in request rate in
keep-alive mode. There should be no gain in http-server-close() since
we don't use this faster path.

11 years agoMEDIUM: session: prepare to support earlier transitions to the established state
Willy Tarreau [Tue, 31 Dec 2013 22:16:50 +0000 (23:16 +0100)] 
MEDIUM: session: prepare to support earlier transitions to the established state

At the moment it is possible in sess_prepare_conn_req() to switch to the
established state when the target is an applet. But sess_update_stream_int()
will soon also have the ability to set the established state via
connect_server() when a connection is reused, leading to a synchronous
connect.

So prepare the code to handle this SI_ST_ASS -> SI_ST_EST transition, which
really matches what's done in the lower layers.

11 years agoMINOR: session: factor out the connect time measurement
Willy Tarreau [Tue, 31 Dec 2013 22:06:46 +0000 (23:06 +0100)] 
MINOR: session: factor out the connect time measurement

Currently there are 3 places in the code where t_connect is set after
switching to state SI_ST_EST, and a fourth one will soon come. Since
all these places lead to an immediate call to sess_establish() to
complete the session establishment, better move that measurement
there.

11 years agoBUG/MINOR: http: don't clear the SI_FL_DONT_WAKE flag between requests
Willy Tarreau [Tue, 31 Dec 2013 22:03:09 +0000 (23:03 +0100)] 
BUG/MINOR: http: don't clear the SI_FL_DONT_WAKE flag between requests

It's a bit hasardous to wipe out all channel flags, this flag should
be left intact as it protects against recursive calls. Fortunately,
we have no possibility to meet this situation with current applets,
but better fix it before it becomes an issue.

This bug has been there for a long time, but it doesn't seem worth
backporting the fix.

11 years agoOPTIM: session: set the READ_DONTWAIT flag when connecting
Willy Tarreau [Tue, 31 Dec 2013 21:33:13 +0000 (22:33 +0100)] 
OPTIM: session: set the READ_DONTWAIT flag when connecting

As soon as we connect to the server, we want to limit the number of
recvfrom() on the response path because most of the time a single
call will retrieve enough information.

At the moment this is only done in the HTTP response parser, after
some reads have already failed, which is too late. We need to do
that at the earliest possible instant. It was already done for the
request side by frontend_accept() for the first request, and by
http_reset_txn() for the next requests.

Thanks to this change, there are no more failed recvfrom() calls in
keep-alive mode.

11 years agoMAJOR: channel: add a new flag CF_WAKE_WRITE to notify the task of writes
Willy Tarreau [Tue, 31 Dec 2013 16:26:25 +0000 (17:26 +0100)] 
MAJOR: channel: add a new flag CF_WAKE_WRITE to notify the task of writes

Since commit 6b66f3e ([MAJOR] implement autonomous inter-socket forwarding)
introduced in 1.3.16-rc1, we've been relying on a stupid mechanism to wake
up the task after a write, which was an exact copy-paste of the reader side.

The principle was that if we empty a buffer and there's no forwarding
scheduled or if the *producer* is not in a connected state, then we wake
the task up.

That does not make any sense. It happens to wake up too late sometimes (eg,
when the request analyser waits for some room in the buffer to start to
work), and leads to unneeded wakeups in client-side keep-alive, because
the task is woken up when the response is sent, while the analysers are
simply waiting for a new request.

In order to fix this, we introduce a new channel flag : CF_WAKE_WRITE. It
is designed so that an analyser can explicitly request being notified when
some data were written. It is used only when the HTTP request or response
analysers need to wait for more room in the buffers. It is automatically
cleared upon wake up.

The flag is also automatically set by the functions which try to write into
a buffer from an applet when they fail (bi_putblk() etc...).

That allows us to remove the stupid condition above and avoid some wakeups.
In http-server-close and in http-keep-alive modes, this reduces from 4 to 3
the average number of wakeups per request, and increases the overall
performance by about 1.5%.

11 years agoRevert "MEDIUM: stats: add support for HTTP keep-alive on the stats page"
Willy Tarreau [Sat, 28 Dec 2013 23:43:40 +0000 (00:43 +0100)] 
Revert "MEDIUM: stats: add support for HTTP keep-alive on the stats page"

This reverts commit f3221f99acdd792352d4ee648d987270d74ca38e.

Igor reported some very strange breakage of his stats page which is
clearly caused by the chunking, though I don't see at first glance
what could be wrong. Better revert it for now.

11 years agoBUG/MEDIUM: stats: fix HTTP/1.0 breakage introduced in previous patch
Willy Tarreau [Sat, 28 Dec 2013 20:48:56 +0000 (21:48 +0100)] 
BUG/MEDIUM: stats: fix HTTP/1.0 breakage introduced in previous patch

Some debugging code was left in the code and committed, which breaks 1.0.

11 years agoMEDIUM: stats: add support for HTTP keep-alive on the stats page
Willy Tarreau [Sat, 28 Dec 2013 20:11:35 +0000 (21:11 +0100)] 
MEDIUM: stats: add support for HTTP keep-alive on the stats page

In theory the principle is simple as we just need to send HTTP chunks
if the client is 1.1 compatible. In practice it's harder because we
have to append a CR LF after each block of data and we're never sure
to have the room for this. In order not to have to deal with this, we
instead send the CR LF prior to each chunk size. The only issue is for
the first chunk and for this reason we avoid to send the empty header
line when using chunked encoding.

11 years agoBUG/MINOR: stream-int: do not clear the owner upon unregister
Willy Tarreau [Sat, 28 Dec 2013 20:06:18 +0000 (21:06 +0100)] 
BUG/MINOR: stream-int: do not clear the owner upon unregister

Since the applet rework and the removal of the inter-task applets,
we must not clear the stream-interface's owner task anymore otherwise
we risk a crash when maintaining keep-alive with an applet. This is
not possible right now so there is no impact yet, but this bug is not
easy to track down. No backport is needed.

11 years agoBUG/MINOR: channel: CHN_INFINITE_FORWARD must be unsigned
Willy Tarreau [Sat, 28 Dec 2013 18:16:26 +0000 (19:16 +0100)] 
BUG/MINOR: channel: CHN_INFINITE_FORWARD must be unsigned

This value is stored as unsigned in chn->to_forward. Having it defined
as signed makes it impossible to pass channel_forward() a previously
saved value because the argument will be zero-extended during the
conversion to long long, while the test will be performed using sign
extension. There is no impact on existing code right now.

11 years agoBUG/MEDIUM: stats: the web interface must check the tracked servers before enabling
Willy Tarreau [Sat, 28 Dec 2013 20:28:49 +0000 (21:28 +0100)] 
BUG/MEDIUM: stats: the web interface must check the tracked servers before enabling

When enabling a tracked server via the web interface, we must first
check if the server tracks another one and the state of this tracked
server, just like the command line does.

Failure to do so causes incorrect logs to be emitted when the server
is enabled :

[WARNING] 361/212556 (2645) : Server bck2/srv3 is DOWN via bck2/srv2. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 361/212603 (2645) : Server bck2/srv3 is DOWN for maintenance.
--> enable server now
[WARNING] 361/212606 (2645) : Server bck2/srv3 is UP (leaving maintenance).

With this fix, it's correct now :

[WARNING] 361/212805 (2666) : Server bck2/srv3 is DOWN via bck2/srv2. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 361/212813 (2666) : Server bck2/srv3 is DOWN for maintenance.
--> enable server now
[WARNING] 361/212821 (2666) : Server bck2/srv3 is DOWN via bck2/srv2. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.

It does not seem necessary to backport this fix, considering that it
depends on extremely fragile behaviours, there are more risks of breakage
caused by a backport than the current inconvenience.

11 years agoBUG/MEDIUM: checks: unchecked servers could not be enabled anymore
Willy Tarreau [Sat, 28 Dec 2013 20:21:31 +0000 (21:21 +0100)] 
BUG/MEDIUM: checks: unchecked servers could not be enabled anymore

Recent fix 02541e8 (BUG/MEDIUM: checks: servers must not start in
slowstart mode) failed to consider one case : a server chich is not
checked at all can be disabled and has to support being enabled
again. So we must also enter the set_server_up() function when the
checks are totally disabled.

No backport is needed.

11 years agoOPTIM: http: don't stop polling for read on the client side after a request
Willy Tarreau [Fri, 27 Dec 2013 22:03:08 +0000 (23:03 +0100)] 
OPTIM: http: don't stop polling for read on the client side after a request

We used to unconditionally disable client-side polling after the client
has posted its request. The goal was to avoid subscribing the file
descriptor to the poller for nothing.

This is perfect for the HTTP close mode where we know we won't have to
read on the client side anymore. However, when keep-alive is maintained
with the client, this makes the situation worse. Indeed, after the first
response, we'll have to wait for the client to send a next request and
since this is never immediate, we'll certainly poll. So what happens is
that polling is enabled after a response and disabled after a request,
so the polling is constantly alternating, which is very expensive with
epoll_ctl().

The solution implemented in this patch consists in only disabling the
polling if the client-side is not in keep-alive mode. That way we have
the best of both worlds. In close, we really close, and in keep-alive,
we poll only once.

The performance gained by this change is important, with haproxy jumping
from 158kreq/s to 184kreq/s (+16%) in HTTP keep-alive mode on a machine
which at best does 222k/s in raw TCP mode.

With this patch and the previous one, a keep-alive run with a fast
enough server (or enough concurrent connections to cover the connect
time) does no epoll_ctl() anymore during a run of ab -k. The net
measured gain is 19%.

11 years agoOPTIM: poll: restore polling after a poll/stop/want sequence
Willy Tarreau [Fri, 27 Dec 2013 19:11:50 +0000 (20:11 +0100)] 
OPTIM: poll: restore polling after a poll/stop/want sequence

If a file descriptor is being polled, and it stopped (eg: buffer full
or end of response), then re-enabled, currently what happens is that
the polling is disabled, then the fd is enabled in speculative mode,
an I/O attempt is made, it loses (otherwise the FD would surely not
have been polled), and the polled is enabled again.

This is too bad, especially with HTTP keep-alive on the server side
where all operations are performed at once before going back to the
poll loop.

Now we improve the behaviour by ensuring that if an fd is still being
polled, when it's enabled after having been disabled, we re-enable the
polling. Doing so saves a number of syscalls and useless wakeups, and
results in a significant performance gain on HTTP keep-alive. A 11%
increase has been observed on the HTTP request rate in keep-alive
thanks to this.

It could be considered as a bug fix, but there was no harm with the
current behaviour, except extra syscalls.

11 years agoBUG/MINOR: http: always disable compression on HTTP/1.0
Willy Tarreau [Tue, 24 Dec 2013 13:41:35 +0000 (14:41 +0100)] 
BUG/MINOR: http: always disable compression on HTTP/1.0

Compression is normally disabled on HTTP/1.0 since it does not
support chunked encoded responses. But the test was incomplete, and
Bertrand Jacquin reported a case where if the server responded using
1.1 to an 1.0 request, then haproxy still used to compress (and of
course the client could not understand the response).

No backport is needed, this is 1.5-specific.

11 years agoMINOR: http: try to stick to same server after status 401/407
Willy Tarreau [Mon, 23 Dec 2013 14:11:25 +0000 (15:11 +0100)] 
MINOR: http: try to stick to same server after status 401/407

In HTTP keep-alive mode, if we receive a 401, we still have a chance
of being able to send the visitor again to the same server over the
same connection. This is required by some broken protocols such as
NTLM, and anyway whenever there is an opportunity for sending the
challenge to the proper place, it's better to do it (at least it
helps with debugging).

11 years agoBUG/MINOR: checks: successful check completion must not re-enable MAINT servers
Willy Tarreau [Mon, 23 Dec 2013 13:04:17 +0000 (14:04 +0100)] 
BUG/MINOR: checks: successful check completion must not re-enable MAINT servers

If a server is switched to maintenance mode while a check is in progress,
the successful completion of the check must not switch it back up. This
is still a consequence of using the same function set_server_up() for
every state change. Bug reported by Igor at owind.

This fix should be backported to 1.4 which is affected as well.

11 years agoBUG: Revert "OPTIM/MEDIUM: epoll: fuse active events into polled ones during polling...
Willy Tarreau [Fri, 20 Dec 2013 15:03:41 +0000 (16:03 +0100)] 
BUG: Revert "OPTIM/MEDIUM: epoll: fuse active events into polled ones during polling changes"

This reverts commit 2f877304ef180654d165bf4ba8c88c204fc09d36.

This commit is OK for clear text traffic but causes trouble with SSL
when buffers are smaller than SSL buffers. Since the issue it addresses
will be gone once the polling redesign is complete, there's no reason
for trying to workaround temporary inefficiencies. Better remove it.

11 years agoBUG/MEDIUM: backend: do not re-initialize the connection's context upon reuse
Willy Tarreau [Fri, 20 Dec 2013 10:09:51 +0000 (11:09 +0100)] 
BUG/MEDIUM: backend: do not re-initialize the connection's context upon reuse

If we reuse a server-side connection, we must not reinitialize its context nor
try to enable send_proxy. At the moment HTTP keep-alive over SSL fails on the
first attempt because the SSL context was cleared, so it only worked after a
retry.

11 years agoBUG/MEDIUM: stream-int: fix the keep-alive idle connection handler
Willy Tarreau [Tue, 17 Dec 2013 13:21:48 +0000 (14:21 +0100)] 
BUG/MEDIUM: stream-int: fix the keep-alive idle connection handler

Commit 2737562 (MEDIUM: stream-int: implement a very simplistic idle
connection manager) implemented an idle connection handler. In the
case where all data is drained from the server, it fails to disable
polling, resulting in a busy spinning loop.

Thanks to Sander Klein and Guillaume Castagnino for reporting this bug.

No backport is needed.

11 years agoBUILD: last release inadvertently prepended a "+" in front of the date
Willy Tarreau [Tue, 17 Dec 2013 10:11:16 +0000 (11:11 +0100)] 
BUILD: last release inadvertently prepended a "+" in front of the date

No impact.

11 years ago[RELEASE] Released version 1.5-dev21 v1.5-dev21
Willy Tarreau [Mon, 16 Dec 2013 23:45:49 +0000 (00:45 +0100)] 
[RELEASE] Released version 1.5-dev21

Released version 1.5-dev21 with the following main changes :
    - MINOR: stats: don't use a monospace font to report numbers
    - MINOR: session: remove debugging code
    - BUG/MAJOR: patterns: fix double free caused by loading strings from files
    - MEDIUM: http: make option http_proxy automatically rewrite the URL
    - BUG/MEDIUM: http: cook_cnt() forgets to set its output type
    - BUG/MINOR: stats: correctly report throttle rate of low weight servers
    - BUG/MEDIUM: checks: servers must not start in slowstart mode
    - BUG/MINOR: acl: parser must also stop at comma on ACL-only keywords
    - MEDIUM: stream-int: implement a very simplistic idle connection manager
    - DOC: update the ROADMAP file

11 years agoDOC: update the ROADMAP file
Willy Tarreau [Mon, 16 Dec 2013 23:35:27 +0000 (00:35 +0100)] 
DOC: update the ROADMAP file

I already forgot to update it for dev20.

11 years agoMEDIUM: stream-int: implement a very simplistic idle connection manager
Willy Tarreau [Mon, 16 Dec 2013 23:00:28 +0000 (00:00 +0100)] 
MEDIUM: stream-int: implement a very simplistic idle connection manager

Idle connections are not monitored right now. So if a server closes after
a response without advertising it, it won't be detected until a next
request wants to use the connection. This is a bit problematic because
it unnecessarily maintains file descriptors and sockets in an idle
state.

This patch implements a very simple idle connection manager for the stream
interface. It presents itself as an I/O callback. The HTTP engine enables
it when it recycles a connection. If a close or an error is detected on the
underlying socket, it tries to drain as much data as possible from the socket,
detect the close and responds with a close as well, then detaches from the
stream interface.

11 years agoBUG/MINOR: acl: parser must also stop at comma on ACL-only keywords
Willy Tarreau [Mon, 16 Dec 2013 21:01:06 +0000 (22:01 +0100)] 
BUG/MINOR: acl: parser must also stop at comma on ACL-only keywords

Igor at owind reported that "url_reg,lower" does not parse because
find_acl_kw() looks for the parenthesis but not for the comma.

11 years agoBUG/MEDIUM: checks: servers must not start in slowstart mode
Willy Tarreau [Mon, 16 Dec 2013 17:08:36 +0000 (18:08 +0100)] 
BUG/MEDIUM: checks: servers must not start in slowstart mode

In 1.5-dev20, commit bb9665e (BUG/MEDIUM: checks: ensure we can enable
a server after boot) tried to fix a side effect of having both regular
checks and agent checks condition the up state propagation to servers.

Unfortunately it was still not fine because after this fix, servers
which make use of slowstart start in this mode. We must not check
the agent's health if agent checks are not enabled, and likewise,
we must not check the regular check's health if they are not enabled.

Reading the code, it seems like we could avoid entering this function
at all if (s->state & SRV_RUNNING) is not satisfied. Let's reserve
this for a later patch if needed.

Thanks to Sander Klein for reporting this abnormal situation.

11 years agoBUG/MINOR: stats: correctly report throttle rate of low weight servers
Willy Tarreau [Mon, 16 Dec 2013 17:04:57 +0000 (18:04 +0100)] 
BUG/MINOR: stats: correctly report throttle rate of low weight servers

The throttling of low weight servers (<16) could mistakenly be reported
as > 100% due to a rounding that was performed before a multiply by 100
instead of after. This was introduced in 1.5-dev20 when fixing a previous
reporting issue by commit d32c399 (MINOR: stats: report correct throttling
percentage for servers in slowstart).

It should be backported if the patch above is backported.

11 years agoBUG/MEDIUM: http: cook_cnt() forgets to set its output type
Willy Tarreau [Mon, 16 Dec 2013 14:14:43 +0000 (15:14 +0100)] 
BUG/MEDIUM: http: cook_cnt() forgets to set its output type

Since comit b805f71 (MEDIUM: sample: let the cast functions set their
output type), the output type of a fetch function is automatically
considered and passed to the next converter. A bug introduced in
1.5-dev9 with commit f853c46 (MEDIUM: pattern/acl: get rid of
temp_pattern in ACLs) was revealed by this last one : the output type
remained string instead of UINT, causing the cast function to try to
cast the contents and to crash on a NULL deref.

Note: this fix was made after a careful review of all fetch functions.
A few non-trivial ones had their comments amended to clearly indicate
the output type.

11 years agoMEDIUM: http: make option http_proxy automatically rewrite the URL
Willy Tarreau [Mon, 16 Dec 2013 13:30:55 +0000 (14:30 +0100)] 
MEDIUM: http: make option http_proxy automatically rewrite the URL

There are very few users of http_proxy, and all of them complain about
the same thing : the request is passed unmodified to the server (in its
proxy form), and it is not possible to fix it using reqrep rules because
http_proxy happens after.

So let's have http_proxy fix the URL it has analysed to get rid of the
scheme and the host part. This will do what users of this feature expect.

11 years agoBUG/MAJOR: patterns: fix double free caused by loading strings from files
Willy Tarreau [Mon, 16 Dec 2013 09:40:28 +0000 (10:40 +0100)] 
BUG/MAJOR: patterns: fix double free caused by loading strings from files

A null pointer assignment was missing after a free in commit 7148ce6 (MEDIUM:
pattern: Extract the index process from the pat_parse_*() functions), causing
a double free after loading a file of string patterns.

This bug was introduced in 1.5-dev20, no backport is needed.

Thanks to Sander Klein for reporting this bug and providing the config
needed to trigger it.

11 years agoMINOR: session: remove debugging code
Willy Tarreau [Mon, 16 Dec 2013 09:12:54 +0000 (10:12 +0100)] 
MINOR: session: remove debugging code

The memset() was put here to corrupt memory for a debugging test,
it's not needed anymore and was unfortunately committed. It does
not harm anyway, it probably just slightly affects performance.

11 years agoMINOR: stats: don't use a monospace font to report numbers
Willy Tarreau [Mon, 16 Dec 2013 08:00:35 +0000 (09:00 +0100)] 
MINOR: stats: don't use a monospace font to report numbers

On several browsers, the monospace font used to display numbers in tips
is not much readable. Since the numbers are aligned anyway, there is too
little benefit in using such a font.

11 years ago[RELEASE] Released version 1.5-dev20 v1.5-dev20
Willy Tarreau [Mon, 16 Dec 2013 01:32:37 +0000 (02:32 +0100)] 
[RELEASE] Released version 1.5-dev20

Released version 1.5-dev20 with the following main changes :
    - DOC: add missing options to the manpage
    - DOC: add manpage references to all system calls
    - DOC: update manpage reference to haproxy-en.txt
    - DOC: remove -s and -l options from the manpage
    - DOC: missing information for the "description" keyword
    - DOC: missing http-send-name-header keyword in keyword table
    - MINOR: tools: function my_memmem() to lookup binary contents
    - MEDIUM: checks: add send/expect tcp based check
    - MEDIUM: backend: Enhance hash-type directive with an algorithm options
    - MEDIUM: backend: Implement avalanche as a modifier of the hashing functions.
    - DOC: Documentation for hashing function, with test results.
    - BUG/MEDIUM: ssl: potential memory leak using verifyhost
    - BUILD: ssl: compilation issue with openssl v0.9.6.
    - BUG/MINOR: ssl: potential memory leaks using ssl_c_key_alg or ssl_c_sig_alg.
    - MINOR: ssl: optimization of verifyhost on wildcard certificates.
    - BUG/MINOR: ssl: verifyhost does not match empty strings on wildcard.
    - MINOR: ssl: Add statement 'verifyhost' to "server" statements
    - CLEANUP: session: remove event_accept() which was not used anymore
    - BUG/MINOR: deinit: free fdinfo while doing cleanup
    - DOC: minor typo fix in documentation
    - BUG/MEDIUM: server: set the macro for server's max weight SRV_UWGHT_MAX to SRV_UWGHT_RANGE
    - BUG/MINOR: use the same check condition for server as other algorithms
    - DOC: fix typo in comments
    - BUG/MINOR: deinit: free server map which is allocated in init_server_map()
    - CLEANUP: stream_interface: cleanup loop information in si_conn_send_loop()
    - MINOR: buffer: align the last output line of buffer_dump()
    - MINOR: buffer: align the last output line if there are less than 8 characters left
    - DOC: stick-table: modify the description
    - OPTIM: stream_interface: return directly if the connection flag CO_FL_ERROR has been set
    - CLEANUP: code style: use tabs to indent codes
    - DOC: checkcache: block responses with cacheable cookies
    - BUG/MINOR: check_config_validity: check the returned value of stktable_init()
    - MEDIUM: haproxy-systemd-wrapper: Use haproxy in same directory
    - MEDIUM: systemd-wrapper: Kill child processes when interrupted
    - LOW: systemd-wrapper: Write debug information to stdout
    - BUG/MINOR: http: fix "set-tos" not working in certain configurations
    - MEDIUM: http: add IPv6 support for "set-tos"
    - DOC: ssl: update build instructions to use new SSL_* variables
    - BUILD/MINOR: systemd: fix compiler warning about unused result
    - url32+src - like base32+src but whole url including parameters
    - BUG/MINOR: fix forcing fastinter in "on-error"
    - CLEANUP: Make parameters of srv_downtime and srv_getinter const
    - CLEANUP: Remove unused 'last_slowstart_change' field from struct peer
    - MEDIUM: Split up struct server's check element
    - MEDIUM: Move result element to struct check
    - MEDIUM: Paramatise functions over the check of a server
    - MEDIUM: cfgparse: Factor out check initialisation
    - MEDIUM: Add state to struct check
    - MEDIUM: Move health element to struct check
    - MEDIUM: Add helper for task creation for checks
    - MEDIUM: Add helper function for failed checks
    - MEDIUM: Log agent fail, stopped or down as info
    - MEDIUM: Remove option lb-agent-chk
    - MEDIUM: checks: Add supplementary agent checks
    - MEDIUM: Do not mark a server as down if the agent is unavailable
    - MEDIUM: Set rise and fall of agent checks to 1
    - MEDIUM: Add enable and disable agent unix socket commands
    - MEDIUM: Add DRAIN state and report it on the stats page
    - BUILD/MINOR: missing header file
    - CLEANUP: regex: Create regex_comp function that compiles regex using compilation options
    - CLEANUP: The function "regex_exec" needs the string length but in many case they expect null terminated char.
    - MINOR: http: some exported functions were not in the header file
    - MINOR: http: change url_decode to return the size of the decoded string.
    - BUILD/MINOR: missing header file
    - BUG/MEDIUM: sample: The function v4tov6 cannot support input and output overlap
    - BUG/MINOR: arg: fix error reporting for add-header/set-header sample fetch arguments
    - MINOR: sample: export the generic sample conversion parser
    - MINOR: sample: export sample_casts
    - MEDIUM: acl: use the fetch syntax 'fetch(args),conv(),conv()' into the ACL keyword
    - MINOR: stick-table: use smp_expr_output_type() to retrieve the output type of a "struct sample_expr"
    - MINOR: sample: provide the original sample_conv descriptor struct to the argument checker function.
    - MINOR: tools: Add a function to convert buffer to an ipv6 address
    - MINOR: acl: export acl arrays
    - MINOR: acl: Extract the pattern parsing and indexation from the "acl_read_patterns_from_file()" function
    - MINOR: acl: Extract the pattern matching function
    - MINOR: sample: Define new struct sample_storage
    - MEDIUM: acl: associate "struct sample_storage" to each "struct acl_pattern"
    - REORG: acl/pattern: extract pattern matching from the acl file and create pattern.c
    - MEDIUM: pattern: create pattern expression
    - MEDIUM: pattern: rename "acl" prefix to "pat"
    - MEDIUM: sample: let the cast functions set their output type
    - MINOR: sample: add a private field to the struct sample_conv
    - MINOR: map: Define map types
    - MEDIUM: sample: add the "map" converter
    - MEDIUM: http: The redirect strings follows the log format rules.
    - BUG/MINOR: acl: acl parser does not recognize empty converter list
    - BUG/MINOR: map: The map list was declared in the map.h file
    - MINOR: map: Cleanup the initialisation of map descriptors.
    - MEDIUM: map: merge identical maps
    - BUG/MEDIUM: pattern: Pattern node has type of "struct pat_idx_elt" in place of "struct eb_node"
    - BUG/MEDIUM: map: Bad map file parser
    - CLEANUP/MINOR: standard: use the system define INET6_ADDRSTRLEN in place of MAX_IP6_LEN
    - BUG/MEDIUM: sample: conversion from str to ipv6 may read data past end
    - MINOR: map: export map_get_reference() function
    - MINOR: pattern: Each pattern sets the expected input type
    - MEDIUM: acl: Last patch change the output type
    - MEDIUM: pattern: Extract the index process from the pat_parse_*() functions
    - MINOR: standard: The function parse_binary() can use preallocated buffer
    - MINOR: regex: Change the struct containing regex
    - MINOR: regex: Copy the original regex expression into string.
    - MINOR: pattern: add support for compiling patterns for lookups
    - MINOR: pattern: make the pattern matching function return a pointer to the matched element
    - MINOR: map: export parse output sample functions
    - MINOR: pattern: add function to lookup a specific entry in pattern list
    - MINOR: pattern/map: Each pattern must free the associated sample
    - MEDIUM: dumpstat: make the CLI parser understand the backslash as an escape char
    - MEDIUM: map: dynamic manipulation of maps
    - BUG/MEDIUM: unique_id: junk in log on empty unique_id
    - BUG/MINOR: log: junk at the end of syslog packet
    - MINOR: Makefile: provide cscope rule
    - DOC: compression: chunk are not compressed anymore
    - MEDIUM: session: disable lingering on the server when the client aborts
    - BUG/MEDIUM: prevent gcc from moving empty keywords lists into BSS
    - DOC: remove the comment saying that SSL certs are not checked on the server side
    - BUG: counters: third counter was not stored if others unset
    - BUG/MAJOR: http: don't emit the send-name-header when no server is available
    - BUG/MEDIUM: http: "option checkcache" fails with the no-cache header
    - BUG/MAJOR: http: sample prefetch code was not properly migrated
    - BUG/MEDIUM: splicing: fix abnormal CPU usage with splicing
    - BUG/MINOR: stream_interface: don't call chk_snd() on polled events
    - OPTIM: splicing: use splice() for the last block when relevant
    - MEDIUM: sample: handle comma-delimited converter list
    - MINOR: sample: fix sample_process handling of unstable data
    - CLEANUP: acl: move the 3 remaining sample fetches to samples.c
    - MINOR: sample: add a new "date" fetch to return the current date
    - MINOR: samples: add the http_date([<offset>]) sample converter.
    - DOC: minor improvements to the part on the stats socket.
    - MEDIUM: sample: systematically pass the keyword pointer to the keyword
    - MINOR: payload: split smp_fetch_rdp_cookie()
    - MINOR: counters: factor out smp_fetch_sc*_tracked
    - MINOR: counters: provide a generic function to retrieve a stkctr for sc* and src.
    - MEDIUM: counters: factor out smp_fetch_sc*_get_gpc0
    - MEDIUM: counters: factor out smp_fetch_sc*_gpc0_rate
    - MEDIUM: counters: factor out smp_fetch_sc*_inc_gpc0
    - MEDIUM: counters: factor out smp_fetch_sc*_clr_gpc0
    - MEDIUM: counters: factor out smp_fetch_sc*_conn_cnt
    - MEDIUM: counters: factor out smp_fetch_sc*_conn_rate
    - MEDIUM: counters: factor out smp_fetch_sc*_conn_cur
    - MEDIUM: counters: factor out smp_fetch_sc*_sess_cnt
    - MEDIUM: counters: factor out smp_fetch_sc*_sess_rate
    - MEDIUM: counters: factor out smp_fetch_sc*_http_req_cnt
    - MEDIUM: counters: factor out smp_fetch_sc*_http_req_rate
    - MEDIUM: counters: factor out smp_fetch_sc*_http_err_cnt
    - MEDIUM: counters: factor out smp_fetch_sc*_http_err_rate
    - MEDIUM: counters: factor out smp_fetch_sc*_kbytes_in
    - MEDIUM: counters: factor out smp_fetch_sc*_bytes_in_rate
    - MEDIUM: counters: factor out smp_fetch_sc*_kbytes_out
    - MEDIUM: counters: factor out smp_fetch_sc*_bytes_out_rate
    - MEDIUM: counters: factor out smp_fetch_sc*_trackers
    - MINOR: session: make the number of stick counter entries more configurable
    - MEDIUM: counters: support passing the counter number as a fetch argument
    - MEDIUM: counters: support looking up a key in an alternate table
    - MEDIUM: cli: adjust the method for feeding frequency counters in tables
    - MINOR: cli: make it possible to enter multiple values at once with "set table"
    - MINOR: payload: allow the payload sample fetches to retrieve arbitrary lengths
    - BUG/MINOR: cli: "clear table" must not kill entries that don't match condition
    - MINOR: ssl: use MAXPATHLEN instead of PATH_MAX
    - MINOR: config: warn when a server with no specific port uses rdp-cookie
    - BUG/MEDIUM: unique_id: HTTP request counter must be unique!
    - DOC: add a mention about the limited chunk size
    - BUG/MEDIUM: fix broken send_proxy on FreeBSD
    - MEDIUM: stick-tables: flush old entries upon soft-stop
    - MINOR: tcp: add new "close" action for tcp-response
    - MINOR: payload: provide the "res.len" fetch method
    - BUILD: add SSL_INC/SSL_LIB variables to force the path to openssl
    - MINOR: http: compute response time before processing headers
    - BUG/MINOR: acl: fix improper string size assignment in proxy argument
    - BUG/MEDIUM: http: accept full buffers on smp_prefetch_http
    - BUG/MINOR: acl: implicit arguments of ACL keywords were not properly resolved
    - BUG/MEDIUM: session: risk of crash on out of memory conditions
    - BUG/MINOR: peers: set the accept date in outgoing connections
    - BUG/MEDIUM: tcp: do not skip tracking rules on second pass
    - BUG/MEDIUM: acl: do not evaluate next terms after a miss
    - MINOR: acl: add a warning when an ACL keyword is used without any value
    - MINOR: tcp: don't use tick_add_ifset() when timeout is known to be set
    - BUG/MINOR: acl: remove patterns from the tree before freeing them
    - MEDIUM: backend: add support for the wt6 hash
    - OPTIM/MEDIUM: epoll: fuse active events into polled ones during polling changes
    - OPTIM/MINOR: mark the source address as already known on accept()
    - BUG/MINOR: stats: don't count tarpitted connections twice
    - CLEANUP: http: homogenize processing of denied req counter
    - CLEANUP: http: merge error handling for req* and http-request *
    - BUG/MEDIUM: http: fix possible parser crash when parsing erroneous "http-request redirect" rules
    - BUG/MINOR: http: fix build warning introduced with url32/url32_src
    - BUG/MEDIUM: checks: fix slow start regression after fix attempt
    - BUG/MAJOR: server: weight calculation fails for map-based algorithms
    - MINOR: stats: report correct throttling percentage for servers in slowstart
    - OPTIM: connection: fold the error handling with handshake handling
    - MINOR: peers: accept to learn strings of different lengths
    - BUG/MAJOR: fix haproxy crash when using server tracking instead of checks
    - BUG/MAJOR: check: fix haproxy crash during soft-stop/soft-start
    - BUG/MINOR: stats: do not report "via" on tracking servers in maintenance
    - BUG/MINOR: connection: fix typo in error message report
    - BUG/MINOR: backend: fix target address retrieval in transparent mode
    - BUG/MINOR: config: report the correct track-sc number in tcp-rules
    - BUG/MINOR: log: fix log-format parsing errors
    - DOC: add some information about how to apply converters to samples
    - MINOR: acl/pattern: use types different from int to clarify who does what.
    - MINOR: pattern: import acl_find_match_name() into pattern.h
    - MEDIUM: stick-tables: support automatic conversion from ipv4<->ipv6
    - MEDIUM: log-format: relax parsing of '%' followed by unsupported characters
    - BUG/MINOR: http: usual deinit stuff in last commit
    - BUILD: log: silent a warning about isblank() with latest patches
    - BUG/MEDIUM: checks: fix health check regression causing them to depend on declaration order
    - BUG/MEDIUM: checks: fix a long-standing issue with reporting connection errors
    - BUG/MINOR: checks: don't consider errno and use conn->err_code
    - BUG/MEDIUM: checks: also update the DRAIN state from the web interface
    - MINOR: stats: remove some confusion between the DRAIN state and NOLB
    - BUG/MINOR: tcp: check that no error is pending during a connect probe
    - BUG/MINOR: connection: check EINTR when sending a PROXY header
    - MEDIUM: connection: set the socket shutdown flags on socket errors
    - BUG/MEDIUM: acl: fix regression introduced by latest converters support
    - MINOR: connection: clear errno prior to checking for errors
    - BUG/MINOR: checks: do not trust errno in write event before any syscall
    - MEDIUM: checks: centralize error reporting
    - OPTIM: checks: don't poll on recv when using plain TCP connects
    - OPTIM: checks: avoid setting SO_LINGER twice
    - MINOR: tools: add a generic binary hex string parser
    - BUG/MEDIUM: checks: tcp-check: do not poll when there's nothing to send
    - BUG/MEDIUM: check: tcp-check might miss some outgoing data when socket buffers are full
    - BUG/MEDIUM: args: fix double free on error path in argument expression parser
    - BUG/MINOR: acl: fix sample expression error reporting
    - BUG/MINOR: checks: tcp-check actions are enums, not flags
    - MEDIUM: checks: make tcp-check perform multiple send() at once
    - BUG/MEDIUM: stick: completely remove the unused flag from the store entries
    - OPTIM: ebtree: pack the struct eb_node to avoid holes on 64-bit
    - BUG/MEDIUM: stick-tables: complete the latest fix about store-responses
    - CLEANUP: stream_interface: remove unused field err_loc
    - MEDIUM: stats: don't use conn->xprt_st anymore
    - MINOR: session: add a simple function to retrieve a session from a task
    - MEDIUM: stats: don't use conn->xprt_ctx anymore
    - MEDIUM: peers: don't rely on conn->xprt_ctx anymore
    - MINOR: http: prevent smp_fetch_url_{ip,port} from using si->conn
    - MINOR: connection: make it easier to emit proxy protocol for unknown addresses
    - MEDIUM: stats: prepare the HTTP stats I/O handler to support more states
    - MAJOR: stats: move the HTTP stats handling to its applet
    - MEDIUM: stats: move request argument processing to the final step
    - MEDIUM: session: detect applets from the session by using s->target
    - MAJOR: session: check for a connection to an applet in sess_prepare_conn_req()
    - MAJOR: session: pass applet return traffic through the response analysers
    - MEDIUM: stream-int: split the shutr/shutw functions between applet and conn
    - MINOR: stream-int: make the shutr/shutw functions void
    - MINOR: obj: provide a safe and an unsafe access to pointed objects
    - MINOR: connection: add a field to store an object type
    - MINOR: connection: always initialize conn->objt_type to OBJ_TYPE_CONN
    - MEDIUM: stream interface: move the peers' ptr into the applet context
    - MINOR: stream-interface: move the applet context to its own struct
    - MINOR: obj: introduce a new type appctx
    - MINOR: stream-int: rename ->applet to ->appctx
    - MINOR: stream-int: split si_prepare_embedded into si_prepare_none and si_prepare_applet
    - MINOR: stream-int: add a new pointer to the end point
    - MEDIUM: stream-interface: set the pointer to the applet into the applet context
    - MAJOR: stream interface: remove the ->release function pointer
    - MEDIUM: stream-int: make ->end point to the connection or the appctx
    - CLEANUP: stream-int: remove obsolete si_ctrl function
    - MAJOR: stream-int: stop using si->conn and use si->end instead
    - MEDIUM: stream-int: do not allocate a connection in parallel to applets
    - MEDIUM: session: attach incoming connection to target on embryonic sessions
    - MINOR: connection: add conn_init() to (re)initialize a connection
    - MINOR: checks: call conn_init() to properly initialize the connection.
    - MINOR: peers: make use of conn_init() to initialize the connection
    - MINOR: session: use conn_init() to initialize the connections
    - MINOR: http: use conn_init() to reinitialize the server connection
    - MEDIUM: connection: replace conn_prepare with conn_assign
    - MINOR: get rid of si_takeover_conn()
    - MINOR: connection: add conn_new() / conn_free()
    - MAJOR: connection: add two new flags to indicate readiness of control/transport
    - MINOR: stream-interface: introduce si_reset() and si_set_state()
    - MINOR: connection: reintroduce conn_prepare to set the protocol and transport
    - MINOR: connection: replace conn_assign with conn_attach
    - MEDIUM: stream-interface: introduce si_attach_conn to replace si_prepare_conn
    - MAJOR: stream interface: dynamically allocate the outgoing connection
    - MEDIUM: connection: move the send_proxy offset to the connection
    - MINOR: connection: check for send_proxy during the connect(), not the SI
    - MEDIUM: connection: merge the send_proxy and local_send_proxy calls
    - MEDIUM: stream-int: replace occurrences of si->appctx with si_appctx()
    - MEDIUM: stream-int: return the allocated appctx in stream_int_register_handler()
    - MAJOR: stream-interface: dynamically allocate the applet context
    - MEDIUM: session: automatically register the applet designated by the target
    - MEDIUM: stats: delay appctx initialization
    - CLEANUP: peers: use less confusing state/status code names
    - MEDIUM: peers: delay appctx initialization
    - MINOR: stats: provide some appctx information in "show sess all"
    - DIET/MINOR: obj: pack the obj_type enum to 8 bits
    - DIET/MINOR: connection: rearrange a few fields to save 8 bytes in the struct
    - DIET/MINOR: listener: rearrange a few fields in struct listener to save 16 bytes
    - DIET/MINOR: proxy: rearrange a few fields in struct proxy to save 16 bytes
    - DIET/MINOR: session: reduce the struct session size by 8 bytes
    - DIET/MINOR: stream-int: rearrange a few fields in struct stream_interface to save 8 bytes
    - DIET/MINOR: http: reduce the size of struct http_txn by 8 bytes
    - MINOR: http: switch the http state to an enum
    - MINOR: http: use an enum for the auth method in http_auth_data
    - DIET/MINOR: task: reduce struct task size by 8 bytes
    - MINOR: stream_interface: add reporting of ressouce allocation errors
    - MINOR: session: report lack of resources using the new stream-interface's error code
    - BUILD: simplify the date and version retrieval in the makefile
    - BUILD: prepare the makefile to skip format lines in SUBVERS and VERDATE
    - BUILD: use format tags in VERDATE and SUBVERS files
    - BUG/MEDIUM: channel:  bo_getline() must wait for \n until buffer is full
    - CLEANUP: check: server port is unsigned
    - BUG/MEDIUM: checks: agent doesn't get the response if server does not closes
    - MINOR: tools: buf2ip6 must not modify output on failure
    - MINOR: pattern: do not assign SMP_TYPES by default to patterns
    - MINOR: sample: make sample_parse_expr() use memprintf() to report parse errors
    - MINOR: arg: improve wording on error reporting
    - BUG/MEDIUM: sample: simplify and fix the argument parsing
    - MEDIUM: acl: fix the argument parser to let the lower layer report detailed errors
    - MEDIUM: acl: fix the initialization order of the ACL expression
    - CLEANUP: acl: remove useless blind copy-paste from sample converters
    - TESTS: add regression tests for ACL and sample expression parsers
    - BUILD: time: adapt the type of TV_ETERNITY to the local system
    - MINOR: chunks: allocate the trash chunks before parsing the config
    - BUILD: definitely silence some stupid GCC warnings
    - MINOR: chunks: always initialize the output chunk in get_trash_chunk()
    - MINOR: checks: improve handling of the servers tracking chain
    - REORG: checks: retrieve the check-specific defines from server.h to checks.h
    - MINOR: checks: use an enum instead of flags to report a check result
    - MINOR: checks: rename the state flags
    - MINOR: checks: replace state DISABLED with CONFIGURED and ENABLED
    - MINOR: checks: use check->state instead of srv->state & SRV_CHECKED
    - MINOR: checks: fix agent check interval computation
    - MINOR: checks: add a PAUSED state for the checks
    - MINOR: checks: create the agent tasks even when no check is configured
    - MINOR: checks: add a flag to indicate what check is an agent
    - MEDIUM: checks: enable agent checks even if health checks are disabled
    - BUG/MEDIUM: checks: ensure we can enable a server after boot
    - BUG/MEDIUM: checks: tracking servers must not inherit the MAINT flag
    - BUG/MAJOR: session: repair tcp-request connection rules
    - BUILD: fix SUBVERS extraction in the Makefile
    - BUILD: pattern: silence a warning about uninitialized value
    - BUILD: log: fix build warning on Solaris
    - BUILD: dumpstats: fix build error on Solaris
    - DOC: move option pgsql-check to the correct place
    - DOC: move option tcp-check to the proper place
    - MINOR: connection: add simple functions to report connection readiness
    - MEDIUM: connection: centralize handling of nolinger in fd management
    - OPTIM: http: set CF_READ_DONTWAIT on response message
    - OPTIM: http: do not re-enable reading on client side while closing the server side
    - MINOR: config: add option http-keep-alive
    - MEDIUM: connection: inform si_alloc_conn() whether existing conn is OK or not
    - MAJOR: stream-int: handle the connection reuse in si_connect()
    - MAJOR: http: add the keep-alive transition on the server side
    - MAJOR: backend: enable connection reuse
    - MINOR: http: add option prefer-last-server
    - MEDIUM: http: do not report connection errors for second and further requests

11 years agoMEDIUM: http: do not report connection errors for second and further requests
Willy Tarreau [Sun, 15 Dec 2013 18:31:37 +0000 (19:31 +0100)] 
MEDIUM: http: do not report connection errors for second and further requests

In HTTP keep-alive, if we face a connection error to the server while sending
the request, the error should not be reported, and the client-side connection
should simply be closed, so that client knows it can retry. This can happen if
the server has too short a keep-alive timeout and quits at the same moment the
new request comes in.

11 years agoMINOR: http: add option prefer-last-server
Willy Tarreau [Sun, 15 Dec 2013 17:58:25 +0000 (18:58 +0100)] 
MINOR: http: add option prefer-last-server

When the load balancing algorithm in use is not deterministic, and a previous
request was sent to a server to which haproxy still holds a connection, it is
sometimes desirable that subsequent requests on a same session go to the same
server as much as possible. Note that this is different from persistence, as
we only indicate a preference which haproxy tries to apply without any form
of warranty. The real use is for keep-alive connections sent to servers. When
this option is used, haproxy will try to reuse the same connection that is
attached to the server instead of rebalancing to another server, causing a
close of the connection. This can make sense for static file servers. It does
not make much sense to use this in combination with hashing algorithms.

11 years agoMAJOR: backend: enable connection reuse
Willy Tarreau [Sun, 15 Dec 2013 15:33:46 +0000 (16:33 +0100)] 
MAJOR: backend: enable connection reuse

This commit allows an existing server-side connection to be reused if
it matches the same target. Basic controls are performed ; right now
we do not allow to reuse a connection when dynamic source binding is
in use or when the destination address or port is dynamic (eg: proxy
mode). Later we'll have to also disable connection sharing when PROXY
protocol is being used or when non-idempotent requests are processed.

11 years agoMAJOR: http: add the keep-alive transition on the server side
Willy Tarreau [Sun, 15 Dec 2013 09:25:42 +0000 (10:25 +0100)] 
MAJOR: http: add the keep-alive transition on the server side

When a connection to the server is complete, if the transaction
requests keep-alive mode, we don't shut the connection and we just
reinitialize the stream interface in order to be able to reuse the
connection afterwards.

Note that the server connection count is decremented, just like the
backend's, and that we still try to wake up waiters. But that makes
sense considering that we'll eventually be able to immediately pass
idle connections to waiters.

11 years agoMAJOR: stream-int: handle the connection reuse in si_connect()
Willy Tarreau [Sun, 15 Dec 2013 15:20:50 +0000 (16:20 +0100)] 
MAJOR: stream-int: handle the connection reuse in si_connect()

This is the best place to reuse a connection. We centralize all
connection requests and we're at the best place to know exactly
what the current state of the underlying connection is. If the
connection is reused, we just enable polling for send() in order
to be able to emit the request.

11 years agoMEDIUM: connection: inform si_alloc_conn() whether existing conn is OK or not
Willy Tarreau [Sun, 15 Dec 2013 12:31:35 +0000 (13:31 +0100)] 
MEDIUM: connection: inform si_alloc_conn() whether existing conn is OK or not

When allocating a new connection, only the caller knows whether it's
acceptable to reuse the previous one or not. Let's pass this information
to si_alloc_conn() which will do the cleanup if the connection is not
acceptable.

11 years agoMINOR: config: add option http-keep-alive
Willy Tarreau [Sat, 16 Jan 2010 18:48:41 +0000 (19:48 +0100)] 
MINOR: config: add option http-keep-alive

This new option enables HTTP keep-alive processing on the connections.
It can be overwritten by http-server-close, httpclose and forceclose.
Right now full-chain keep-alive is not yet implemented, but we need
the option to work on it. The doc will come later.

11 years agoOPTIM: http: do not re-enable reading on client side while closing the server side
Willy Tarreau [Sun, 15 Dec 2013 14:32:10 +0000 (15:32 +0100)] 
OPTIM: http: do not re-enable reading on client side while closing the server side

It's common to observe a an recv() call on the client side just after
the connect() to has been issued to the server side when running in
server close mode. The reason is that the whole request has been sent
and the shutw() has been queued in the channel, so the request message
switches to the MSG_CLOSED state, which didn't disable reading. Let's
do it now. That way the reading will only be re-enabled after the
response is transferred to the client. However if abortonclose is set,
we still leave it enabled.

11 years agoOPTIM: http: set CF_READ_DONTWAIT on response message
Willy Tarreau [Sun, 15 Dec 2013 14:21:32 +0000 (15:21 +0100)] 
OPTIM: http: set CF_READ_DONTWAIT on response message

strace shows a lot of EAGAIN on small response messages. This
is caused by the fact that the READ_DONTWAIT flag is not set
on response message, it's only there when we want to flush
pending data.

For small responses, it's a waste of CPU cycles to call recv()
for nothing since most of the time, everything we'll need will
be in the first response. Also, this will offer more opportunities
for using splice() to transfer data.

11 years agoMEDIUM: connection: centralize handling of nolinger in fd management
Willy Tarreau [Sun, 15 Dec 2013 13:19:38 +0000 (14:19 +0100)] 
MEDIUM: connection: centralize handling of nolinger in fd management

Right now we see many places doing their own setsockopt(SO_LINGER).
Better only do it just before the close() in fd_delete(). For this
we add a new flag on the file descriptor, indicating if it's safe or
not to linger. If not (eg: after a connect()), then the setsockopt()
call is automatically performed before a close().

The flag automatically turns to safe when receiving a read0.

11 years agoMINOR: connection: add simple functions to report connection readiness
Willy Tarreau [Sun, 15 Dec 2013 09:23:20 +0000 (10:23 +0100)] 
MINOR: connection: add simple functions to report connection readiness

conn_xprt_ready() reports if the transport layer is ready.
conn_ctrl_ready() reports if the control layer is ready.

The stream interface uses si_conn_ready() to report that the
underlying connection is ready. This will be used for connection
reuse in keep-alive mode.

11 years agoDOC: move option tcp-check to the proper place
Willy Tarreau [Mon, 16 Dec 2013 00:07:00 +0000 (01:07 +0100)] 
DOC: move option tcp-check to the proper place

It was not alphabetically sorted.

11 years agoDOC: move option pgsql-check to the correct place
Willy Tarreau [Sun, 15 Dec 2013 17:49:01 +0000 (18:49 +0100)] 
DOC: move option pgsql-check to the correct place

This one was not alphabetically sorted.

11 years agoBUILD: dumpstats: fix build error on Solaris
Willy Tarreau [Mon, 16 Dec 2013 00:42:03 +0000 (01:42 +0100)] 
BUILD: dumpstats: fix build error on Solaris

Since the recent addition of map updates, haproxy does not build anymore
on Solaris because "s_addr" is a #define :

src/dumpstats.c: In function `stats_map_lookup':
src/dumpstats.c:4688: error: syntax error before '.' token
src/dumpstats.c:4781: error: `S_un' undeclared (first use in this function)
src/dumpstats.c:4781: error: (Each undeclared identifier is reported only once
src/dumpstats.c:4781: error: for each function it appears in.)
make: *** [src/dumpstats.o] Error 1

Simply rename the variable.

11 years agoBUILD: log: fix build warning on Solaris
Willy Tarreau [Mon, 16 Dec 2013 00:38:33 +0000 (01:38 +0100)] 
BUILD: log: fix build warning on Solaris

The is* macros must not use a char on Solaris. Unsigned char is OK.
Casting char to int is wrong as well since we get a negative value.

  src/log.c: In function `parse_logformat_string':
  src/log.c:454: warning: subscript has type `char'

11 years agoBUILD: pattern: silence a warning about uninitialized value
Willy Tarreau [Sun, 15 Dec 2013 15:42:26 +0000 (16:42 +0100)] 
BUILD: pattern: silence a warning about uninitialized value

Gcc 3.4 warns that mask may be used uninitialized in pattern.c. This
is wrong since it's used in the same condition as its assignment,
although it's not necessarily obvious for the compiler. Fix this by
initializing the value.

This was introduced by recent commit 01cdcd4a so no backport is needed.

11 years agoBUILD: fix SUBVERS extraction in the Makefile
Willy Tarreau [Mon, 16 Dec 2013 00:34:39 +0000 (01:34 +0100)] 
BUILD: fix SUBVERS extraction in the Makefile

We'd rather skip any line containing "$Format" and not just those
beginning with it because SUBVERS starts with a dash and caused a
bad format to be reported.

11 years agoBUG/MAJOR: session: repair tcp-request connection rules
Willy Tarreau [Mon, 16 Dec 2013 01:16:50 +0000 (02:16 +0100)] 
BUG/MAJOR: session: repair tcp-request connection rules

Since recent commit f79c817 (MAJOR: connection: add two new flags to
indicate readiness of control/transport) and the surrounding commits,
the session initialization has been slightly delayed and the control
layer of the connection is not yet initialized when processing the
rules.

We need to move that minimal initialization a bit above.

The bug was introduced with latest changes, no backport is needed.

11 years agoBUG/MEDIUM: checks: tracking servers must not inherit the MAINT flag
Willy Tarreau [Sat, 14 Dec 2013 15:16:01 +0000 (16:16 +0100)] 
BUG/MEDIUM: checks: tracking servers must not inherit the MAINT flag

If a server is disabled in configuration and another one tracks it,
this last one must not inherit the MAINT flag otherwise it needs to
be explicitly enabled afterwards. Just remove this to fix the issue.

11 years agoBUG/MEDIUM: checks: ensure we can enable a server after boot
Willy Tarreau [Sat, 14 Dec 2013 15:14:15 +0000 (16:14 +0100)] 
BUG/MEDIUM: checks: ensure we can enable a server after boot

Since commit 58c3297 (MEDIUM: Set rise and fall of agent checks to 1),
due to a bogus condition, it became impossible to re-enable a server
that was disabled in the configuration if no agent was enabled. The
reason is that in this case, the agent's health was zero while the
condition expected it to be at least one to consider the action.

Let's fix this by only considering the health of checks that are enabled.

11 years agoMEDIUM: checks: enable agent checks even if health checks are disabled
Willy Tarreau [Wed, 11 Dec 2013 20:26:24 +0000 (21:26 +0100)] 
MEDIUM: checks: enable agent checks even if health checks are disabled

The agent is able to retrieve some weight information from the server
and will eventually be able to force the server into maintenance mode.
It doesn't seem logical to have it depend on the health check being
configured, as for some servers it might very well make sense to only
fetch the weight from the server's load regardless of the health.

So let's stop disabling the agent checks when health checks are disabled.

11 years agoMINOR: checks: add a flag to indicate what check is an agent
Willy Tarreau [Wed, 11 Dec 2013 20:15:19 +0000 (21:15 +0100)] 
MINOR: checks: add a flag to indicate what check is an agent

Currently to know if a check is an agent, we compare its pointer to its
servers' agent pointer. Better have a flag in its state to indicate this.

11 years agoMINOR: checks: create the agent tasks even when no check is configured
Willy Tarreau [Wed, 11 Dec 2013 20:10:14 +0000 (21:10 +0100)] 
MINOR: checks: create the agent tasks even when no check is configured

Till now, a configuration required at least one health check in the
whole config file to create the agent tasks. Now we start them even
if no health check is enabled.

11 years agoMINOR: checks: add a PAUSED state for the checks
Willy Tarreau [Wed, 11 Dec 2013 20:03:31 +0000 (21:03 +0100)] 
MINOR: checks: add a PAUSED state for the checks

Health checks can now be paused. This is the status they get when the
server is put into maintenance mode, which is more logical than relying
on the server's state at some places. It will be needed to allow agent
checks to run when health checks are disabled (currently not possible).

11 years agoMINOR: checks: fix agent check interval computation
Willy Tarreau [Wed, 11 Dec 2013 19:41:18 +0000 (20:41 +0100)] 
MINOR: checks: fix agent check interval computation

start_checks() only used to consider the health checks intervals to
compute the start interval, so if an agent had a faster check than
all health checks, it would be significantly delayed.

11 years agoMINOR: checks: use check->state instead of srv->state & SRV_CHECKED
Willy Tarreau [Wed, 11 Dec 2013 19:36:34 +0000 (20:36 +0100)] 
MINOR: checks: use check->state instead of srv->state & SRV_CHECKED

Having the check state partially stored in the server doesn't help.
Some functions such as srv_getinter() rely on the server being checked
to decide what check frequency to use, instead of relying on the check
being configured. So let's get rid of SRV_CHECKED and SRV_AGENT_CHECKED
and only use the check's states instead.

11 years agoMINOR: checks: replace state DISABLED with CONFIGURED and ENABLED
Willy Tarreau [Wed, 11 Dec 2013 19:11:55 +0000 (20:11 +0100)] 
MINOR: checks: replace state DISABLED with CONFIGURED and ENABLED

At the moment, health checks and agent checks are tied : no agent
check is emitted if no health check is enabled. Other parameters
are considered in the condition for letting checks run. It will
help us selectively enable checks (agent and regular checks) to be
know whether they're enabled/disabled and configured or not. Now
we can already emit an error when trying to enable an unconfigured
agent.

11 years agoMINOR: checks: rename the state flags
Willy Tarreau [Wed, 11 Dec 2013 18:41:16 +0000 (19:41 +0100)] 
MINOR: checks: rename the state flags

The flag CHK_STATE_RUNNING is misleading as one may believe it means
the state is enabled (just like SRV_RUNNING). Let's rename these two
flags CHK_ST_INPROGRESS and CHK_ST_DISABLED.