]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
16 years ago[MAJOR] completely separate HTTP and TCP states on the request path
Willy Tarreau [Mon, 11 Aug 2008 21:42:50 +0000 (23:42 +0200)] 
[MAJOR] completely separate HTTP and TCP states on the request path

For the first time, HTTP and TCP are not merged anymore. All request
processing has moved to process_request while the TCP processing of
the frontend remains in process_cli. The code is a lot cleaner,
simpler, smaller (1%) and slightly faster (1% too).

Right now, the HTTP state machine cannot easily command the TCP
state machine, but it does not cause that many difficulties.

The response processing has not yet been extracted, and the unix-stream
state machines have to be broken down that way too.

The CL_STDATA, CL_STSHUTR and CL_STSHUTW states still exist and are
exactly the sames. They will have to be all merged into CL_STDATA
once the work has stabilized. It is also possible that this single
state will disappear in favor of just buffer flags.

16 years ago[MEDIUM] simplify and centralize request timeout cancellation and request forwarding
Willy Tarreau [Mon, 11 Aug 2008 15:35:01 +0000 (17:35 +0200)] 
[MEDIUM] simplify and centralize request timeout cancellation and request forwarding

Instead of playing with req->flags and request timeout everywhere,
tweak them only at precise locations.

16 years ago[MAJOR] get rid of SV_STANALYZE (step 2)
Willy Tarreau [Mon, 11 Aug 2008 13:24:42 +0000 (15:24 +0200)] 
[MAJOR] get rid of SV_STANALYZE (step 2)

The SV_STANALYZE state was installed on the server side but was really
meant to be processed with the rest of the request on the client side.
It suffered from several issues, mostly related to the way timeouts were
handled while waiting for data.

All known issues related to timeouts during a request - and specifically
a request involving body processing - have been raised and fixed. At this
point, the code is a bit dirty but works fine, so next steps might be
cleanups with an ability to come back to the current state in case of
trouble.

16 years ago[MAJOR] kill CL_STINSPECT and CL_STHEADERS (step 1)
Willy Tarreau [Sun, 10 Aug 2008 20:55:22 +0000 (22:55 +0200)] 
[MAJOR] kill CL_STINSPECT and CL_STHEADERS (step 1)

This is a first attempt at separating data processing from the
TCP state machine. Those two states have been replaced with flags
in the session indicating what needs to be analyzed. The corresponding
code is still called before and in lieu of TCP states.

Next change should get rid of the specific SV_STANALYZE which is in
fact a client state.

Then next change should consist in making it possible to analyze
TCP contents while being in CL_STDATA (or CL_STSHUT*).

16 years ago[PATCH] appsessions: cleanup DEBUG_HASH and initialize request_counter
Aleksandar Lazic [Wed, 13 Aug 2008 17:57:02 +0000 (19:57 +0200)] 
[PATCH] appsessions: cleanup DEBUG_HASH and initialize request_counter

This patch cleanup the -DDEBUG=DEBUG_HASH output setting and initialize
the request_counter for the appsessions.

16 years ago[BUG] client timeout incorrectly rearmed while waiting for server
Willy Tarreau [Mon, 11 Aug 2008 09:20:03 +0000 (11:20 +0200)] 
[BUG] client timeout incorrectly rearmed while waiting for server

Client timeout could be refreshed in stream_sock_*, but this is
undesired when the timeout is already set to eternity. The effect
is that a session could still be aborted if client timeout was
smaller than server timeout. A second effect is that sessions
expired on the server side would expire with "cD" flags.

The fix consists in not updating it if it was not previously set.
A cleaner method might consist in updating the buffer timeout. This
is probably what will be done later when the state machines only
deal with the buffers.

16 years ago[BUG] server timeout was not considered in some circumstances
Willy Tarreau [Mon, 11 Aug 2008 08:35:07 +0000 (10:35 +0200)] 
[BUG] server timeout was not considered in some circumstances

Due to a copy-paste typo, the client timeout was refreshed instead
of the server's when waiting for server response. This means that
the server's timeout remained eternity.

16 years ago[BUG] fix segfault with url_param + check_post
Willy Tarreau [Sun, 10 Aug 2008 22:21:56 +0000 (00:21 +0200)] 
[BUG] fix segfault with url_param + check_post

If an HTTP/0.9-like POST request is sent to haproxy while
configured with url_param + check_post, it will crash. The
reason is that the total buffer length was computed based
on req->total (which equals the number of bytes read) and
not req->l (number of bytes in the buffer), thus leading
to wrong size calculations when calling memchr().

The affected code does not look like it could have been
exploited to run arbitrary code, only reads were performed
at wrong locations.

16 years ago[MEDIUM] process_cli: don't rely at all on server state
Willy Tarreau [Sun, 10 Aug 2008 14:21:32 +0000 (16:21 +0200)] 
[MEDIUM] process_cli: don't rely at all on server state

A new buffer flag BF_MAY_FORWARD has been added so that the client
FSM can check whether it is allowed to forward the response to the
client. The client FSM does not have to monitor the server state
anymore.

16 years ago[MEDIUM] process_srv: don't rely at all on client state
Willy Tarreau [Sun, 3 Aug 2008 18:38:13 +0000 (20:38 +0200)] 
[MEDIUM] process_srv: don't rely at all on client state

A new buffer flag BF_MAY_CONNECT has been added so that the server
FSM can check whether it is allowed to establish a connection or
not. That way, the client FSM only has to move this flag and the
server side does not need to monitor client state anymore.

16 years ago[MEDIUM] process_srv: rely on buffer flags for client shutdown
Willy Tarreau [Sun, 3 Aug 2008 17:15:35 +0000 (19:15 +0200)] 
[MEDIUM] process_srv: rely on buffer flags for client shutdown

The open/close nature of each half of the client side is known
to the buffer, so let the server state machine rely on this
instead of checking the client state for CL_STSHUT* or
CL_STCLOSE.

16 years ago[MEDIUM] buffers: ensure buffer_shut* are properly called upon shutdowns
Willy Tarreau [Sun, 3 Aug 2008 15:25:14 +0000 (17:25 +0200)] 
[MEDIUM] buffers: ensure buffer_shut* are properly called upon shutdowns

It is important that buffer states reflect the state of both sides so
that we can remove client and server state inter-dependencies.

16 years ago[MEDIUM] memory: update pool_free2() to support NULL pointers
Willy Tarreau [Sun, 3 Aug 2008 15:41:33 +0000 (17:41 +0200)] 
[MEDIUM] memory: update pool_free2() to support NULL pointers

In order to make pool usage more convenient, let pool_free2()
support NULL pointers by doing nothing, just like the standard
free(3) call does.

The various call places have been updated to remove the now
useless checks.

16 years ago[CLEANUP] remove 65 useless NULL checks before free
Willy Tarreau [Sun, 3 Aug 2008 10:19:50 +0000 (12:19 +0200)] 
[CLEANUP] remove 65 useless NULL checks before free

C specification clearly states that free(NULL) is a no-op.
So remove useless checks before calling free.

16 years ago[MINOR] permit renaming of x-forwarded-for header
Ross West [Sun, 3 Aug 2008 08:51:45 +0000 (10:51 +0200)] 
[MINOR] permit renaming of x-forwarded-for header

Because I needed it in my situation - here's a quick patch to
allow changing of the "x-forwarded-for" header by using a suboption to
"option forwardfor".

Suboption "header XYZ" will set the header from "x-forwarded-for" to "XYZ".

Default is still "x-forwarded-for" if the header value isn't defined.
Also the suboption 'except a.b.c.d/z' still works on the same line.

So it's now: option forwardfor [except a.b.c.d[/z]] [header XYZ]

16 years ago[MEDIUM] acl: when possible, report the name and requirements of ACLs in warnings
Willy Tarreau [Sun, 27 Jul 2008 20:02:32 +0000 (22:02 +0200)] 
[MEDIUM] acl: when possible, report the name and requirements of ACLs in warnings

When an ACL is referenced at a wrong place (eg: response during request, layer7
during layer4), try to indicate precisely the name and requirements of this ACL.

Only the first faulty ACL is returned. A small change consisting in iterating
that way may improve reports :
   cap = ACL_USE_any_unexpected
   while ((acl=cond_find_require(cond, cap))) {
     warning()
     cap &= ~acl->requires;
   }

This will report the first ACL of each unsupported type. But doing so will
mangle the error reporting a lot, so we need to rework error reports first.

17 years ago[MEDIUM] acl: set types on all currently known ACL verbs
Willy Tarreau [Fri, 25 Jul 2008 17:31:03 +0000 (19:31 +0200)] 
[MEDIUM] acl: set types on all currently known ACL verbs

All currently known ACL verbs have been assigned a type which makes
it possible to detect inconsistencies, such as response values used
in request rules.

17 years ago[MEDIUM] acl: enforce ACL type checking
Willy Tarreau [Fri, 25 Jul 2008 17:13:19 +0000 (19:13 +0200)] 
[MEDIUM] acl: enforce ACL type checking

ACL now hold information on the availability of the data they rely
on. They can indicate which parts of the requests/responses they
require, and the rules parser may now report inconsistencies.

As an example, switching rules are now checked for response-specific
ACLs, though those are not still set. A warning is reported in case
of mismatch. ACLs keyword restrictions will now have to be specifically
set wherever a better control is expected.

The line number where an ACL condition is declared has been added to
the conditions in order to be able to report the faulty line number
during post-loading checks.

17 years ago[MINOR] acl: add the "wait_end" acl verb
Willy Tarreau [Sun, 20 Jul 2008 09:18:28 +0000 (11:18 +0200)] 
[MINOR] acl: add the "wait_end" acl verb

The new "wait_end" acl delays evaluation of the rule (and the next ones)
to the end of the analysis period. This is intented to be used with TCP
content analysis. A rule referencing such an ACL will not match until
the delay is over. An equivalent default ACL "WAIT_END" has been created.

17 years ago[MEDIUM] acl: get rid of dummy values in always_true/always_false
Willy Tarreau [Sun, 20 Jul 2008 08:39:22 +0000 (10:39 +0200)] 
[MEDIUM] acl: get rid of dummy values in always_true/always_false

make use of last change in order to get rid of dummy values in
always_true/always_false.

17 years ago[MEDIUM] acl: permit fetch() functions to set the result themselves
Willy Tarreau [Sun, 20 Jul 2008 08:13:37 +0000 (10:13 +0200)] 
[MEDIUM] acl: permit fetch() functions to set the result themselves

For protocol analysis, it's not always convenient to have to run through
a fetch then a match against dummy values. It's easier to let the fetch()
function set the result itself. This obviously works only for boolean
values.

17 years ago[MINOR] acl: add REQ_CONTENT to the list of default acls
Willy Tarreau [Sun, 20 Jul 2008 07:29:50 +0000 (09:29 +0200)] 
[MINOR] acl: add REQ_CONTENT to the list of default acls

With content inspection, checking the presence of data in the
request buffer is very important. It's getting boring to always
add such an ACL, so let's add it by default.

17 years ago[DOC] document the new "tcp-request" keyword and associated ACLs
Willy Tarreau [Wed, 16 Jul 2008 16:36:06 +0000 (18:36 +0200)] 
[DOC] document the new "tcp-request" keyword and associated ACLs

The update concerns :
  - tcp-request inspect-delay
  - tcp-request accept
  - tcp-request reject
  - acl ... req_len
  - acl ... req_ssl_ver

17 years ago[CLEANUP] remove dependency on obsolete INTBITS macro
Willy Tarreau [Mon, 14 Jul 2008 22:36:31 +0000 (00:36 +0200)] 
[CLEANUP] remove dependency on obsolete INTBITS macro

The INTBITS macro was found to be already defined on some platforms,
and to equal 32 (while INTBITS was 5 here). Due to pure luck, there
was no declaration conflict, but it's nonetheless a problem to fix.

Looking at the code showed that this macro was only used for left
shifts and nothing else anymore. So the replacement is obvious. The
new macro, BITS_PER_INT is more obviously correct.

17 years ago[CLEANUP] remove many #include <types/xxx> from C files
Willy Tarreau [Mon, 14 Jul 2008 22:22:45 +0000 (00:22 +0200)] 
[CLEANUP] remove many #include <types/xxx> from C files

It should be stated as a rule that a C file should never
include types/xxx.h when proto/xxx.h exists, as it gives
less exposure to declaration conflicts (one of which was
caught and fixed here) and it complicates the file headers
for nothing.

Only types/global.h, types/capture.h and types/polling.h
have been found to be valid includes from C files.

17 years ago[CLEANUP] remove unused include/types/client.h
Willy Tarreau [Mon, 14 Jul 2008 21:57:33 +0000 (23:57 +0200)] 
[CLEANUP] remove unused include/types/client.h

This file is not used anymore.

17 years ago[MINOR] acl: add req_ssl_ver in TCP, to match an SSL version
Willy Tarreau [Tue, 15 Jul 2008 16:58:05 +0000 (18:58 +0200)] 
[MINOR] acl: add req_ssl_ver in TCP, to match an SSL version

This new keyword matches an dotted version mapped into an integer.
It permits to match an SSL message protocol version just as if it
was an integer, so that it is easy to map ranges, like this :

acl obsolete_ssl  req_ssl_ver   lt 3
acl correct_ssl   req_ssl_ver   3.0-3.1
acl invalid_ssl   req_ssl_ver   gt 3.1

Both SSLv2 hello messages and SSLv3 messages are supported. The
test tries to be strict enough to avoid being easily fooled. In
particular, it waits for as many bytes as announced in the message
header if this header looks valid (bound to the buffer size).

The same decoder will be usable with minor changes to check the
response messages.

17 years ago[MINOR] acl: add a new parsing function: parse_dotted_ver
Willy Tarreau [Tue, 15 Jul 2008 14:05:33 +0000 (16:05 +0200)] 
[MINOR] acl: add a new parsing function: parse_dotted_ver

This new function supports one major and one minor and makes an int of them.
It is very convenient to compare versions (eg: SSL) just as if they were plain
integers, as the comparison functions will still be based on integers.

17 years ago[MAJOR] implement tcp request content inspection
Willy Tarreau [Mon, 14 Jul 2008 21:54:42 +0000 (23:54 +0200)] 
[MAJOR] implement tcp request content inspection

Some people need to inspect contents of TCP requests before
deciding to forward a connection or not. A future extension
of this demand might consist in selecting a server farm
depending on the protocol detected in the request.

For this reason, a new state CL_STINSPECT has been added on
the client side. It is immediately entered upon accept() if
the statement "tcp-request inspect-delay <xxx>" is found in
the frontend configuration. Haproxy will then wait up to
this amount of time trying to find a matching ACL, and will
either accept or reject the connection depending on the
"tcp-request content <action> {if|unless}" rules, where
<action> is either "accept" or "reject".

Note that it only waits that long if no definitive verdict
can be found earlier. That generally implies calling a fetch()
function which does not have enough information to decode
some contents, or a match() function which only finds the
beginning of what it's looking for.

It is only at the ACL level that partial data may be processed
as such, because we need to distinguish between MISS and FAIL
*before* applying the term negation.

Thus it is enough to add "| ACL_PARTIAL" to the last argument
when calling acl_exec_cond() to indicate that we expect
ACL_PAT_MISS to be returned if some data is missing (for
fetch() or match()). This is the only case we may return
this value. For this reason, the ACL check in process_cli()
has become a lot simpler.

A new ACL "req_len" of type "int" has been added. Right now
it is already possible to drop requests which talk too early
(eg: for SMTP) or which don't talk at all (eg: HTTP/SSL).

Also, the acl fetch() functions have been extended in order
to permit reporting of missing data in case of fetch failure,
using the ACL_TEST_F_MAY_CHANGE flag.

The default behaviour is unchanged, and if no rule matches,
the request is accepted.

As a side effect, all layer 7 fetching functions have been
cleaned up so that they now check for the validity of the
layer 7 pointer before dereferencing it.

17 years ago[MEDIUM] modularize the "timeout" keyword configuration parser
Willy Tarreau [Wed, 9 Jul 2008 18:34:27 +0000 (20:34 +0200)] 
[MEDIUM] modularize the "timeout" keyword configuration parser

The "timeout" keyword already relied on an external parser, let's
make use of the new keyword registration mechanism.

17 years ago[MINOR] cfgparse: add support for warnings in external functions
Willy Tarreau [Wed, 9 Jul 2008 18:22:56 +0000 (20:22 +0200)] 
[MINOR] cfgparse: add support for warnings in external functions

Some parsers will need to report warnings in some cases. Let's
use positive values for that.

17 years ago[MEDIUM] modularize the global "stats" keyword configuration parser
Willy Tarreau [Wed, 9 Jul 2008 18:12:41 +0000 (20:12 +0200)] 
[MEDIUM] modularize the global "stats" keyword configuration parser

The "stats" keyword already relied on an external parser, let's
make use of the new keyword registration mechanism.

17 years ago[MEDIUM] add support for configuration keyword registration
Willy Tarreau [Wed, 9 Jul 2008 17:39:06 +0000 (19:39 +0200)] 
[MEDIUM] add support for configuration keyword registration

Any module which needs configuration keywords may now dynamically
register a keyword in a given section, and associate it with a
configuration parsing function using cfg_register_keywords() from
a constructor function. This makes the configuration parser more
modular because it is not required anymore to touch cfg_parse.c.
Example :

static int parse_global_blah(char **args, int section_type, struct proxy *curpx,
                             struct proxy *defpx, char *err, int errlen)
{
printf("parsing blah in global section\n");
return 0;
}

static int parse_listen_blah(char **args, int section_type, struct proxy *curpx,
      struct proxy *defpx, char *err, int errlen)
{
printf("parsing blah in listen section\n");
if (*args[1]) {
snprintf(err, errlen, "missing arg for listen_blah!!!");
return -1;
}
return 0;
}

static struct cfg_kw_list cfg_kws = {{ },{
{ CFG_GLOBAL, "blah", parse_global_blah },
{ CFG_LISTEN, "blah", parse_listen_blah },
{ 0, NULL, NULL },
}};

__attribute__((constructor))
static void __module_init(void)
{
cfg_register_keywords(&cfg_kws);
}

17 years ago[TESTS] added test-acl.cfg to test some ACL combinations
Willy Tarreau [Wed, 9 Jul 2008 14:18:21 +0000 (16:18 +0200)] 
[TESTS] added test-acl.cfg to test some ACL combinations

various rules constructions can be tested with this test case.

17 years ago[BUG] use_backend would not correctly consider "unless"
Willy Tarreau [Wed, 9 Jul 2008 09:23:31 +0000 (11:23 +0200)] 
[BUG] use_backend would not correctly consider "unless"

A copy-paste typo made use_backend not correctly consider the "unless"
case, depending on the previous "block" rule.

17 years ago[MAJOR] convert all expiration timers from timeval to ticks
Willy Tarreau [Sun, 6 Jul 2008 22:09:58 +0000 (00:09 +0200)] 
[MAJOR] convert all expiration timers from timeval to ticks

This is the first attempt at moving all internal parts from
using struct timeval to integer ticks. Those provides simpler
and faster code due to simplified operations, and this change
also saved about 64 bytes per session.

A new header file has been added : include/common/ticks.h.

It is possible that some functions should finally not be inlined
because they're used quite a lot (eg: tick_first, tick_add_ifset
and tick_is_expired). More measurements are required in order to
decide whether this is interesting or not.

Some function and variable names are still subject to change for
a better overall logics.

17 years ago[BUILD] silent a warning in unlikely() with gcc 4.x
Willy Tarreau [Sun, 6 Jul 2008 13:18:50 +0000 (15:18 +0200)] 
[BUILD] silent a warning in unlikely() with gcc 4.x

The unlikely() implementation for gcc 4.x spits out a warning
when a pointer is passed. Add a cast to unsigned long.

17 years ago[OPTIM] task_queue: assume most consecutive timers are equal
Willy Tarreau [Sat, 5 Jul 2008 16:16:19 +0000 (18:16 +0200)] 
[OPTIM] task_queue: assume most consecutive timers are equal

When queuing a timer, it's very likely that an expiration date is
equal to that of the previously queued timer, due to time rounding
to the millisecond. Optimizing for this case provides a noticeable
1% performance boost.

17 years ago[MEDIUM] introduce task->nice and boot access to statistics
Willy Tarreau [Mon, 30 Jun 2008 05:51:00 +0000 (07:51 +0200)] 
[MEDIUM] introduce task->nice and boot access to statistics

The run queue scheduler now considers task->nice to queue a task and
to pick a task out of the queue. This makes it possible to boost the
access to statistics (both via HTTP and UNIX socket). The UNIX socket
receives twice as much a boost as the HTTP socket because it is more
sensible.

17 years ago[MAJOR] use an ebtree instead of a list for the run queue
Willy Tarreau [Sun, 29 Jun 2008 20:40:23 +0000 (22:40 +0200)] 
[MAJOR] use an ebtree instead of a list for the run queue

We now insert tasks in a certain sequence in the run queue.
The sorting key currently is the arrival order. It will now
be possible to apply a "nice" value to any task so that it
goes forwards or backwards in the run queue.

The calls to wake_expired_tasks() and maintain_proxies()
have been moved to the main run_poll_loop(), because they
had nothing to do in process_runnable_tasks().

The task_wakeup() function is not inlined anymore, as it was
only used at one place.

The qlist member of the task structure has been removed now.
The run_queue list has been replaced for an integer indicating
the number of tasks in the run queue.

17 years ago[OPTIM] shrink wake_expired_tasks() by using task_wakeup()
Willy Tarreau [Sun, 29 Jun 2008 17:25:52 +0000 (19:25 +0200)] 
[OPTIM] shrink wake_expired_tasks() by using task_wakeup()

It's not worth duplicating task_wakeup() in wake_expired_tasks().
Calling it reduces code size and slightly improves performance.

17 years ago[BUILD] change declaration of base64tab to fix build with Intel C++
Willy Tarreau [Sun, 29 Jun 2008 15:17:38 +0000 (17:17 +0200)] 
[BUILD] change declaration of base64tab to fix build with Intel C++

I got a report that Intel C++ complains about the size of the
base64tab in base64.c. Setting it to 65 chars to allow for the
trailing zero fixes the problem.

17 years ago[MEDIUM] rework the wait queue mechanism
Willy Tarreau [Sun, 29 Jun 2008 15:00:59 +0000 (17:00 +0200)] 
[MEDIUM] rework the wait queue mechanism

The wait queues now rely on 4 trees for past, present and future
timers. The computations are cleaner and more reliable. The
wake_expired_tasks function has become simpler. Also, a bug
previously introduced in task_queue() by the first introduction
of eb_trees has been fixed (the eb->key was never updated).

17 years ago[BUG] disable buffer read timeout when reading stats
Willy Tarreau [Sun, 29 Jun 2008 14:38:43 +0000 (16:38 +0200)] 
[BUG] disable buffer read timeout when reading stats

The buffer read timeouts were not reset when stats were produced. This
caused unneeded wakeups.

17 years ago[MINOR] introduce now_ms, the current date in milliseconds
Willy Tarreau [Sun, 29 Jun 2008 11:47:25 +0000 (13:47 +0200)] 
[MINOR] introduce now_ms, the current date in milliseconds

This new time value will be used to compute timeouts and wait queue
positions. The operation is made once for all when time is retrieved.
A future improvement might consist in having it in ticks of 1/1024
second and to convert all timeouts into ticks.

17 years ago[BUG] wqueue: perform proper timeout comparisons with wrapping values
Willy Tarreau [Sun, 29 Jun 2008 08:25:57 +0000 (10:25 +0200)] 
[BUG] wqueue: perform proper timeout comparisons with wrapping values

With wrapping keys, we cannot simply do "if (key > now)", but
we must at least do "if ((signed)(key-now) > 0)".

17 years ago[BUG] we could segfault during exit while freeing uri_auths
Willy Tarreau [Tue, 24 Jun 2008 09:14:45 +0000 (11:14 +0200)] 
[BUG] we could segfault during exit while freeing uri_auths

The following config makes haproxy segfault on exit :

defaults
mode http
balance roundrobin

listen  no-stats
        bind       :8001

listen  stats
        bind       :8002
stats      uri /stats

The simple fix is to ensure that p->uri_auth is not NULL
before dereferencing it.

17 years ago[MAJOR] replace ultree with ebtree in wait-queues
Willy Tarreau [Tue, 24 Jun 2008 06:17:16 +0000 (08:17 +0200)] 
[MAJOR] replace ultree with ebtree in wait-queues

The ultree code has been removed in favor of a simpler and
cleaner ebtree implementation. The eternity queue does not
need to exist anymore, and the pool_tree64 has been removed.

The ebtree node is stored in the task itself. The qlist list
header is still used by the run-queue, but will be able to
disappear once the run-queue uses ebtree too.

17 years ago[OPTIM] add branch prediction hints in list manipulations
Willy Tarreau [Mon, 23 Jun 2008 20:39:37 +0000 (22:39 +0200)] 
[OPTIM] add branch prediction hints in list manipulations

GCC does not do very clever things with the ifs in list manipulation
macros. Adding a 'likely' helps it remove expensive jumps and useless
code.

17 years ago[MEDIUM] further improve monotonic clock by check forward jumps
Willy Tarreau [Mon, 23 Jun 2008 12:00:57 +0000 (14:00 +0200)] 
[MEDIUM] further improve monotonic clock by check forward jumps

The first implementation of the monotonic clock did not verify
forward jumps. The consequence is that a fast changing time may
expire a lot of tasks. While it does seem minor, in fact it is
problematic because most machines which boot with a wrong date
are in the past and suddenly see their time jump by several
years in the future.

The solution is to check if we spent more apparent time in
a poller than allowed (with a margin applied). The margin
is currently set to 1000 ms. It should be large enough for
any poll() to complete.

Tests with randomly jumping clock show that the result is quite
accurate (error less than 1 second at every change of more than
one second).

17 years ago[MEDIUM] implement a monotonic internal clock
Willy Tarreau [Sun, 22 Jun 2008 15:18:02 +0000 (17:18 +0200)] 
[MEDIUM] implement a monotonic internal clock

If the system date is set backwards while haproxy is running,
some scheduled events are delayed by the amount of time the
clock went backwards. This is particularly problematic on
systems where the date is set at boot, because it seldom
happens that health-checks do not get sent for a few hours.

Before switching to use clock_gettime() on systems which
provide it, we can at least ensure that the clock is not
going backwards and maintain two clocks : the "date" which
represents what the user wants to see (mostly for logs),
and an internal date stored in "now", used for scheduled
events.

17 years ago[DOC] documentation for the "retries" parameter was missing.
Willy Tarreau [Fri, 20 Jun 2008 15:27:19 +0000 (17:27 +0200)] 
[DOC] documentation for the "retries" parameter was missing.

17 years ago[BUG] fix the dequeuing logic to ensure that all requests get served
Willy Tarreau [Fri, 20 Jun 2008 13:04:11 +0000 (15:04 +0200)] 
[BUG] fix the dequeuing logic to ensure that all requests get served

The dequeuing logic was completely wrong. First, a task was assigned
to all servers to process the queue, but this task was never scheduled
and was only woken up on session free. Second, there was no reservation
of server entries when a task was assigned a server. This means that
as long as the task was not connected to the server, its presence was
not accounted for. This was causing trouble when detecting whether or
not a server had reached maxconn. Third, during a redispatch, a session
could lose its place at the server's and get blocked because another
session at the same moment would have stolen the entry. Fourth, the
redispatch option did not work when maxqueue was reached for a server,
and it was not possible to do so without indefinitely hanging a session.

The root cause of all those problems was the lack of pre-reservation of
connections at the server's, and the lack of tracking of servers during
a redispatch. Everything relied on combinations of flags which could
appear similarly in quite distinct situations.

This patch is a major rework but there was no other solution, as the
internal logic was deeply flawed. The resulting code is cleaner, more
understandable, uses less magics and is overall more robust.

As an added bonus, "option redispatch" now works when maxqueue has
been reached on a server.

17 years ago[BUG] log: reported queue position was offed-by-one
Willy Tarreau [Fri, 13 Jun 2008 19:48:18 +0000 (21:48 +0200)] 
[BUG] log: reported queue position was offed-by-one

The reported queue position in the logs was 0 for the first pending request
in the queue, which is wrong because it means that one request will have to
be completed before the queued one may execute. It caused the undesired side
effect that 0/0 was reported when either 0 or 1 request was pending in the
queue. Thus, we have to increment the queue size before reporting the value.

17 years ago[BUG] queue management: wake oldest request in queues
Willy Tarreau [Fri, 13 Jun 2008 19:12:51 +0000 (21:12 +0200)] 
[BUG] queue management: wake oldest request in queues

When a server terminates a connection, the next session in its
own queue was immediately processed. Because of this, if all
server queues are always filled, then no new anonymous request
will be processed. Consider oldest request between global and
server queues to choose from which to pick the request.

An improvement over this will consist in adding a configurable
offset when comparing expiration dates, so that cookie-less
requests can get either less or more priority.

17 years ago[BUG] event pollers must not wait if a task exists in the run queue
Willy Tarreau [Fri, 13 Jun 2008 19:06:56 +0000 (21:06 +0200)] 
[BUG] event pollers must not wait if a task exists in the run queue

Under some circumstances, a task may already lie in the run queue
(eg: inter-task wakeup). It is disastrous to wait for an event in
this case because some processing gets delayed.

17 years ago[DEBUG] add a TRACE macro to facilitate runtime data extraction
Willy Tarreau [Fri, 13 Jun 2008 20:36:31 +0000 (22:36 +0200)] 
[DEBUG] add a TRACE macro to facilitate runtime data extraction

The new TRACE macro is used almost like fprintf, except that a session
has to be passed  instead of the file descriptor. It displays infos about
where it is called, session ptr and id, etc...

17 years ago[BUILD] make install should depend on haproxy not "all"
Willy Tarreau [Wed, 11 Jun 2008 22:25:46 +0000 (00:25 +0200)] 
[BUILD] make install should depend on haproxy not "all"

Reported by Cherife Li : just doing a "make install" fails because it
depends on "all" which is equivalent to "help" if no TARGET was specified.
Make it depend on "haproxy" instead.

17 years ago[MEDIUM] add support for conditional HTTP redirection
Willy Tarreau [Sat, 7 Jun 2008 21:08:56 +0000 (23:08 +0200)] 
[MEDIUM] add support for conditional HTTP redirection

A new "redirect" keyword adds the ability to send an HTTP 301/302/303
redirection to either an absolute location or to a prefix followed by
the original URI. The redirection is conditionned by ACL rules, so it
becomes very easy to move parts of a site to another site using this.

This work was almost entirely done at Exceliance by Emeric Brun.

A test-case has been added in the tests/ directory.

17 years ago[MEDIUM] Fix memory freeing at exit, part 2
Krzysztof Piotr Oledzki [Sat, 31 May 2008 11:53:23 +0000 (13:53 +0200)] 
[MEDIUM] Fix memory freeing at exit, part 2

- free oldpids
- call free(exp->preg), not only regfree(exp->preg): req_exp, rsp_exp
- build a list of unique uri_auths and eventually free it
- prune_acl_cond/free for switching_rules
- add a callback pointer to free ptr from acl_pattern (used for regexs) and execute it

==1180== malloc/free: in use at exit: 0 bytes in 0 blocks.
==1180== malloc/free: 5,599 allocs, 5,599 frees, 4,220,556 bytes allocated.
==1180== All heap blocks were freed -- no leaks are possible.

17 years ago[MEDIUM] Fix memory freeing at exit
Krzysztof Piotr Oledzki [Thu, 29 May 2008 21:53:44 +0000 (23:53 +0200)] 
[MEDIUM] Fix memory freeing at exit

New functions implemented:
 - deinit_pollers: called at the end of deinit())
 - prune_acl: called via list_for_each_entry_safe

Add missing pool_destroy2 calls:
 - p->hdr_idx_pool
 - pool2_tree64

Implement all task stopping:
 - health-check: needs new "struct task" in the struct server
 - queue processing: queue_mgt
 - appsess_refresh: appsession_refresh

before (idle system):
==6079== LEAK SUMMARY:
==6079==    definitely lost: 1,112 bytes in 75 blocks.
==6079==    indirectly lost: 53,356 bytes in 2,090 blocks.
==6079==      possibly lost: 52 bytes in 1 blocks.
==6079==    still reachable: 150,996 bytes in 504 blocks.
==6079==         suppressed: 0 bytes in 0 blocks.

after (idle system):
==6945== LEAK SUMMARY:
==6945==    definitely lost: 7,644 bytes in 137 blocks.
==6945==    indirectly lost: 9,913 bytes in 587 blocks.
==6945==      possibly lost: 0 bytes in 0 blocks.
==6945==    still reachable: 0 bytes in 0 blocks.
==6945==         suppressed: 0 bytes in 0 blocks.

before (running system for ~2m):
==9343== LEAK SUMMARY:
==9343==    definitely lost: 1,112 bytes in 75 blocks.
==9343==    indirectly lost: 54,199 bytes in 2,122 blocks.
==9343==      possibly lost: 52 bytes in 1 blocks.
==9343==    still reachable: 151,128 bytes in 509 blocks.
==9343==         suppressed: 0 bytes in 0 blocks.

after (running system for ~2m):
==11616== LEAK SUMMARY:
==11616==    definitely lost: 7,644 bytes in 137 blocks.
==11616==    indirectly lost: 9,981 bytes in 591 blocks.
==11616==      possibly lost: 0 bytes in 0 blocks.
==11616==    still reachable: 4 bytes in 1 blocks.
==11616==         suppressed: 0 bytes in 0 blocks.

Still not perfect but significant improvement.

17 years ago[BUG/CLEANUP] cookiedomain -> cookie_domain rename + free(p->cookie_domain)
Krzysztof Piotr Oledzki [Thu, 29 May 2008 21:03:34 +0000 (23:03 +0200)] 
[BUG/CLEANUP] cookiedomain -> cookie_domain rename + free(p->cookie_domain)

Rename cookiedomain -> cookie_domain to be consistent with current
naming scheme. Also make sure cookie_domain is deallocated at deinit()

17 years ago[MEDIUM] detect streaming buffers and tag them as such
Willy Tarreau [Sat, 3 May 2008 21:07:14 +0000 (23:07 +0200)] 
[MEDIUM] detect streaming buffers and tag them as such

Add the ability to detect streaming buffers, and set a
flag indicating it. It will later serve us in order to
dynamically resize them, and to prioritize file descriptors
during polls.

17 years ago[MEDIUM] reduce risk of event starvation in ev_sepoll
Willy Tarreau [Sun, 25 May 2008 08:39:02 +0000 (10:39 +0200)] 
[MEDIUM] reduce risk of event starvation in ev_sepoll

If too many events are set for spec I/O, those ones can starve the
polled events. Experiments show that when polled events starve, they
quickly turn into spec I/O, making the situation even worse. While
we can reduce the number of polled events processed at once, we
cannot do this on speculative events because most of them are new
ones (avg 2/3 new - 1/3 old from experiments).

The solution against this problem relies on those two factors :
  1) one FD registered as a spec event cannot be polled at the same time
  2) even during very high loads, we will almost never be interested in
     simultaneous read and write streaming on the same FD.

The first point implies that during starvation, we will not have more than
half of our FDs in the poll list, otherwise it means there is less than that
in the spec list, implying there is no starvation.

The second point implies that we're statically only interested in half of
the maximum number of file descriptors at once, because we will unlikely
have simultaneous read and writes for a same buffer during long periods.

So, if we make it possible to drain maxsock/2/2 during peak loads, then we
can ensure that there will be no starvation effect. This means that we must
always allocate maxsock/4 events for the poller.

Last, sepoll uses an optimization consisting in reducing the number of calls
to epoll_wait() to once every too polls. However, when dealing with many
spec events, we can wait very long and skipping epoll_wait() every second
time increases latency. For this reason, we try to detect if we are beyond
a reasonable limit and stop doing so at this stage.

17 years ago[DOC] update the README file with new build options
Willy Tarreau [Sun, 25 May 2008 08:32:50 +0000 (10:32 +0200)] 
[DOC] update the README file with new build options

17 years ago[MINOR] Allow to specify a domain for a cookie
Krzysztof Piotr Oledzki [Fri, 23 May 2008 21:49:32 +0000 (23:49 +0200)] 
[MINOR] Allow to specify a domain for a cookie

This patch allows to specify a domain used when inserting a cookie
providing a session stickiness. Usefull for example with wildcard domains.

The patch adds one new variable to the struct proxy: cookiedomain.
When set the domain is appended to a Set-Cookie header.

Domain name is validated using the new invalid_domainchar() function.
It is basically invalid_char() limited to [A-Za-z0-9_.-]. Yes, the test
is too trivial and does not cover all wrong situations, but the main
purpose is to detect most common mistakes, not intentional abuses.

The underscore ("_") character is not RFC-valid but as it is
often (mis)used so I decided to allow it.

17 years ago[MEDIUM] upgrade to ebtree v4.0
Willy Tarreau [Fri, 16 May 2008 17:48:20 +0000 (19:48 +0200)] 
[MEDIUM] upgrade to ebtree v4.0

New ebtree also supports unique keys. This is useful for counters.

17 years ago[MEDIUM] add support for URI hash depth and length limits
Marek Majkowski [Sun, 27 Apr 2008 21:25:55 +0000 (23:25 +0200)] 
[MEDIUM] add support for URI hash depth and length limits

This patch adds two optional arguments "len" and "depth" to
"balance uri". They are used to limit the length in characters
of the analysis, as well as the number of directory components
it applies to.

17 years ago[BUILD] fix build with gcc 4.3
Jeremy Hinegardner [Mon, 21 Apr 2008 05:34:31 +0000 (07:34 +0200)] 
[BUILD] fix build with gcc 4.3

For Fedora 9 gcc 4.3 will be shipping as a feature, and right now haproxy does
not compile with gcc 4.3.

It appears that there is a reordering of headers or something along those lines,
This is the patch that gets haproxy to compile with gcc 4.3.  I'm not sure if
this is the correct approach you would want to use, so please correct me.

If this works for you, I'll go ahead and put this patch in the src rpm until a
release of haproxy which compiles with gcc 4.3 is released.

17 years ago[TESTS] add a debug patch to help trigger the stats bug
Krzysztof Oledzki [Mon, 21 Apr 2008 05:28:21 +0000 (07:28 +0200)] 
[TESTS] add a debug patch to help trigger the stats bug

About: [BUG] Flush buffers also where there are exactly 0 bytes left

I'm also attaching a debug patch that helps to trigger this bug.

Without the fix:
# echo -ne "GET /haproxy?stats;csv;norefresh HTTP/1.0\r\n\r\n"|nc 127.0.0.1
801|wc -c
16384

With the fix:
# echo -ne "GET /haproxy?stats;csv;norefresh HTTP/1.0\r\n\r\n"|nc 127.0.0.1
801|wc -c
33089

Best regards,

                                Krzysztof Oledzki

17 years ago[BUG] Flush buffers also where there are exactly 0 bytes left
Krzysztof Piotr Oledzki [Sun, 20 Apr 2008 19:34:47 +0000 (21:34 +0200)] 
[BUG] Flush buffers also where there are exactly 0 bytes left

I noticed it was possible to get truncated http/csv stats. Sometimes.
Usually the problem disappeared as fast as it appeared, but once it
happend that my http-stats page was truncated for about one hour.
It was quite weird as it happened independently for csv and http
output and it took me some time to track & fix this bug.

Both buffer_write & buffer_write_chunk used to return 0 in two
situations: is case of success or where there was exactly 0 bytes
left. The first one is intentional but I believe the second one
is not as it was not possible to distinguish between successful
write and unsuccessful one, which means that if the buffer was 100%
filled, it was never flushed and it was not possible to write
more data.

This patch fixes this problem.

17 years ago[RELEASE] Released version 1.3.15 v1.3.15
Willy Tarreau [Sat, 19 Apr 2008 19:06:14 +0000 (21:06 +0200)] 
[RELEASE] Released version 1.3.15

Released version 1.3.15 with the following main changes :
    - [BUILD] Added support for 'make install'
    - [BUILD] Added 'install-man' make target for installing the man page
    - [BUILD] Added 'install-bin' make target
    - [BUILD] Added 'install-doc' make target
    - [BUILD] Removed "/" after '$(DESTDIR)' in install targets
    - [BUILD] Changed 'install' target to install the binaries first
    - [BUILD] Replace hardcoded 'LD = gcc' with 'LD = $(CC)'
    - [MEDIUM]: Inversion for options
    - [MEDIUM]: Count retries and redispatches also for servers, fix redistribute_pending, extend logs, %d->%u cleanup
    - [BUG]: Restore clearing t->logs.bytes
    - [MEDIUM]: rework checks handling
    - [DOC] Update a "contrib" file with a hint about a scheme used for formathing subjects
    - [MEDIUM] Implement "track [<backend>/]<server>"
    - [MINOR] Implement persistent id for proxies and servers
    - [BUG] Don't increment server connections too much + fix retries
    - [MEDIUM]: Prevent redispatcher from selecting the same server, version #3
    - [MAJOR] proto_uxst rework -> SNMP support
    - [BUG] appsession lookup in URL does not work
    - [BUG] transparent proxy address was ignored in backend
    - [BUG] hot reconfiguration failed because of a wrong error check
    - [DOC] big update to the configuration manual
    - [DOC] large update to the configuration manual
    - [DOC] document more options
    - [BUILD] major rework of the GNU Makefile
    - [STATS] add support for "show info" on the unix socket
    - [DOC] document options forwardfor to logasap
    - [MINOR] add support for the "backlog" parameter
    - [OPTIM] introduce global parameter "tune.maxaccept"
    - [MEDIUM] introduce "timeout http-request" in frontends
    - [MINOR] tarpit timeout is also allowed in backends
    - [BUG] increment server connections for each connect()
    - [MEDIUM] add a turn-around state of one second after a connection failure
    - [BUG] fix typo in redispatched connection
    - [DOC] document options nolinger to ssl-hello-chk
    - [DOC] added documentation for "option tcplog" to "use_backend"
    - [BUG] connect_server: server might not exist when sending error report
    - [MEDIUM] support fully transparent proxy on Linux (USE_LINUX_TPROXY)
    - [MEDIUM] add non-local bind to connect() on Linux
    - [MINOR] add transparent proxy support for balabit's Tproxy v4
    - [BUG] use backend's source and not server's source with tproxy
    - [BUG] fix overlapping server flags
    - [MEDIUM] fix server health checks source address selection
    - [BUG] build failed on CONFIG_HAP_LINUX_TPROXY without CONFIG_HAP_CTTPROXY
    - [DOC] added "server", "source" and "stats" keywords
    - [DOC] all server parameters have been documented
    - [DOC] document all req* and rsp* keywords.
    - [DOC] added documentation about HTTP header manipulations
    - [BUG] log response byte count, not request
    - [BUILD] code did not build in full debug mode
    - [BUG] fix truncated responses with sepoll
    - [MINOR] use s->frt_addr as the server's address in transparent proxy
    - [MINOR] fix configuration hint about timeouts
    - [DOC] minor cleanup of the doc and notice to contributors
    - [MINOR] report correct section type for unknown keywords.
    - [BUILD] update MacOS Makefile to build on newer versions
    - [DOC] fix erroneous "useallbackups" option in the doc
    - [DOC] applied small fixes from early readers
    - [MINOR] add configuration support for "redir" server keyword
    - [MEDIUM] completely implement the server redirection method
    - [TESTS] add a test case for the server redirection mechanism
    - [DOC] add a configuration entry for "server ... redir <prefix>"
    - [BUILD] backend.c and checks.c did not build without tproxy !
    - Revert "[BUILD] backend.c and checks.c did not build without tproxy !"
    - [BUILD] backend.c and checks.c did not build without tproxy !
    - [OPTIM] used unsigned ints for HTTP state and message offsets
    - [OPTIM] GCC4's builtin_expect() is suboptimal
    - [BUG] failed conns were sometimes incremented in the frontend!
    - [BUG] timeout.check was not pre-set to eternity
    - [TESTS] add test-pollers.cfg to easily report pollers in use
    - [BUG] do not apply timeout.connect in checks if unset
    - [BUILD] ensure that makefile understands USE_DLMALLOC=1
    - [MINOR] silent gcc for a wrong warning
    - [CLEANUP] update .gitignore to ignore more temporary files
    - [CLEANUP] report dlmalloc's source path only if explictly specified
    - [BUG] str2sun could leak a small buffer in case of error during parsing
    - [BUG] option allbackups was not working anymore in roundrobin mode
    - [MAJOR] implementation of the "leastconn" load balancing algorithm
    - [BUILD] ensure that users don't build without setting the target anymore.
    - [DOC] document the leastconn LB algo
    - [MEDIUM] fix stats socket limitation to 16 kB
    - [DOC] fix unescaped space in httpchk example.
    - [BUG] fix double-decrement of server connections
    - [TESTS] add a test case for port mapping
    - [TESTS] add a benchmark for integer hashing
    - [TESTS] add new methods in ip-hash test file
    - [MAJOR] implement parameter hashing for POST requests

17 years ago[BUILD] fix build of POST analysis code with gcc < 3
Willy Tarreau [Sat, 19 Apr 2008 19:24:56 +0000 (21:24 +0200)] 
[BUILD] fix build of POST analysis code with gcc < 3

move variable declarations at beginning of blocks.

17 years ago[MAJOR] implement parameter hashing for POST requests
matt.farnsworth@nokia.com [Mon, 14 Apr 2008 18:47:37 +0000 (20:47 +0200)] 
[MAJOR] implement parameter hashing for POST requests

This patch extends the "url_param" load balancing method by introducing
the "check_post" option. Using this option enables analysis of the beginning
of POST requests to search for the specified URL parameter.

The patch also fixes a few minor typos in comments that were discovered
during code review.

17 years ago[TESTS] add new methods in ip-hash test file
Willy Tarreau [Sun, 13 Apr 2008 07:27:00 +0000 (09:27 +0200)] 
[TESTS] add new methods in ip-hash test file

added methods to provide a better hash with small input sets

17 years ago[TESTS] add a benchmark for integer hashing
Willy Tarreau [Sat, 12 Apr 2008 20:28:32 +0000 (22:28 +0200)] 
[TESTS] add a benchmark for integer hashing

If we want to support netmasks for IP address hashing,
we will need something better than a pure modulus, otherwise
people with even numbers of servers will get surprizes.

Bob Jenkins is known for his works on hashing, and his site
has a lot of very interesting researches and algorithms for
integer hashing. He also points to the work of Thomas Wang
who has similar findings.

The program here tests their algorithms in order to find one
well suited for IP address hashing.

17 years ago[TESTS] add a test case for port mapping
Willy Tarreau [Sat, 12 Apr 2008 09:19:04 +0000 (11:19 +0200)] 
[TESTS] add a test case for port mapping

17 years ago[BUG] fix double-decrement of server connections
Willy Tarreau [Fri, 28 Mar 2008 17:09:38 +0000 (18:09 +0100)] 
[BUG] fix double-decrement of server connections

If a client does a sudden dirty close (CL_STCLOSE) during a server
connect turn-around, then the number of server connections is
decremented twice. This causes huge problems on the affected
server because when its connection number becomes negative, it
overflows and prevents the server from accepting new connections
due to an apparent saturation.

The fix consists in not decrementing the counter if the server is
in a turn-around state.

17 years ago[DOC] fix unescaped space in httpchk example.
Willy Tarreau [Fri, 21 Mar 2008 19:17:14 +0000 (20:17 +0100)] 
[DOC] fix unescaped space in httpchk example.

Lars Braeuer reported a missing space in the example which drives
readers in wrong direction.

17 years ago[BUILD] Replace hardcoded 'LD = gcc' with 'LD = $(CC)'
Christian Wiese [Mon, 17 Mar 2008 17:23:12 +0000 (18:23 +0100)] 
[BUILD] Replace hardcoded 'LD = gcc' with 'LD = $(CC)'

haproxy relies on linking the binary using gcc, so there is no real need to
hardcode both (CC and LD). Setting 'LD = $(CC)' will make the build system
a bit more cross-compile friendly because only the right cross-compiler has
to be passed via make.

17 years ago[MEDIUM] fix stats socket limitation to 16 kB
Willy Tarreau [Mon, 17 Mar 2008 20:38:24 +0000 (21:38 +0100)] 
[MEDIUM] fix stats socket limitation to 16 kB

Due to the way the stats socket work, it was not possible to
maintain the information related to the command entered, so
after filling a whole buffer, the request was lost and it was
considered that there was nothing to write anymore.

The major reason was that some flags were passed directly
during the first call to stats_dump_raw() instead of being
stored persistently in the session.

To definitely fix this problem, flags were added to the stats
member of the session structure.

A second problem appeared. When the stats were produced, a first
call to client_retnclose() was performed, then one or multiple
subsequent calls to buffer_write_chunks() were done. But once the
stats buffer was full and a reschedule operated, the buffer was
flushed, the write flag cleared from the buffer and nothing was
done to re-arm it.

For this reason, a check was added in the proto_uxst_stats()
function in order to re-call the client FSM when data were added
by stats_dump_raw(). Finally, the whole unix stats dump FSM was
rewritten to avoid all the magics it depended on. It is now
simpler and looks more like the HTTP one.

17 years ago[DOC] document the leastconn LB algo
Willy Tarreau [Mon, 17 Mar 2008 11:07:56 +0000 (12:07 +0100)] 
[DOC] document the leastconn LB algo

17 years ago[BUILD] Changed 'install' target to install the binaries first
Christian Wiese [Wed, 12 Mar 2008 16:28:13 +0000 (18:28 +0200)] 
[BUILD] Changed 'install' target to install the binaries first

17 years ago[BUILD] Removed "/" after '$(DESTDIR)' in install targets
Christian Wiese [Wed, 12 Mar 2008 16:19:16 +0000 (18:19 +0200)] 
[BUILD] Removed "/" after '$(DESTDIR)' in install targets

SBINDIR, MANDIR and DOCDIR use an absolute path

17 years ago[BUILD] Added 'install-doc' make target
Christian Wiese [Wed, 12 Mar 2008 15:24:49 +0000 (17:24 +0200)] 
[BUILD] Added 'install-doc' make target

This change is also introducing a new make variable called DOCDIR,
which is set to "$(PREFIX)/doc/haproxy" by default.

17 years ago[BUILD] Added 'install-bin' make target
Christian Wiese [Wed, 12 Mar 2008 14:21:05 +0000 (16:21 +0200)] 
[BUILD] Added 'install-bin' make target

17 years ago[BUILD] Added 'install-man' make target for installing the man page
Christian Wiese [Wed, 12 Mar 2008 13:57:54 +0000 (15:57 +0200)] 
[BUILD] Added 'install-man' make target for installing the man page

This change is also introducing a new variable in the Makefile called
MANDIR, which is set to "$PREFIX/share/man" by default.

17 years ago[BUILD] Added support for 'make install'
Christian Wiese [Wed, 12 Mar 2008 13:25:35 +0000 (15:25 +0200)] 
[BUILD] Added support for 'make install'

To be flexible while installing haproxy following variables have been
added to the Makefile:
- DESTDIR useful i.e. while installing in a sandbox (not set by default)
- PREFIX  defines the default install prefix (default: /usr/local)
- SBINDIR defines the dir the haproxy binary gets installed
  (default: $PREFIX/sbin)

17 years ago[BUILD] ensure that users don't build without setting the target anymore.
Willy Tarreau [Tue, 11 Mar 2008 05:37:39 +0000 (06:37 +0100)] 
[BUILD] ensure that users don't build without setting the target anymore.

Too often, people report performance issues on Linux 2.6 because they don't
use the available optimizations. We need to ensure that people are aware of
the available features, and for this, we must force them to choose a target
OS (or "generic"), but at least prevent them from blindly building for a
generic target.

17 years ago[MAJOR] implementation of the "leastconn" load balancing algorithm
Willy Tarreau [Mon, 10 Mar 2008 21:04:20 +0000 (22:04 +0100)] 
[MAJOR] implementation of the "leastconn" load balancing algorithm

The new "leastconn" LB algorithm selects the server which has the
least established or pending connections. The weights are considered,
so that a server with a weight of 20 will get twice as many connections
as the server with a weight of 10.

The algorithm respects the minconn/maxconn settings, as well as the
slowstart since it is a dynamic algorithm. It also correctly supports
backup servers (one and all).

It is generally suited for protocols with long sessions (such as remote
terminals and databases), as it will ensure that upon restart, a server
with no connection will take all new ones until its load is balanced
with others.

A test configuration has been added in order to ease regression testing.

17 years ago[BUG] option allbackups was not working anymore in roundrobin mode
Willy Tarreau [Sat, 8 Mar 2008 20:42:54 +0000 (21:42 +0100)] 
[BUG] option allbackups was not working anymore in roundrobin mode

Commit 3168223a7b33a1d5aad1e11b8f2ad917645d7f27 broke option
"allbackups" in roundrobin mode due to an erroneous structure
member replacement in backend.c. The PR_O_USE_ALL_BK flag was
not tested in the right member anymore.

This bug uncoverred another one, by which all backup servers would
be used whatever the option's value, if all of them had been seen
as simultaneously failed at one moment.

This patch fixes the two stupid errors. Correctness has been tested
using the test-fwrr.cfg config example.

17 years ago[BUG] str2sun could leak a small buffer in case of error during parsing
Willy Tarreau [Fri, 7 Mar 2008 09:07:04 +0000 (10:07 +0100)] 
[BUG] str2sun could leak a small buffer in case of error during parsing

Matt Farnsworth reported a memory leak in str2sun() in case a too large
socket path is passed. The bug is very minor because it only happens
once during config parsing, but has to be fixed nevertheless. The patch
Matt provided could even be improved by completely removing the useless
strdup() in this function.

17 years ago[CLEANUP] report dlmalloc's source path only if explictly specified
Willy Tarreau [Fri, 7 Mar 2008 09:02:14 +0000 (10:02 +0100)] 
[CLEANUP] report dlmalloc's source path only if explictly specified

There's no point in reporting dlmalloc's source path if it was the
default one.

17 years ago[CLEANUP] update .gitignore to ignore more temporary files
Willy Tarreau [Fri, 7 Mar 2008 08:39:37 +0000 (09:39 +0100)] 
[CLEANUP] update .gitignore to ignore more temporary files

17 years ago[MINOR] silent gcc for a wrong warning
Willy Tarreau [Tue, 4 Mar 2008 05:38:57 +0000 (06:38 +0100)] 
[MINOR] silent gcc for a wrong warning

gcc believes that avoididx may be used uninitialized, which is wrong.

17 years ago[MAJOR] proto_uxst rework -> SNMP support
Krzysztof Piotr Oledzki [Sun, 2 Mar 2008 01:42:14 +0000 (02:42 +0100)] 
[MAJOR] proto_uxst rework -> SNMP support

Currently there is a ~16KB limit for a data size passed via unix socket.
It is caused by a trivial bug ttat is going to fixed soon, however
in most cases there is no need to dump a full stats.

This patch makes possible to select a scope of dumped data by extending
current "show stat" to "show stat [<iid> <type> <sid>]":
 - iid is a proxy id, -1 to dump all proxies
 - type selects type of dumpable objects: 1 for frontend, 2 for backend, 4 for
   server, -1 for all types. Values can be ORed, for example:
     1+2=3   -> frontend+backend.
     1+2+4=7 -> frontend+backend+server.
 - sid is a service id, -1 to dump everything from the selected proxy.

To do this I implemented a new session flag (SN_STAT_BOUND), added three
variables in data_ctx.stats (iid, type, sid), modified dumpstats.c and
completely revorked the process_uxst_stats: now it waits for a "\n"
terminated string, splits args and uses them. BTW: It should be quite easy
to add new commands, for example to enable/disable servers, the only problem
I can see is a not very lucky config name (*stats* socket). :|

During the work I also fixed two bug:
 - s->flags were not initialized for proto_uxst
 - missing comma if throttling not enabled (caused by a stupid change in
     "Implement persistent id for proxies and servers")

Other changes:
 - No more magic type valuse, use STATS_TYPE_FE/STATS_TYPE_BE/STATS_TYPE_SV
 - Don't memset full s->data_ctx (it was clearing s->data_ctx.stats.{iid/type/sid},
    instead initialize stats.sv & stats.sv_st (stats.px and stats.px_st were already
    initialized)

With all that changes it was extremely easy to write a short perl plugin
for a perl-enabled net-snmp (also included in this patch).

29385 is my PEN (Private Enterprise Number) and I'm willing to donate
the SNMPv2-SMI::enterprises.29385.106.* OIDs for HAProxy if there
is nothing assigned already.

17 years ago[MEDIUM]: Prevent redispatcher from selecting the same server, version #3
Krzysztof Piotr Oledzki [Fri, 22 Feb 2008 02:50:19 +0000 (03:50 +0100)] 
[MEDIUM]: Prevent redispatcher from selecting the same server, version #3

When haproxy decides that session needs to be redispatched it chose a server,
but there is no guarantee for it to be a different one. So, it often
happens that selected server is exactly the same that it was previously, so
a client ends up with a 503 error anyway, especially when one sever has
much bigger weight than others.

Changes from the previous version:
 - drop stupid and unnecessary SN_DIRECT changes

 - assign_server(): use srvtoavoid to keep the old server and clear s->srv
    so SRV_STATUS_NOSRV guarantees that t->srv == NULL (again)
    and get_server_rr_with_conns has chances to work (previously
    we were passing a NULL here)

 - srv_redispatch_connect(): remove t->srv->cum_sess and t->srv->failed_conns
   incrementing as t->srv was guaranteed to be NULL

 - add avoididx to get_server_rr_with_conns. I hope I correctly understand this code.

 - fix http_flush_cookie_flags() and move it to assign_server_and_queue()
   directly. The code here was supposed to set CK_DOWN and clear CK_VALID,
   but: (TX_CK_VALID | TX_CK_DOWN) == TX_CK_VALID == TX_CK_MASK so:
if ((txn->flags & TX_CK_MASK) == TX_CK_VALID)
txn->flags ^= (TX_CK_VALID | TX_CK_DOWN);
   was really a:
if ((txn->flags & TX_CK_MASK) == TX_CK_VALID)
txn->flags &= TX_CK_VALID

   Now haproxy logs "--DI" after redispatching connection.

 - defer srv->redispatches++ and s->be->redispatches++ so there
   are called only if a conenction was redispatched, not only
   supposed to.

 - don't increment lbconn if redispatcher selected the same sarver

 - don't count unsuccessfully redispatched connections as redispatched
   connections

 - don't count redispatched connections as errors, so:

 - the number of connections effectively served by a server is:
 srv->cum_sess - srv->failed_conns - srv->retries - srv->redispatches
   and
 SUM(servers->failed_conns) == be->failed_conns

 - requires the "Don't increment server connections too much + fix retries" patch

 - needs little more testing and probably some discussion so reverting to the RFC state

Tests #1:
 retries 4
 redispatch

i) 1 server(s): b (wght=1, down)
  b) sessions=5, lbtot=1, err_conn=1, retr=4, redis=0
  -> request failed

ii) server(s): b (wght=1, down), u (wght=1, down)
  b) sessions=4, lbtot=1, err_conn=0, retr=3, redis=1
  u) sessions=1, lbtot=1, err_conn=1, retr=0, redis=0
  -> request FAILED

iii) 2 server(s): b (wght=1, down), u (wght=1, up)
  b) sessions=4, lbtot=1, err_conn=0, retr=3, redis=1
  u) sessions=1, lbtot=1, err_conn=0, retr=0, redis=0
  -> request OK

iv) 2 server(s): b (wght=100, down), u (wght=1, up)
  b) sessions=4, lbtot=1, err_conn=0, retr=3, redis=1
  u) sessions=1, lbtot=1, err_conn=0, retr=0, redis=0
  -> request OK

v) 1 server(s): b (down for first 4 SYNS)
  b) sessions=5, lbtot=1, err_conn=0, retr=4, redis=0
  -> request OK

Tests #2:
 retries 4

i) 1 server(s): b (down)
  b) sessions=5, lbtot=1, err_conn=1, retr=4, redis=0
  -> request FAILED

17 years ago[BUG] Don't increment server connections too much + fix retries
Krzysztof Piotr Oledzki [Mon, 4 Feb 2008 01:10:09 +0000 (02:10 +0100)] 
[BUG] Don't increment server connections too much + fix retries

Commit 98937b875798e10fac671d109355cde29d2a411a while fixing
one bug introduced another one. With "retries 4" and
"option redispatch" haproxy tries to connect 4 times to
one server server and 1 time to a second one. However
logs showed 5 connections to the first server (the
last one was counted twice) and 2 to the second.

This patch also fixes srv->retries and be->retries increments.

Now I get: 3 retries and 1 error in a first server (4 cum_sess)
and 1 error in a second server (1 cum_sess) with:
 retries 4
 option redispatch

and: 4 retries and 1 error (5 cum_sess) with:
 retries 4

So, the number of connections effectively served by a server is:
 srv->cum_sess - srv->failed_conns - srv->retries

17 years ago[MINOR] Implement persistent id for proxies and servers
Krzysztof Piotr Oledzki [Sat, 23 Feb 2008 00:19:10 +0000 (01:19 +0100)] 
[MINOR] Implement persistent id for proxies and servers

This patch adds a possibility to set a persistent id for a proxy/server.
Now, even if some proxies/servers are inserted/deleted/moved, iids and
sids can be still used reliable.

Some people add servers with tricky names (BACKEND or FRONTEND for example).
So I also added one more field ('type') to distinguish between a
backend (0), frontend (1) and server (2) without complicated logic:
if name==BACKEND and sid==0 then type is BACKEND else type is SERVER,
etc for a FRONTEND. It also makes possible to have one frontend with more
than one IP (a patch coming soon) with independed stats - for example to
differs between remote and local traffic.

Finally, I added documentation about the CSV format.

This patch depends on '[MEDIUM] Implement "track [<backend>/]<server>"'

17 years ago[MEDIUM] Implement "track [<backend>/]<server>"
Krzysztof Piotr Oledzki [Mon, 18 Feb 2008 00:26:35 +0000 (01:26 +0100)] 
[MEDIUM] Implement "track [<backend>/]<server>"

This patch implements ability to set the current state of one server
by tracking another one. It:
 - adds two variables: *tracknext, *tracked to struct server
 - implements findserver(), similar to findproxy()
 - adds "track" keyword accepting both "proxy/server" and "server" (assuming current proxy)
 - verifies if both checks and tracking is not enabled at the same time
 - changes set_server_down() to notify tracking server
 - creates set_server_up(), set_server_disabled(), set_server_enabled() by
   moving the code from process_chk() and adding notifications
 - changes stats to show a name of tracked server instead of Chk/Dwn/Dwntime(html)
   or by adding new variable (csv)

Changes from the previuos version:
 - it is possibile to track independently of the declaration order
 - one extra comma bug is fixed
 - new condition to check if there is no disable-on-404 inconsistency