]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
10 years agoCLEANUP: session: simplify references to chn_{prod,cons}(&s->{req,res})
Willy Tarreau [Fri, 28 Nov 2014 13:42:25 +0000 (14:42 +0100)] 
CLEANUP: session: simplify references to chn_{prod,cons}(&s->{req,res})

These 4 combinations are needlessly complicated since the session already
has direct access to the associated stream interfaces without having to
check an indirect pointer.

10 years agoMEDIUM: channel: remove now unused ->prod and ->cons pointers
Willy Tarreau [Fri, 28 Nov 2014 13:23:47 +0000 (14:23 +0100)] 
MEDIUM: channel: remove now unused ->prod and ->cons pointers

Nothing uses them anymore.

10 years agoMAJOR: channel: only rely on the new CF_ISRESP flag to find the SI
Willy Tarreau [Fri, 28 Nov 2014 13:22:12 +0000 (14:22 +0100)] 
MAJOR: channel: only rely on the new CF_ISRESP flag to find the SI

Now we exclusively use this flag to find what side a channel is and
where the stream ints are. The ->prod and ->cons are not used anymore.

10 years agoMEDIUM: channel: add a new flag "CF_ISRESP" for the response channel
Willy Tarreau [Fri, 28 Nov 2014 13:17:09 +0000 (14:17 +0100)] 
MEDIUM: channel: add a new flag "CF_ISRESP" for the response channel

This flag designates the response channel. This will be used to know
what channel we're seeing and finding our way back to the session.

10 years agoREORG/MEDIUM: channel: only use chn_prod / chn_cons to find stream-interfaces
Willy Tarreau [Fri, 28 Nov 2014 13:10:28 +0000 (14:10 +0100)] 
REORG/MEDIUM: channel: only use chn_prod / chn_cons to find stream-interfaces

The purpose of these two macros will be to pass via the session to
find the relevant stream interfaces so that we don't need to store
the ->cons nor ->prod pointers anymore. Currently they're only defined
so that all references could be removed.

Note that many places need a second pass of clean up so that we don't
have any chn_prod(&s->req) anymore and only &s->si[0] instead, and
conversely for the 3 other cases.

10 years agoCLEANUP: stream-int: add si_opposite() to find the other stream interface
Willy Tarreau [Fri, 28 Nov 2014 12:59:31 +0000 (13:59 +0100)] 
CLEANUP: stream-int: add si_opposite() to find the other stream interface

At a few places we need to find one stream interface from the other one.
Instead of passing via the channel, we simply use the session as an
intermediary, which simply results in applying an offset to the pointer.

10 years agoCLEANUP: stream-int: add si_ib/si_ob to dereference the buffers
Willy Tarreau [Fri, 28 Nov 2014 11:18:45 +0000 (12:18 +0100)] 
CLEANUP: stream-int: add si_ib/si_ob to dereference the buffers

This makes the code cleaner and is more intuitive to use.

10 years agoMEDIUM: stream-int: remove any reference to the owner
Willy Tarreau [Fri, 28 Nov 2014 11:12:34 +0000 (12:12 +0100)] 
MEDIUM: stream-int: remove any reference to the owner

si->owner is not used anymore now, so let's remove any reference to it.

10 years agoMEDIUM: stream-int: use si_task() to retrieve the task from the stream int
Willy Tarreau [Fri, 28 Nov 2014 11:08:47 +0000 (12:08 +0100)] 
MEDIUM: stream-int: use si_task() to retrieve the task from the stream int

We go back to the session to get the owner. Here again it's very easy
and is just a matter of relative offsets. Since the owner always exists
and always points to the session's task, we can remove some unneeded
tests.

10 years agoMEDIUM: stream-int: make si_sess() use the stream int's side
Willy Tarreau [Fri, 28 Nov 2014 11:03:32 +0000 (12:03 +0100)] 
MEDIUM: stream-int: make si_sess() use the stream int's side

This one relies on the SI's side to find the pointer to the session.
That the stream interface doesn't have to look at the task's context
anymore.

10 years agoMEDIUM: stream-interface: remove now unused pointers to channels
Willy Tarreau [Fri, 28 Nov 2014 10:53:35 +0000 (11:53 +0100)] 
MEDIUM: stream-interface: remove now unused pointers to channels

Everyone must now use si_ic() / si_oc() to find the relevant channels,
the points have been totally removed.

10 years agoMAJOR: stream-int: only rely on SI_FL_ISBACK to find the requested channel
Willy Tarreau [Fri, 28 Nov 2014 10:50:38 +0000 (11:50 +0100)] 
MAJOR: stream-int: only rely on SI_FL_ISBACK to find the requested channel

In order to plan removal of si->ib / si->ob, we now check the side of the
stream interface and find the session, then the requested channel. In
practice it's just an offset applied to the pointer based on the flag.

10 years agoMEDIUM: stream-int: add a flag indicating which side the SI is on
Willy Tarreau [Fri, 28 Nov 2014 10:26:07 +0000 (11:26 +0100)] 
MEDIUM: stream-int: add a flag indicating which side the SI is on

This new flag "SI_FL_ISBACK" is set only on the back SI and is cleared
on the front SI. That way it's possible only by looking at the SI to
know what side it is.

10 years agoREORG/MEDIUM: stream-int: introduce si_ic/si_oc to access channels
Willy Tarreau [Fri, 28 Nov 2014 10:11:05 +0000 (11:11 +0100)] 
REORG/MEDIUM: stream-int: introduce si_ic/si_oc to access channels

We'll soon remove direct references to the channels from the stream
interface since everything belongs to the same session, so let's
first not dereference si->ib / si->ob anymore and use macros instead.

10 years agoCLEANUP: remove now unused channel pool
Willy Tarreau [Thu, 27 Nov 2014 21:10:04 +0000 (22:10 +0100)] 
CLEANUP: remove now unused channel pool

The channels are now part of the struct session. Their pool is
not needed anymore.

10 years agoREORG/MAJOR: move session's req and resp channels back into the session
Willy Tarreau [Thu, 27 Nov 2014 19:45:39 +0000 (20:45 +0100)] 
REORG/MAJOR: move session's req and resp channels back into the session

The channels were pointers to outside structs and this is not needed
anymore since the buffers have moved, but this complicates operations.
Move them back into the session so that both channels and stream interfaces
are always allocated for a session. Some places (some early sample fetch
functions) used to validate that a channel was NULL prior to dereferencing
it. Now instead we check if chn->buf is NULL and we force it to remain NULL
until the channel is initialized.

10 years agoDOC: lua api
Thierry FOURNIER [Wed, 11 Mar 2015 19:31:00 +0000 (20:31 +0100)] 
DOC: lua api

This contains the Lua API documentation and the build environment
for Sphinx.

10 years agoMINOR: lua: fetches and converters can return an empty string in place of nil
Thierry FOURNIER [Wed, 11 Mar 2015 19:13:36 +0000 (20:13 +0100)] 
MINOR: lua: fetches and converters can return an empty string in place of nil

In some cases we don't want to known if a fetch or converter
fails. We just want a valid string. After this patch, we
have two sets of fetches and two sets of converters. There are:
txn.f, txn.sf, txn.c, txn.sc. The version prefixed by 's' always
returns strings for any type, and returns an empty string in the
error case or when the data are not available. This is particularly
useful when manipulating headers or cookies.

10 years agoMINOR: lua: replace function (req|get)_channel by a variable
Thierry FOURNIER [Wed, 11 Mar 2015 18:39:09 +0000 (19:39 +0100)] 
MINOR: lua: replace function (req|get)_channel by a variable

To add data in channel, it is necessary to process in two times.
First time, get the channel object, and after send data:

   local req = txn:req_channel()
req:send("data\n")

Now, the function is converted as a variable containing the req
and res aobject. We can process as following:

   txn.req:send("data\n")

10 years agoMINOR: lua: wrapper for converters
Thierry FOURNIER [Tue, 10 Mar 2015 22:58:30 +0000 (23:58 +0100)] 
MINOR: lua: wrapper for converters

This patch implements a wrapper to give access to the converters
in the Lua code. The converters are used with the transaction.
The automatically created function are prefixed by "conv_".

10 years agoMINOR: converters: add function to browse converters
Thierry FOURNIER [Tue, 10 Mar 2015 22:56:48 +0000 (23:56 +0100)] 
MINOR: converters: add function to browse converters

This patch adds a fucntion to browse each converter. This
is used with Lua for using the converters with a wrapper.

10 years agoMEDIUM: lua: create a namespace for the fetches
Thierry FOURNIER [Wed, 11 Mar 2015 17:28:02 +0000 (18:28 +0100)] 
MEDIUM: lua: create a namespace for the fetches

HAProxy proposes many sample fetches. It is possible that the
automatic registration of the sample fetches causes a collision
with an existing Lua function. This patch sets a namespace for
the sample fetches.

10 years agoMEDIUM: lua: change the objects configuration
Thierry FOURNIER [Wed, 11 Mar 2015 16:43:33 +0000 (17:43 +0100)] 
MEDIUM: lua: change the objects configuration

Actually an object is just a userdata value with a metatable.
This mode causes some problems like I can't add lua own data.
This new model uses an array as object base, and affect the
userdata at the index 0.

10 years agoMINOR: replace the Core object by a simple model.
Thierry FOURNIER [Wed, 11 Mar 2015 16:29:39 +0000 (17:29 +0100)] 
MINOR: replace the Core object by a simple model.

The core entry is just a collection of function, it doesn't depends on
special variable. This patch just converts an object contained in a
metatable in object contained in a normal table.

10 years agoCLEANUP: lua: use the same function names in C and Lua
Willy Tarreau [Tue, 10 Mar 2015 13:23:13 +0000 (14:23 +0100)] 
CLEANUP: lua: use the same function names in C and Lua

A few function names in Lua had underscores which did not appear in their
C counterpart. Since almost all of them already had similar names, better
uniformize the naming convention.

10 years agoMINOR: lua: convert IP addresses to type string
Willy Tarreau [Tue, 10 Mar 2015 16:28:54 +0000 (17:28 +0100)] 
MINOR: lua: convert IP addresses to type string

For now we don't perform any operation on IP addresses, so at least
we'd like to be able to pass them as strings so that we can log them
or whatever in Lua. Without this patch txn.src(txn) returns "nil" and
now it returns the correct IP address.

10 years agoMEDIUM: lua: make the functions hlua_gethlua() and hlua_sethlua() faster
Thierry FOURNIER [Tue, 10 Mar 2015 01:40:29 +0000 (02:40 +0100)] 
MEDIUM: lua: make the functions hlua_gethlua() and hlua_sethlua() faster

Lua 5.3 provides an opaque space associated with each
coroutine stack. This patch uses this lot of memory to
store the "struct hlua *" associated pointer.

This patch makes the retrieval of the "struct hlua *"
associated struct faster because it replace a lookup in
a tree by an immediate access to the data.

10 years agoRevert "BUG/MEDIUM: lua: can't handle the response bytes"
Willy Tarreau [Tue, 10 Mar 2015 16:16:10 +0000 (17:16 +0100)] 
Revert "BUG/MEDIUM: lua: can't handle the response bytes"

This reverts commit cd9084f77683106ace2fb863080e7d10e71c39fc.

This commit introduced a regression making it impossible to leave
process_session() during a forced yield because the analyser was always
set on the response even if not needed. The result was a busy loop
making haproxy spin at 100% without even polling anymore in case a
forced yield was performed.

The problem it tried to address (intercept response data from a request
analyser before forwarding) is not a trivial issue to address since
wakeups based on reads will not necessarily happen unless there's write
activity.

Anyway, if functions are attached specifically to a request or to a
response, it's for a reason. So for now let's be clear about the fact
that it's unreliable to try to process data from the opposite channel
until a better solution is found.

10 years agoBUG/MAJOR: http: fix stats regression consecutive to HTTP_RULE_RES_YIELD
Willy Tarreau [Tue, 10 Mar 2015 14:25:54 +0000 (15:25 +0100)] 
BUG/MAJOR: http: fix stats regression consecutive to HTTP_RULE_RES_YIELD

Commit bc4c1ac ("MEDIUM: http/tcp: permit to resume http and tcp custom actions")
unfortunately broke the stats applet by moving the clearing of the analyser bit
after processing the applet headers. It used to work only in HTTP/1.1 and not
in HTTP/1.0. This is 1.6-specific, no backport is needed.

10 years agoBUG/MINOR: lua: report the correct function name in an error message
Willy Tarreau [Tue, 10 Mar 2015 13:22:28 +0000 (14:22 +0100)] 
BUG/MINOR: lua: report the correct function name in an error message

"req_channel" was reported instead of "res_channel". This is harmless.

10 years agoBUG/MEDIUM: buffer: one byte miss in buffer free space check
Thierry FOURNIER [Tue, 10 Mar 2015 00:55:01 +0000 (01:55 +0100)] 
BUG/MEDIUM: buffer: one byte miss in buffer free space check

Space is not avalaible only if the end of the data inserted
is strictly greater than the end of buffer. If these two value
are equal, the space is avamaible.

10 years agoBUG/BUILD: lua: The strict Lua 5.3 version check is not done.
Thierry FOURNIER [Mon, 9 Mar 2015 23:35:36 +0000 (00:35 +0100)] 
BUG/BUILD: lua: The strict Lua 5.3 version check is not done.

This patch fix the Lua library check. Only the version
5.3 or later is allowed.

This bug is added by the patch "MEDIUM: lua: use the
Lua-5.3 version of the library" with commit id

   f90838b71a3c7f84e1d8b4ff85760a35d60c6910

10 years agoBUG/MINOR: lua: sockets receive behavior doesn't follows the specs
Thierry FOURNIER [Mon, 9 Mar 2015 17:35:06 +0000 (18:35 +0100)] 
BUG/MINOR: lua: sockets receive behavior doesn't follows the specs

Specs says that the receive() function with an argument "*l"
must return a line without the final "\n" ( or without "\r\n").
This patch removes these two final bytes.

10 years agoBUG/MEDIUM: lua: cannot connect socket
Thierry FOURNIER [Mon, 9 Mar 2015 17:12:40 +0000 (18:12 +0100)] 
BUG/MEDIUM: lua: cannot connect socket

The Lua stack is not waked up when the connect() receive a positive
or negatibe response. This patch adds a signal to wake up the Lua
stack.

10 years agoBUG/MEDIUM: lua: sockets don't have buffer to write data
Thierry FOURNIER [Mon, 9 Mar 2015 16:51:43 +0000 (17:51 +0100)] 
BUG/MEDIUM: lua: sockets don't have buffer to write data

When we try to write data in a session from another session, the "req"
buffer is not allowed. This patch try to allocate the buffer. The session
wait if the buffer is not yet avalaible.

10 years agoBUG/MINOR: log: segfault if there are no proxy reference
Thierry FOURNIER [Mon, 9 Mar 2015 16:10:29 +0000 (17:10 +0100)] 
BUG/MINOR: log: segfault if there are no proxy reference

The HAProxy API allow to send log without defined proxy (it
set to the NULL value). An incomplete test if done to choose
the log tag and an invalid pointer is dereferenced.

10 years agoBUG/MINOR: lua: check buffers before initializing socket
Thierry FOURNIER [Mon, 9 Mar 2015 16:07:10 +0000 (17:07 +0100)] 
BUG/MINOR: lua: check buffers before initializing socket

When a socket is initilized in the body context, a segfaut is generated
because the memory pools are not initilized. This atch check if these
memory pool are initialized.

10 years agoBUG/MEDIUM: lua: segfault with buffer_replace2
Thierry FOURNIER [Sat, 7 Mar 2015 13:38:50 +0000 (14:38 +0100)] 
BUG/MEDIUM: lua: segfault with buffer_replace2

The function buffer_contig_space() returns the contiguous space avalaible
to add data (at the end of the input side) while the function
hlua_channel_send_yield() needs to insert data starting at p. Here we
introduce a new function bi_space_for_replace() which returns the amount
of space that can be inserted at the head of the input side with one of
the buffer_replace* functions.

This patch proposes a function that returns the space avalaible after buf->p.

10 years agoBUG/MEDIUM: lua: can't handle the response bytes
Thierry FOURNIER [Sat, 7 Mar 2015 14:11:09 +0000 (15:11 +0100)] 
BUG/MEDIUM: lua: can't handle the response bytes

The request action can't handle the reponse trafic because its
automatically forwarded. The forard with CHN_INFINITE_FORWARD
is set because any anamizers are registered on  the response
channel.

This patch automatically register the request analyzer on the
reponse channel when its yield. This prevent the automatic
tranfer of the response bytes.

10 years agoBUG/MAJOR: lua: some function are not yieldable, the forced yield causes errors
Thierry FOURNIER [Fri, 6 Mar 2015 13:05:24 +0000 (14:05 +0100)] 
BUG/MAJOR: lua: some function are not yieldable, the forced yield causes errors

The hook function called each nth Lua instructions just
do a yield. Sometimes this yield is not allowed, because
some functions are not compatible.

The Lua-5.3 permits to known if the yield is avalaible with
the function lua_isyieldable().

If the processing is interrupted in non yieldable state,
we try to execute a yield asap. The yield will be may
available at the end of the non-yieldable currently
executed function. So, we require interrupt at the end
of the current function.

But, Lua cannot yield when its returning from a function,
so, we can fix the interrupt hook to 1 instruction,
expecting that the function is finnished.

During this time, the execution timeout is always checked.

10 years agoMEDIUM: lua: use the Lua-5.3 version of the library
Thierry FOURNIER [Fri, 6 Mar 2015 12:48:32 +0000 (13:48 +0100)] 
MEDIUM: lua: use the Lua-5.3 version of the library

The Lua-5.3 version of the library adds a required function to fix
a bug with the forced-yield system.

This patch permits to build with the Lua-5.3 library. Main changes
are:
 - "unsigned" type disappear to be replaced by signed type,
 - prototype of the yield function callback changes.

10 years agoBUG/MEDIUM: lua: many errors when we try to send data with the channel API
Thierry FOURNIER [Fri, 6 Mar 2015 00:07:45 +0000 (01:07 +0100)] 
BUG/MEDIUM: lua: many errors when we try to send data with the channel API

First we allow to use the reserved size to write the data that
will be sent. The reserved size remain guaranty because the
writed data will be sent quickly and the reserved room we be
again avalaible.

This permits to guaranty that the function send always have
avalaible space to send data (except if it cannot connect to
the server).

The function buffer_replace2 works only on contiguous buffer.
This patch also detects if the required size is contiguous.
If it not the case we realign the buffer.

10 years agoBUG/MEDIUM: lua: the Lua process is not waked up after sending data on requests side
Thierry FOURNIER [Thu, 5 Mar 2015 23:35:53 +0000 (00:35 +0100)] 
BUG/MEDIUM: lua: the Lua process is not waked up after sending data on requests side

If we are writing in the request buffer, we are not waked up
when the data are forwarded because it is useles. The request
analyzers are waked up only when data is incoming. So, if the
request buffer is full, we set the WAKE_ON_WRITE flag.

10 years agoBUG/MEDIUM: lua: fix infinite loop about channel
Thierry FOURNIER [Thu, 5 Mar 2015 16:45:34 +0000 (17:45 +0100)] 
BUG/MEDIUM: lua: fix infinite loop about channel

Before this patch, each yield in a Lua action set a flags to be
waked up when some activity were detected on the response channel.
This behavior causes loop in the analyzer process.

This patch set the wake up on response buffer activity only if we
really want to be waked up on this activity.

10 years agoBUG/MEDIUM: lua: reset flags before resuming execution
Thierry FOURNIER [Thu, 5 Mar 2015 16:10:14 +0000 (17:10 +0100)] 
BUG/MEDIUM: lua: reset flags before resuming execution

This patch reset the flags except th run flag before resuming
the Lua execution. If this initialisation is not done, some
flags can remain at the end of the Lua execution and give bad
informations.

10 years agoBUG/MINOR: lua: set buffer if it is nnot avalaible.
Thierry FOURNIER [Thu, 5 Mar 2015 16:06:12 +0000 (17:06 +0100)] 
BUG/MINOR: lua: set buffer if it is nnot avalaible.

Check if the buffer is avalaible because HAProxy doesn't allocate
the request buffer if its not required. Sometimes, the Lua need to
write some data to the server before that the client send his data.

10 years agoMINOR: lua: add the struct session in the lua channel struct
Thierry FOURNIER [Thu, 5 Mar 2015 16:04:41 +0000 (17:04 +0100)] 
MINOR: lua: add the struct session in the lua channel struct

This is used later to modify some flags in the session.

10 years agoDOC: lua: Lua configuration documentation
Thierry FOURNIER [Thu, 5 Mar 2015 10:17:06 +0000 (11:17 +0100)] 
DOC: lua: Lua configuration documentation

This patch adds the documentation of the Lua configuration directives.
The documentation was read back by Andjelko Iharos.

10 years agoBUG/MEDIUM: lua: the execution timeout is ignored in yield case
Thierry FOURNIER [Thu, 5 Mar 2015 10:16:52 +0000 (11:16 +0100)] 
BUG/MEDIUM: lua: the execution timeout is ignored in yield case

This patch check the expiration of the execution timeout for each
yield source, and test also the execution timeout before resuming
the execution of the Lua code.

10 years agoBUG/MEDIUM: task: fix recently introduced scheduler skew
Willy Tarreau [Wed, 4 Mar 2015 22:26:01 +0000 (23:26 +0100)] 
BUG/MEDIUM: task: fix recently introduced scheduler skew

Commit 501260b ("MEDIUM: task: always ensure that the run queue is
consistent") introduced a skew in the scheduler : if a negatively niced
task is woken up, it can be inserted prior to the current index and will
be skipped as long as there is some activity with less prioritary tasks.
The immediate effect is that it's not possible to get access to the stats
under full load until the load goes down.

This is because the rq_next constantly evolves within more recent
positions. The fix is simple, __task_wakeup() must empty rq_next. The
sad thing is that this issue was fixed during development and missed
during the commit. No backport is needed, this is purely 1.6 stuff.

10 years agoMEDIUM: lua: change the sleep function core
Thierry FOURNIER [Wed, 4 Mar 2015 14:51:09 +0000 (15:51 +0100)] 
MEDIUM: lua: change the sleep function core

This patch uses the last yield functionalities. The sleep function
just return the wake up time.

10 years agoMEDIUM: lua: interrupt the Lua execution for running other process
Thierry FOURNIER [Tue, 3 Mar 2015 16:37:37 +0000 (17:37 +0100)] 
MEDIUM: lua: interrupt the Lua execution for running other process

This patch permits to interrupt the Lua execution each n# of
instructions. It is useful for controling the execution time
of an Lua code, and permits at the HAProxy schedule to process
some others tasks waiting execution.

10 years agoMINOR: lua: adds "forced yield" flag
Thierry FOURNIER [Tue, 3 Mar 2015 16:29:06 +0000 (17:29 +0100)] 
MINOR: lua: adds "forced yield" flag

This flag indicate that the current yield is returned by the Lua
execution task control. If this flag is set, the current task may
quit but will be set in the run queue to be re-executed immediatly.

This patch modify the "hlua_yieldk()" function, it adds an argument
that contain a field containing yield options.

10 years agoMEDIUM: lua: each yielding function returns a wake up time.
Thierry FOURNIER [Tue, 3 Mar 2015 16:17:55 +0000 (17:17 +0100)] 
MEDIUM: lua: each yielding function returns a wake up time.

This is used to ensure that the task doesn't become a zombie
when the Lua returns a yield. The yield wrapper ensure that an
timer used for waking up the task will be set.

The timer is reseted to TICK_ETERNITY if the Lua execution is
done.

10 years agoMINOR: lua: set skeleton for Lua execution expiration
Thierry FOURNIER [Tue, 3 Mar 2015 15:52:26 +0000 (16:52 +0100)] 
MINOR: lua: set skeleton for Lua execution expiration

This first patch permits to cofigure the Lua execution exipiration.
This expiration is configured but it is not yet avalaible, it will
be add in a future patch.

10 years agoMINOR: lua: use bitfield and macro in place of integer and enum
Thierry FOURNIER [Tue, 3 Mar 2015 14:17:35 +0000 (15:17 +0100)] 
MINOR: lua: use bitfield and macro in place of integer and enum

In the future, the lua execution must return scheduling informations.
We want more than one flag, so I convert an integer used with an
enum into an interer used as bitfield.

10 years agoMINOR: lua: remove some #define
Thierry FOURNIER [Wed, 4 Mar 2015 15:48:34 +0000 (16:48 +0100)] 
MINOR: lua: remove some #define

The #define compilation directives are centralized in the hlua
include files. This permits to remove ome #ifdef from the haproxy
main code.

10 years agoMINOR: remove unused declaration.
Thierry FOURNIER [Wed, 4 Mar 2015 15:46:37 +0000 (16:46 +0100)] 
MINOR: remove unused declaration.

This declaration is removed in the patch 'Lua initialisation on demand".
commit id 05ac42455fab8bba252bf124d6c450402429fd39

10 years agoBUG/MAJOR: lua: send function fails and return bad bytes
Thierry FOURNIER [Wed, 4 Mar 2015 10:44:47 +0000 (11:44 +0100)] 
BUG/MAJOR: lua: send function fails and return bad bytes

In some cases the Lua "send" function fails. This is caused by the
return of "buffer_replace2()" is not tested. I checked avalaible space
in the buffer and I supposed than "buffer_replace2()" took all the
data. In some cases, "buffer_replace2()" cannot take the incoming
data, it returns the amount of data copied.

This patch check the amount of data really copied by "buffer_replace2()"
and advance the buffer with taking this value in account.

10 years agoBUILD/CLEANUP: systemd: avoid a warning due to mixed code and declaration
Cyril Bonté [Tue, 3 Mar 2015 22:26:14 +0000 (23:26 +0100)] 
BUILD/CLEANUP: systemd: avoid a warning due to mixed code and declaration

Gcc complains because the systemd wrapper mixed code and declaration :
"warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]".

10 years agoBUILD: try to automatically detect the Lua library name
Cyril Bonté [Tue, 3 Mar 2015 22:13:03 +0000 (23:13 +0100)] 
BUILD: try to automatically detect the Lua library name

Depending on the distribution, the Lua library can have different names.
Some distributions will require -llua5.2, others -llua52, and other systems may
require -llua.

Now, the Makefile will try to guess the library name, in order of priority :
"lua5.2", "lua52", or "lua".

10 years agoBUILD: lua: missing ifdef related to SSL when enabling LUA
Baptiste Assmann [Mon, 2 Mar 2015 20:40:06 +0000 (21:40 +0100)] 
BUILD: lua: missing ifdef related to SSL when enabling LUA

A couple of ifdef are missing around SSL related functions in LUA.
It prevents from compiling LUA without SSL.
Current patch fix this.

10 years agoBUG/MEDIUM: lua: segfault when calling haproxy sample fetches from lua
Cyril Bonté [Sun, 1 Mar 2015 23:08:41 +0000 (00:08 +0100)] 
BUG/MEDIUM: lua: segfault when calling haproxy sample fetches from lua

When a Lua script calls an internal haproxy sample fetch, it may segfault in
some conditions :
- when a fetch has no argument,
- when there is no room left to store the special type ARGT_STOP in the argument
  list (this one shouldn't happen currently as there isn't any sample fetch with
  enough arguments to fill the allocated buffer).

Example of Lua code which reproduces a segfault :
core.register_fetches("segfault", function(txn, ...)
  return txn.req_ver(txn)
end)

10 years agoMINOR: lua: add a compilation error message when compiled with an incompatible version
Cyril Bonté [Sun, 1 Mar 2015 23:08:40 +0000 (00:08 +0100)] 
MINOR: lua: add a compilation error message when compiled with an incompatible version

haproxy Lua support begins with Lua 5.2. In order to ease the diagnostic on
compilation error, a preprocessor error is added when an incompatible version
is used.

The compatibility is determined by the presence of LUA_VERSION_NUM and its
magic value (502 for Lua 5.2.x).

10 years agoMINOR: report the Lua version in -vv
Cyril Bonté [Sun, 1 Mar 2015 23:08:39 +0000 (00:08 +0100)] 
MINOR: report the Lua version in -vv

As of the other libraries used by haproxy, it can be useful to display the Lua
version used at compilation time.
A new line is added to "haproxy -vv", which shows if Lua is supported by the
binary, and with which version it was compiled.

10 years agoMINOR: lua: typo in an error message
Cyril Bonté [Sun, 1 Mar 2015 23:08:38 +0000 (00:08 +0100)] 
MINOR: lua: typo in an error message

A small typo was introduced in an error message, occuring when too many
arguments are provided ("Malformed argument mask").

10 years agoMEDIUM: lua: Lua initialisation "on demand"
Thierry FOURNIER [Fri, 27 Feb 2015 17:37:27 +0000 (18:37 +0100)] 
MEDIUM: lua: Lua initialisation "on demand"

Actually, the Lua context is always initilized in each
session, even if the session doesn't use Lua. This
behavior cause 5% performances loss.

This patch initilize the Lua only if it is use by the
session. The initialization is now on demand.

10 years agoBUILD: lua: cleanup many mixed occurrences declarations & code
Willy Tarreau [Fri, 27 Feb 2015 15:38:20 +0000 (16:38 +0100)] 
BUILD: lua: cleanup many mixed occurrences declarations & code

The code was a bit of a pain to follow because of this, especially
when some of it heavily relies on longjmp... This refreshing makes
it slightly easier to read.

10 years agoMINOR: lua: txn: add binding for closing the client connection.
Thierry FOURNIER [Tue, 17 Feb 2015 17:42:34 +0000 (18:42 +0100)] 
MINOR: lua: txn: add binding for closing the client connection.

10 years agoMINOR: lua: core: can yield an execution stack
Thierry FOURNIER [Tue, 17 Feb 2015 14:01:59 +0000 (15:01 +0100)] 
MINOR: lua: core: can yield an execution stack

This patch provides a yield function. This function permits to
give back the hand at the HAProxy scheduler. It is used when the
lua processing consumes a lot of time.

10 years agoMINOR: lua: core: can set the nice of the current task
Thierry FOURNIER [Mon, 16 Feb 2015 18:34:56 +0000 (19:34 +0100)] 
MINOR: lua: core: can set the nice of the current task

This patch adds an LUA binding that permits to change the
task priority.

10 years agoMINOR: lua: txn: object "txn" provides two objects "channel"
Thierry FOURNIER [Tue, 17 Feb 2015 13:59:53 +0000 (14:59 +0100)] 
MINOR: lua: txn: object "txn" provides two objects "channel"

This patch adds two functions that creates and returns channel
object from a txn object.

10 years agoMINOR: lua: channel: add "channel" class
Thierry FOURNIER [Mon, 9 Feb 2015 15:38:34 +0000 (16:38 +0100)] 
MINOR: lua: channel: add "channel" class

The channel class permits manipulation of channels. A channel is
an FIFO buffer between the client and the server. This class provides
function to read, write, forward, destroy and alter data between
the input and the ouput of the buffer.

10 years agoMINOR: lua: core: pattern and acl manipulation
Thierry FOURNIER [Wed, 4 Feb 2015 12:21:04 +0000 (13:21 +0100)] 
MINOR: lua: core: pattern and acl manipulation

The functions added by this patch add LUA bindings for the ACL
and map manipulation.

10 years agoMEDIUM: lua: socket: add "socket" class for TCP I/O
Thierry FOURNIER [Mon, 16 Feb 2015 18:27:16 +0000 (19:27 +0100)] 
MEDIUM: lua: socket: add "socket" class for TCP I/O

This patch adds the TCP I/O functionnality. The class implemented
provides the same functions than the "lua socket" project. This
make network compatibility with another LUA project. The documentation
is located here:

   http://w3.impa.br/~diego/software/luasocket/tcp.html

10 years agoMINOR: lua: core: add sleep functions
Thierry FOURNIER [Mon, 16 Feb 2015 18:43:25 +0000 (19:43 +0100)] 
MINOR: lua: core: add sleep functions

This version of sleep is based on a coroutine. A sleeping
task is started and a signal is registered. This sleep version
must disapear to be replaced by a version using the internal
timers.

10 years agoMINOR: lua: add bindings for tcp and http actions
Thierry FOURNIER [Mon, 16 Feb 2015 19:23:40 +0000 (20:23 +0100)] 
MINOR: lua: add bindings for tcp and http actions

This patch adds the runtime environment for http and tcp actions.
It provides also the function for action registering.

10 years agoMINOR: lua: register and execute converters in LUA
Thierry FOURNIER [Mon, 16 Feb 2015 19:21:12 +0000 (20:21 +0100)] 
MINOR: lua: register and execute converters in LUA

This patch permits to write LUA converters. Note that
all the converters declared trough LUA are automatically
prefixed by "lua.".

The Lua converters needs the current session to be executed,
but the writed and executed Lua code must be static and
contextless. The TXN object is not created for the converters.

10 years agoMINOR: lua: register and execute sample-fetches in LUA
Thierry FOURNIER [Mon, 16 Feb 2015 19:19:18 +0000 (20:19 +0100)] 
MINOR: lua: register and execute sample-fetches in LUA

This patch permits to write LUA samples fetches. Note that
all the fethes declared trough LUA are automatically prefixed
by "lua.".

10 years agoMINOR: lua: txn: add lua function in TXN that returns an array of http headers
Thierry FOURNIER [Mon, 16 Feb 2015 19:22:55 +0000 (20:22 +0100)] 
MINOR: lua: txn: add lua function in TXN that returns an array of http headers

This patch adds an LUA binding that returns an array of
HTTP headers. The key is the header name and the value is
the header value.

10 years agoMINOR: lua: txn: import existing sample-fetches in the class TXN
Thierry FOURNIER [Mon, 16 Feb 2015 19:14:51 +0000 (20:14 +0100)] 
MINOR: lua: txn: import existing sample-fetches in the class TXN

This patch adds the browsing of all the HAProxy fetches and
create associated LUA functions. The HAProxy internal fetches
can be used in LUA trough the class "TXN".

Note that the symbols "-", "+" and "." in the name of current
sample fetch are rewrited as "_" in LUA because ".", "-" and "+"
are operators.

10 years agoMINOR: lua: add shared context in the lua stack
Thierry FOURNIER [Wed, 25 Feb 2015 10:43:21 +0000 (11:43 +0100)] 
MINOR: lua: add shared context in the lua stack

The shared context is a global reference dedicated to one Lua stack.
Even if the TXN is not required, the shared context it is associated
with a TXN object. In fact, the shared has no sense outside a TXN
context

10 years agoMINOR: lua: txn: create class TXN associated with the transaction.
Thierry FOURNIER [Mon, 16 Feb 2015 19:11:43 +0000 (20:11 +0100)] 
MINOR: lua: txn: create class TXN associated with the transaction.

This class of functions permit to access to all the functions
associated with the transaction like http header, HAProxy internal
fetches, etc ...

This patch puts the skeleton of this class. The class will be
enhanced later.

10 years agoMINOR: lua: add sample and args type converters
Thierry FOURNIER [Fri, 23 Jan 2015 10:36:30 +0000 (11:36 +0100)] 
MINOR: lua: add sample and args type converters

These function are used for converting LUA value in HAProxy values.
This is helpful with sample-fetch and converter wrappers.

10 years agoMEDIUM: lua: add coroutine as tasks.
Thierry FOURNIER [Fri, 23 Jan 2015 11:13:00 +0000 (12:13 +0100)] 
MEDIUM: lua: add coroutine as tasks.

This LUA subsystem permits to execute LUA code in parallel of the
main HAProxy activity. This is useful for periodic updates or
special checks.

10 years agoMINOR: lua: post initialisation bindings
Thierry FOURNIER [Fri, 23 Jan 2015 11:08:30 +0000 (12:08 +0100)] 
MINOR: lua: post initialisation bindings

This system permits to execute some lua function after than HAProxy
complete his initialisation. These functions are executed between
the end of the configuration parsing and check and the begin of the
scheduler.

10 years agoMINOR: lua: core: create "core" class and object
Thierry FOURNIER [Fri, 23 Jan 2015 13:07:08 +0000 (14:07 +0100)] 
MINOR: lua: core: create "core" class and object

This object provides main HAProxy functions. This first version
creates an empty object. It will be enhanced later.

10 years agoMINOR: lua: add the configuration directive "lua-load"
Thierry FOURNIER [Fri, 23 Jan 2015 14:57:06 +0000 (15:57 +0100)] 
MINOR: lua: add the configuration directive "lua-load"

This directive is encoutered in the global section of the HAProxy
configuration file. It permits to load and execute an LUA file.

10 years agoMEDIUM: lua: "com" signals
Thierry FOURNIER [Fri, 23 Jan 2015 10:08:20 +0000 (11:08 +0100)] 
MEDIUM: lua: "com" signals

This system permits to send signals between lua tasks. A main lua stack can
register the signal in a coprocess. When the coprocess finish his job, it
send a signal, and the associated task is wakes. If the main lua execution
stack stop (with or without errors), the list or pending signals is purged.

10 years agoMINOR: lua: add runtime execution context
Thierry FOURNIER [Fri, 23 Jan 2015 13:27:52 +0000 (14:27 +0100)] 
MINOR: lua: add runtime execution context

The functions added permits to execute the LUA stack execution in
HAProxy. It provides all the runtie environment and initialise the
main LUA stack.

10 years agoMINOR: lua: add ease functions
Thierry FOURNIER [Wed, 25 Feb 2015 17:48:12 +0000 (18:48 +0100)] 
MINOR: lua: add ease functions

This patch adds little convenient functions useful for lua basic
manipulation.

10 years agoMEDIUM: lua: lua integration in the build and init system.
Thierry FOURNIER [Fri, 23 Jan 2015 13:06:13 +0000 (14:06 +0100)] 
MEDIUM: lua: lua integration in the build and init system.

This is the first step of the lua integration. We add the useful
files in the HAProxy project. These files contains the main
includes, the Makefile options and empty initialisation function.
Is is the LUA skeleton.

10 years agoMINOR: channel: functions to get data from a buffer without copy
Thierry FOURNIER [Mon, 16 Feb 2015 18:26:48 +0000 (19:26 +0100)] 
MINOR: channel: functions to get data from a buffer without copy

We now have functions to retrieve one block and one line from
either the input or the output part of a buffer. They return
up to two (pointer,length) values in case the buffer wraps.

10 years agoMEDIUM: http/tcp: permit to resume http and tcp custom actions
Thierry FOURNIER [Wed, 25 Feb 2015 12:36:14 +0000 (13:36 +0100)] 
MEDIUM: http/tcp: permit to resume http and tcp custom actions

Later, the processing of some actions needs to be interrupted and resumed
later. This patch permit to resume the actions. The actions that needs
to run with the resume mode are not yet avalaible. It will be soon with
Lua patches. So the code added by this patch is untestable for the moment.

The list of "tcp_exec_req_rules" cannot resme because is called by the
unresumable function "accept_session".

10 years agoMEDIUM: http: change the code returned by the response processing rule functions
Thierry FOURNIER [Wed, 25 Feb 2015 12:51:19 +0000 (13:51 +0100)] 
MEDIUM: http: change the code returned by the response processing rule functions

Actually, this function returns a pointer on the rule that stop
the evaluation of the rule list. Later we integrate the possibility
of interrupt and resue the processsing of some actions. The current
response mode is not sufficient to returns the "interrupt" information.

The pointer returned is never used, so I change the return type of
this function by an enum. With this enum, the function is ready to
return the "interupt" value.

10 years agoMEDIUM: buffer: make bo_putblk/bo_putstr/bo_putchk return the number of bytes copied.
Thierry FOURNIER [Fri, 6 Feb 2015 17:40:20 +0000 (18:40 +0100)] 
MEDIUM: buffer: make bo_putblk/bo_putstr/bo_putchk return the number of bytes copied.

This is not used yet. Planned for LUA.

10 years agoMEDIUM: tcp: add register keyword system.
Thierry FOURNIER [Fri, 12 Dec 2014 18:41:33 +0000 (19:41 +0100)] 
MEDIUM: tcp: add register keyword system.

This patch introduces an action keyword registration system for TCP
rulesets similar to what is available for HTTP rulesets. This sytem
will be useful with lua.

10 years agoMINOR: includes: fix a lot of missing or useless includes
Thierry FOURNIER [Tue, 16 Dec 2014 14:41:18 +0000 (15:41 +0100)] 
MINOR: includes: fix a lot of missing or useless includes

These modifications are done for resolving cross-dependent
includes in the upcoming LUA code.

<proto/channel.h> misses <types/channel.h>.

<types/acl.h> doesn't use <types/session.h> because the session
is already declared in the file as undefined pointer.

appsession.c misses <unistd.h> to use "write()".

Declare undefined pointer "struct session" for <types/proxy.h>
and <types/queue.h>. These includes dont need the detail of this
struct.

10 years agoMINOR: global: export many symbols.
Thierry FOURNIER [Mon, 8 Dec 2014 18:50:43 +0000 (19:50 +0100)] 
MINOR: global: export many symbols.

The functions "val_payload_lv" and "val_hdr" are useful with
lua. The lua automatic binding for sample fetchs needs to
compare check functions.

The "arg_type_names" permit to display error messages.

10 years agoMINOR: sample: add function for browsing samples.
Thierry FOURNIER [Mon, 8 Dec 2014 13:49:19 +0000 (14:49 +0100)] 
MINOR: sample: add function for browsing samples.

This function is useful with the incoming lua functions.