]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
16 years ago[MEDIUM] stream_sock_process_data moved to stream_sock.c
Willy Tarreau [Wed, 27 Aug 2008 19:41:35 +0000 (21:41 +0200)] 
[MEDIUM] stream_sock_process_data moved to stream_sock.c

The old temporary process_srv_data function moved to stream_sock.c.

16 years ago[MEDIUM] process_srv_data: ensure that we always correctly re-arm timeouts
Willy Tarreau [Wed, 27 Aug 2008 19:10:25 +0000 (21:10 +0200)] 
[MEDIUM] process_srv_data: ensure that we always correctly re-arm timeouts

We really want to ensure that we don't miss a timeout update and do not
update them for nothing. So the code takes care of updating the timeout
in the two following circumstances :
  - it was not set
  - some I/O has been performed

Maybe we'll be able to remove that from stream_sock_{read|write}, or
we'll find a way to ensure that we never have to re-enable this.

16 years ago[MEDIUM] third cleanup and optimization of process_srv_data()
Willy Tarreau [Wed, 27 Aug 2008 18:35:41 +0000 (20:35 +0200)] 
[MEDIUM] third cleanup and optimization of process_srv_data()

Some repeated tests were factored out.
Now the code makes sense and is fully understandable.

16 years ago[MEDIUM] second level of code cleanup for process_srv_data
Willy Tarreau [Wed, 27 Aug 2008 18:09:19 +0000 (20:09 +0200)] 
[MEDIUM] second level of code cleanup for process_srv_data

Now the function is 100% server-independant. Next step will
consist in using the same function for the client side too.

16 years ago[MEDIUM] massive cleanup of process_srv()
Willy Tarreau [Wed, 27 Aug 2008 16:52:22 +0000 (18:52 +0200)] 
[MEDIUM] massive cleanup of process_srv()

Server-specific calls were extracted and moved to the caller.
The function is now nearly server-agnostic.

16 years ago[OPTIM] remove useless fd_set(read) upon shutdown(write)
Willy Tarreau [Wed, 27 Aug 2008 13:19:25 +0000 (15:19 +0200)] 
[OPTIM] remove useless fd_set(read) upon shutdown(write)

Those old tricks are no longer needed and are overwritten
anyway. Remove them.

16 years ago[MAJOR] rework of the server FSM
Willy Tarreau [Sun, 19 Oct 2008 05:30:41 +0000 (07:30 +0200)] 
[MAJOR] rework of the server FSM

srv_state has been removed from HTTP state machines, and states
have been split in either TCP states or analyzers. For instance,
the TARPIT state has just become a simple analyzer.

New flags have been added to the struct buffer to compensate this.
The high-level stream processors sometimes need to force a disconnection
without touching a file-descriptor (eg: report an error). But if
they touched BF_SHUTW or BF_SHUTR, the file descriptor would not
be closed. Thus, the two SHUT?_NOW flags have been added so that
an application can request a forced close which the stream interface
will be forced to obey.

During this change, a new BF_HIJACK flag was added. It will
be used for data generation, eg during a stats dump. It
prevents the producer on a buffer from sending data into it.

  BF_SHUTR_NOW  /* the producer must shut down for reads ASAP  */
  BF_SHUTW_NOW  /* the consumer must shut down for writes ASAP */
  BF_HIJACK     /* the producer is temporarily replaced        */

BF_SHUTW_NOW has precedence over BF_HIJACK. BF_HIJACK has
precedence over BF_MAY_FORWARD (so that it does not need it).

New functions buffer_shutr_now(), buffer_shutw_now(), buffer_abort()
are provided to manipulate BF_SHUT* flags.

A new type "stream_interface" has been added to describe both
sides of a buffer. A stream interface has states and error
reporting. The session now has two stream interfaces (one per
side). Each buffer has stream_interface pointers to both
consumer and producer sides.

The server-side file descriptor has moved to its stream interface,
so that even the buffer has access to it.

process_srv() has been split into three parts :
  - tcp_get_connection() obtains a connection to the server
  - tcp_connection_failed() tests if a previously attempted
    connection has succeeded or not.
  - process_srv_data() only manages the data phase, and in
    this sense should be roughly equivalent to process_cli.

Little code has been removed, and a lot of old code has been
left in comments for now.

16 years ago[MEDIUM] make it possible for analysers to follow the whole session
Willy Tarreau [Thu, 21 Aug 2008 08:05:00 +0000 (10:05 +0200)] 
[MEDIUM] make it possible for analysers to follow the whole session

Some analysers will need to remain present after connection is
established. Change the way BF_MAY_FORWARD is set to allow this.

16 years ago[BUG] fix harmless but wrong fd insertion sequence
Willy Tarreau [Tue, 26 Aug 2008 11:25:39 +0000 (13:25 +0200)] 
[BUG] fix harmless but wrong fd insertion sequence

In backend.c, we had an EV_FD_SET() called before fd_insert().
This is wrong because fd_insert updates maxfd which might be
used by some of the pollers during EV_FD_SET(), although this
is not currently the case.

16 years ago[BUG] Fix empty X-Forwarded-For header name when set in defaults section
Willy Tarreau [Sat, 23 Aug 2008 06:18:21 +0000 (08:18 +0200)] 
[BUG] Fix empty X-Forwarded-For header name when set in defaults section

The following patch introduced a minor bug :
   [MINOR] permit renaming of x-forwarded-for header

If "option forwardfor" is declared in a defaults section, the header name
is never set and we see an empty header name before the value. Also, the
header name was not reset between two defaults sections.

16 years ago[TESTS] test-fsm: 22 regression tests for state machines
Willy Tarreau [Sun, 17 Aug 2008 17:30:03 +0000 (19:30 +0200)] 
[TESTS] test-fsm: 22 regression tests for state machines

22 regression tests for state machines are managed by the new
file tests/test-fsm.cfg. Check it, they are all documented
inside. Most of the bugs introduced during the FSM extraction
have been found with these tests.

16 years ago[BUG] process_request: HTTP body analysis must return zero if missing data
Willy Tarreau [Sun, 17 Aug 2008 17:17:57 +0000 (19:17 +0200)] 
[BUG] process_request: HTTP body analysis must return zero if missing data

This missing return and timeout check caused an infinite loop too.

16 years ago[BUG] process_cli/process_srv: don't call shutdown when already done
Willy Tarreau [Sun, 17 Aug 2008 16:16:38 +0000 (18:16 +0200)] 
[BUG] process_cli/process_srv: don't call shutdown when already done

A few missing checks of BF_SHUTR and BF_SHUTW caused busy loops upon
some error paths.

16 years ago[MEDIUM] merge inspect_exp and txn->exp into request buffer
Willy Tarreau [Sun, 17 Aug 2008 16:03:28 +0000 (18:03 +0200)] 
[MEDIUM] merge inspect_exp and txn->exp into request buffer

Since we may have several analysers on a buffer, it's more
convenient to have the analyser timeout attached to the
buffer itself.

16 years ago[BUILD] fix warning in proto_tcp.c with gcc >= 4
Willy Tarreau [Sun, 17 Aug 2008 15:13:47 +0000 (17:13 +0200)] 
[BUILD] fix warning in proto_tcp.c with gcc >= 4

signedness issues.

16 years ago[BUG] regparm is broken on gcc < 3
Willy Tarreau [Sun, 17 Aug 2008 15:06:37 +0000 (17:06 +0200)] 
[BUG] regparm is broken on gcc < 3

Gcc < 3 does not consider regparm declarations for function pointers.
This causes big trouble at least with pollers (and with any function
pointer after all). Disable CONFIG_HAP_USE_REGPARM for gcc < 3.

16 years ago[OPTIM] process_cli/process_srv: reduce the number of tests
Willy Tarreau [Sun, 17 Aug 2008 14:23:10 +0000 (16:23 +0200)] 
[OPTIM] process_cli/process_srv:  reduce the number of tests

We can skip a number of tests by simply checking a few flags,
it saves a few CPU cycles in the fast path.

16 years ago[MEDIUM] session: move the analysis bit field to the buffer
Willy Tarreau [Sun, 17 Aug 2008 13:20:19 +0000 (15:20 +0200)] 
[MEDIUM] session: move the analysis bit field to the buffer

It makes more sense to store the list of analysers in the buffer
than in the session since they are precisely plugged onto one
buffer.

16 years ago[MINOR] ensure the termination flags are set by process_xxx
Willy Tarreau [Sun, 17 Aug 2008 12:38:41 +0000 (14:38 +0200)] 
[MINOR] ensure the termination flags are set by process_xxx

When any processing remains on a buffer, it must be up to the
processing functions to set the termination flags, because they
are the only ones who know about higher levels.

16 years ago[MEDIUM] centralize buffer timeout checks at the top of process_session
Willy Tarreau [Sun, 17 Aug 2008 11:04:25 +0000 (13:04 +0200)] 
[MEDIUM] centralize buffer timeout checks at the top of process_session

it's more efficient and easier to check all the timeouts at once and
always rely on the buffer flags than to check them everywhere.

16 years ago[MEDIUM] use buffer->wex instead of buffer->cex for connect timeout
Willy Tarreau [Sun, 17 Aug 2008 10:11:14 +0000 (12:11 +0200)] 
[MEDIUM] use buffer->wex instead of buffer->cex for connect timeout

It's a shame not to use buffer->wex for connection timeouts since by
definition it cannot be used till the connection is not established.
Using it instead of ->cex also makes the buffer processing more
symmetric.

16 years ago[MAJOR] process_session: rely only on buffer flags
Willy Tarreau [Sat, 16 Aug 2008 23:00:46 +0000 (01:00 +0200)] 
[MAJOR] process_session: rely only on buffer flags

Instead of calling all functions in a loop, process_session now
calls them according to buffer flags changes. This ensures that
we almost never call functions for nothing. The flags settings
are still quite coarse, but the number of average functions
calls per session has dropped from 31 to 18 (the calls to
process_srv dropped from 13 to 7 and the calls to process_cli
dropped from 13 to 8).

This could still be improved by memorizing which flags each
function uses, but that would add a level of complexity which
is not desirable and maybe even not worth the small gain.

16 years ago[MEDIUM] buffers: add BF_EMPTY and BF_FULL to remove dependency on req/rep->l
Willy Tarreau [Sat, 16 Aug 2008 20:18:07 +0000 (22:18 +0200)] 
[MEDIUM] buffers: add BF_EMPTY and BF_FULL to remove dependency on req/rep->l

It is not always convenient to run checks on req->l in functions to
check if a buffer is empty or full. Now the stream_sock functions
set flags BF_EMPTY and BF_FULL according to the buffer contents. Of
course, functions which touch the buffer contents adjust the flags
too.

16 years ago[CLEANUP] get rid of BF_SHUT*_PENDING
Willy Tarreau [Sat, 16 Aug 2008 19:13:23 +0000 (21:13 +0200)] 
[CLEANUP] get rid of BF_SHUT*_PENDING

BF_SHUTR_PENDING and BF_SHUTW_PENDING were poor ideas because
BF_SHUTR is the pending of BF_SHUTW_DONE and BF_SHUTW is the
pending of BF_SHUTR_DONE. Remove those two useless and confusing
"pending" versions and rename buffer_shut{r,w}_* functions.

16 years ago[BUG] maintain_proxies must not disable backends
Willy Tarreau [Sat, 16 Aug 2008 16:41:13 +0000 (18:41 +0200)] 
[BUG] maintain_proxies must not disable backends

maintain_proxies could disable backends (p->maxconn == 0) which is
wrong (but apparently harmless). Add a check for p->maxconn == 0.

16 years ago[BUG] process_response: do not touch srv_state
Willy Tarreau [Sat, 16 Aug 2008 16:40:18 +0000 (18:40 +0200)] 
[BUG] process_response: do not touch srv_state

process_response is not allowed to touch srv_state (this is an
incident which has survived the code migration). This bug was
causing connection exhaustion on frontend due to some closed
sockets marked SV_STDATA again.

16 years ago[BUG] buffers: remove BF_MAY_CONNECT and fix forwarding issue
Willy Tarreau [Sat, 16 Aug 2008 14:39:26 +0000 (16:39 +0200)] 
[BUG] buffers: remove BF_MAY_CONNECT and fix forwarding issue

It wasn't really wise to separate BF_MAY_CONNECT and BF_MAY_FORWARD,
as it caused trouble in TCP mode because the connection was allowed
but not the forwarding. Remove BF_MAY_CONNECT.

16 years ago[BUG] process_response must not enable the read FD
Willy Tarreau [Sat, 16 Aug 2008 14:11:07 +0000 (16:11 +0200)] 
[BUG] process_response must not enable the read FD

Since the separation of TCP and HTTP state machines, the HTTP
code must not play anymore with the file descriptor status
without checking if they are closed. Remains of such practice
have caused busy loops under some circumstances (mainly when
client closed during headers response).

16 years ago[BUG] ev_sepoll: closed file descriptors could persist in the spec list
Willy Tarreau [Sat, 16 Aug 2008 14:06:02 +0000 (16:06 +0200)] 
[BUG] ev_sepoll: closed file descriptors could persist in the spec list

If __fd_clo() was called on a file descriptor which was previously
disabled, it was not removed from the spec list. This apparently
could not happen on previous code because the TCP states prevented
this, but now it happens regularly. The effects are spec entries
stuck populated, leading to busy loops.

16 years ago[MINOR] term_trace: add better instrumentations to trace the code
Willy Tarreau [Sat, 16 Aug 2008 12:55:08 +0000 (14:55 +0200)] 
[MINOR] term_trace: add better instrumentations to trace the code

A new member has been added to the struct session. It keeps a trace
of what block of code performs a close or a shutdown on a socket, and
in what sequence. This is extremely convenient for post-mortem analysis
where flag combinations and states seem impossible. A new ABORT_NOW()
macro has also been added to make the code immediately segfault where
called.

16 years ago[MEDIUM] remove unused references to {CL|SV}_STSHUT*
Willy Tarreau [Sat, 16 Aug 2008 08:56:30 +0000 (10:56 +0200)] 
[MEDIUM] remove unused references to {CL|SV}_STSHUT*

All references to CL_STSHUT* and SV_STSHUT* were removed where
possible. Some of them could not be removed because they are
still in use by the unix sockets.

A bug remains at this stage. Injecting with a very short timeout
sometimes leads to a client in close state and a server in data
state with all buffer flags indicating a shutdown but the server
fd still enable, thus causing a busy loop.

16 years ago[MAJOR] clearly separate HTTP response processing from TCP server state
Willy Tarreau [Fri, 15 Aug 2008 21:43:19 +0000 (23:43 +0200)] 
[MAJOR] clearly separate HTTP response processing from TCP server state

The HTTP response is now processed in its own function, regardless of
the TCP state. All FSMs have become fairly simpler and must still be
improved by removing useless CL_STSHUT* and SV_STSHUT* (still used by
proto_uxst). The number of calls to process_* is still huge though.

Next steps consist in :
  - removing useless assignments of CL_STSHUT* and SV_STSHUT*
  - add a BF_EMPTY flag to buffers to indicate an empty buffer
  - returning smarter values in process_* so that each callee
    may explicitly indicate whom needs to be called after it.
  - unify read and write timeouts for a same side. The way it
    is now is too complicated and error-prone
  - auditing code for regression testing

We're close to getting something which works fairly better now.

16 years ago[MAJOR] better separation of response processing and server state
Willy Tarreau [Fri, 15 Aug 2008 16:16:37 +0000 (18:16 +0200)] 
[MAJOR] better separation of response processing and server state

TCP timeouts are not managed anymore by the response FSM. Warning,
the FORCE_CLOSE state does not work anymore for now. All remaining
bugs causing stale connections have been swept.

16 years ago[MAJOR] get rid of the SV_STHEADERS state
Willy Tarreau [Thu, 14 Aug 2008 16:35:40 +0000 (18:35 +0200)] 
[MAJOR] get rid of the SV_STHEADERS state

The HTTP response code has been moved to a specific function
called "process_response" and the SV_STHEADERS state has been
removed and replaced with the flag AN_RTR_HTTP_HDR.

16 years ago[BUG] fix recently introduced loop when client closes early
Willy Tarreau [Wed, 13 Aug 2008 17:19:37 +0000 (19:19 +0200)] 
[BUG] fix recently introduced loop when client closes early

Due to a recent change in the FSMs, if the client closes with buffer
full, then the server loops waiting for headers. We can safely ignore
this case since the server FSM will have to be reworked too. Let's
fix the root cause for now.

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.

16 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.

16 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.

16 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.

16 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.

16 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.

16 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