Commit Graph

534 Commits

Author SHA1 Message Date
Willy Tarreau
5c8e3e09e9 [MEDIUM] added the 'block' keyword to the config language
The new 'block' keyword makes it possible to block a request based on
ACL test results. Block accepts two optional arguments : 'if' <cond>
and 'unless' <cond>.

The request will be blocked with a 403 response if the condition is validated
(if) or if it is not (unless). Do not rely on this one too much, as it's more
of a proof of concept helping in developing other matches.
2007-05-08 23:24:51 +02:00
Willy Tarreau
8797c06327 [MEDIUM] added several ACL criteria and matches
Many ACL criteria have been added. Some others are still commented out
because some functions are still missing.
2007-05-08 23:24:50 +02:00
Willy Tarreau
eb0c614f0e [MEDIUM] add the 'acl' keyword to the config language
The 'acl' keyword allows one to declare a new ACL. It is an important part
of the ACL framework.
2007-05-08 23:24:50 +02:00
Willy Tarreau
a84d374367 [MAJOR] new framework for generic ACL support
This framework offers all other subsystems the ability to register
ACL matching criteria. Some generic matching functions are already
provided. Others will come soon and the framework shall evolve.
2007-05-08 23:24:50 +02:00
Willy Tarreau
14c8aac63b [MEDIUM] store the original destination address in the session
There are multiple places where the client's destination address is
required. Let's store it in the session when needed, and add a flag
to inform that it has been retrieved.
2007-05-08 23:24:20 +02:00
Willy Tarreau
d077a8e67c [MINOR] fixed useless memory allocation in str2net()
It was not necessary anymore to allocate memory in str2net().
Moreover, some calls to free() were missing in case of errors.
2007-05-08 23:23:38 +02:00
Willy Tarreau
58ef70227a [TESTS] added a trivial program to benchmark hash algos
The uri_hash.c program makes it very easy to benchmark the
distribution of hash algos. Pass it one word per line, and
it will show the distribution per server for 1 to 10 servers.
2007-05-08 23:22:43 +02:00
Willy Tarreau
c9b654b48b [BUG] fix early server close after client close
Problem reported by Andy Smith. If a client sends TCP data
and quickly closes the connection before the server connection
is established, AND the whole buffer can be sent at once when
the connection establishes, then the server side believes that
it can simply abort the connection because the buffer is empty,
without checking that some work was performed.

Fix: ensure that nothing was written before closing.
2007-05-08 14:46:53 +02:00
Willy Tarreau
540abe406d [MEDIUM] ensure that we always have a null word in config
It is important when parsing configuration file to ensure that at
least one word is empty to mark the end of the line. This will be
required with ACLs in order to avoid reading past the end of line.
2007-05-08 14:12:06 +02:00
Willy Tarreau
3ff3dc1fb1 [MINOR] add support for variable size arrays in structures
Depending on the version of GCC, variable size arrays are not
declared in the same manner. Let's add a check for the version
and provide a macro.
2007-05-08 14:08:05 +02:00
Willy Tarreau
2b1dccd501 [MINOR] add LIST_HEAD_INIT to the list management macros
It is useful to have the ability to initialize a list while declaring it.
2007-05-08 14:07:44 +02:00
Willy Tarreau
b9c62b90da [MEDIUM] add better list management macros
The FOREACH_ITEM and FOREACH_ITEM_SAFE macros are nasty, they
require too many arguments. Let's port those from linux instead.
2007-05-08 14:07:39 +02:00
Willy Tarreau
2fcb500481 [MEDIUM] implement the URI hash algorithm
Guillaume Dallaire contributed the URI hashing algorithm for
use with proxy-caches. It provides the advantage of optimizing
the cache hit rate.
2007-05-08 14:05:27 +02:00
Willy Tarreau
9cdde230a5 [MEDIUM] always have msg->sol point to beginning of message
Since the 'data' pointer is not stored in message structures, it is
useful to have such a pointer to it when the message has been fully
parsed.
2007-05-08 14:05:14 +02:00
Willy Tarreau
2e8eb67762 [BUILD] do not build rbtree anymore
Rbtree is not used anymore. Remove it from the makefiles.
2007-04-30 17:30:59 +02:00
Willy Tarreau
e33aecefa6 [MINOR] uninline task_wakeup
task_wakup has become bigger since we used the trees. Let's not
inline it anymore.
2007-04-30 14:38:03 +02:00
Willy Tarreau
8bb46f4015 [MINOR] ev_sepoll: refine flags management.
Ensure that we don't call the event handlers if the FD is already
marked FD_STERROR, and ensure that we properly catch HUP and ERR.
2007-04-30 14:38:00 +02:00
Willy Tarreau
6996e15e16 [BUG] fixed connection establishment detection
Since the introduction of speculative I/O, it was not always possible
to correctly detect a connection establishment. Particularly, in TCP
mode, there is no data to send and getsockopt() returns no error. The
solution consists in trying a connect() again to get its diagnostic.
2007-04-30 14:37:43 +02:00
Willy Tarreau
c2c078362a [MINOR] remove wait_time nullification in ev_sepoll
in ev_sepoll(), wait_time is forced to zero if at least one
speculative event is converted to a real event. This is completely
wrong.
2007-04-29 21:49:00 +02:00
Willy Tarreau
5465e111fd [MINOR] pre-compute t->expire in event_accept
At the end of event_accept(), t->expire is computed with tv_min
between two exclusive values. Let's simply assign it at the same
time.
2007-04-29 19:09:47 +02:00
Willy Tarreau
42aae5c7cf [MEDIUM] many cleanups in the time functions
Now, functions whose name begins with '__tv_' are inlined. Also,
'tv_ms' is used as a prefix for functions using milliseconds.
2007-04-29 17:43:56 +02:00
Willy Tarreau
f41d4b15ee [MINOR] tell the compiler that debug more is unlikely to happen
In process_session(), add unlikely() around debug code.
2007-04-29 13:44:48 +02:00
Willy Tarreau
8d7d1497e0 [MEDIUM] implement and use tv_cmp2_le instead of tv_cmp2_ms
tv_cmp2_ms handles multiple combinations of tv1 and tv2, but only
one form is used: (tv1 <= tv2). So it is overkill to use it everywhere.
A new function designed to do exactly this has been written for that
purpose: tv_cmp2_le. Also, removed old unused tv_* functions.
2007-04-29 13:44:43 +02:00
Willy Tarreau
a6a6a93e56 [MAJOR] changed TV_ETERNITY to ~0 instead of 0
The fact that TV_ETERNITY was 0 was very awkward because it
required that comparison functions handled the special case.
Now it is ~0 and all comparisons are performed on unsigned
values, so that it is naturally greater than any other value.

A performance gain of about 2-5% has been noticed.
2007-04-29 13:44:24 +02:00
Willy Tarreau
96bcfd75aa [MAJOR] replaced rbtree with ul2tree.
The rbtree-based wait queue consumes a lot of CPU. Use the ul2tree
instead. Lots of cleanups and code reorganizations made it possible
to reduce the task struct and simplify the code a bit.
2007-04-29 13:43:53 +02:00
Willy Tarreau
3fa095d542 [MINOR] removed useless counters from ul2tree_insert()
node_right_lookup and node_right_lookup were two statistical counters.
Let's remove them as we do not need them.
2007-04-29 13:43:03 +02:00
Willy Tarreau
be384c6354 [MINOR] import ul2tree from old librt project
This is an import of the old ul2tree code as well as required bitops.
All of them will have to be refreshed at one moment.
2007-04-29 13:41:57 +02:00
Willy Tarreau
40cf67da89 [MINOR] added support for dual-linked lists
Imported dual-linked lists management macros from the old scheduler project,
and fixed a long-standing nasty bug in the DLIST_ADD() macro.
2007-04-29 13:40:50 +02:00
Willy Tarreau
6e0433f0e9 [RELEASE] Released version 1.3.9 with the following changes :
- modularized the polling mechanisms and use function pointers instead
      of macros at many places
    - implemented support for FreeBSD's kqueue() polling mechanism
    - fixed a warning on OpenBSD : MIN/MAX redefined
    - change socket registration order at startup to accomodate kqueue.
    - several makefile cleanups to support old shells
    - fix build with limits.h once for all
    - ev_epoll: do not rely on fd_sets anymore, use changes stacks instead.
    - fdtab now holds the results of polling
    - implemented support for speculative I/O processing with epoll()
    - remove useless calls to shutdown(SHUT_RD), resulting in small speed boost
    - auto-registering of pollers at load time
2007-04-16 01:33:37 +02:00
Willy Tarreau
5b7024270a [BUILD] regparm in fd.h broke build on gcc-2.95
It was necessary to put the attribute after the type.
2007-04-16 01:33:26 +02:00
Willy Tarreau
de99e99ecf [MAJOR] introduced speculative I/O with epoll()
The principle behind speculative I/O is to speculatively try to
perform I/O before registering the events in the system. This
considerably reduces the number of calls to epoll_ctl() and
sometimes even epoll_wait(), and manages to increase overall
performance by about 10%.

The new poller has been called "sepoll". It is used by default
on Linux when it works. A corresponding option "nosepoll" and
the command line argument "-ds" allow to disable it.
2007-04-16 00:53:59 +02:00
Willy Tarreau
ef1d1f859b [MAJOR] auto-registering of pollers at load time
Gcc provides __attribute__((constructor)) which is very convenient
to execute functions at startup right before main(). All the pollers
have been converted to have their register() function declared like
this, so that it is not necessary anymore to call them from a centralized
file.
2007-04-16 00:25:25 +02:00
Willy Tarreau
b40d42006c [BUILD] declare epoll_* as static when using our own functions
We will have to share this code among several implementations.
2007-04-15 23:57:41 +02:00
Willy Tarreau
9f195293de [MAJOR] remove useless calls to shutdown(SHUT_RD)
shutdown(SHUT_RD) is useless on data TCP sockets. It does nothing
and consumes one syscall. Remove it.
2007-04-15 21:26:58 +02:00
Willy Tarreau
8374918cce [MAJOR] implemented support for speculative I/O processing
The pollers will now be able to speculatively call the I/O
processing functions and decide whether or not they want to
poll on those FDs. The changes primarily consist in teaching
those functions how to pass the info they got an EAGAIN.
2007-04-15 20:56:27 +02:00
Willy Tarreau
3d32d3a849 [MINOR] add support for the polling results in fdtab
Now fdtab can contain the FD_POLL_* events so that the pollers
which can fill them can give userful information to readers and
writers about the precise condition of wakeup.
2007-04-15 11:31:05 +02:00
Willy Tarreau
7a9664872e [MINOR] recompute maxfd before touching fdtab
It may be dangerous to play with fdtab before doing fd_insert()
because this last one is responsible for growing maxfd as needed.
Call fd_insert() before instead.
2007-04-15 10:58:02 +02:00
Willy Tarreau
69cad1a338 [MINOR] copy-paste typo when checking for -dk to disable kqueue. 2007-04-10 22:45:11 +02:00
Willy Tarreau
258696f5d8 [MAJOR] missing tv_now in kqueue_poll() blocking timeouts
a missing call to tv_now(&now) just after kevent() prevented
the timeouts from expiring.
2007-04-10 02:31:54 +02:00
Willy Tarreau
58094f2fd9 [MAJOR] ev_epoll: do not rely on fd_sets anymore
The new epoll-based poller uses a list of changes in order to
process only the fds which have changed.
2007-04-10 01:43:43 +02:00
Willy Tarreau
167d8b5953 [BUILD] Fix limits.h once for all
Patch #cf83df3d162687d9c74783357421bd89f596eaac was stupid. Including
limits.h is portable and easier. At least it now builds on Solaris,
FreeBSD, Linux and OpenBSD.
2007-04-09 22:16:12 +02:00
Willy Tarreau
a1973c4d82 [CLEANUP] make makefile more old sh-friendly
Older SH on Solaris does not know about $(cmd) but only know `cmd`.
2007-04-09 22:07:11 +02:00
Willy Tarreau
40562cb00c [MINOR] kqueue: use fd_clo() to close the fd
fd_clo() does not call kevent() which is not needed during a close().
This one will be faster.
2007-04-09 20:38:57 +02:00
Willy Tarreau
2ff7622c0c [MAJOR] delay registering of listener sockets at startup
Some pollers such as kqueue lose their FD across fork(), meaning that
the registered file descriptors are lost too. Now when the proxies are
started by start_proxies(), the file descriptors are not registered yet,
leaving enough time for the fork() to take place and to get a new pollfd.
It will be the first call to maintain_proxies that will register them.
2007-04-09 19:29:56 +02:00
Willy Tarreau
8755285486 [MEDIUM] kqueue: do not manually remove fds
FDs attached to a kevent are automatically removed after close().
Also, do not mark the FDs as EV_CLEAR. We want to stay informed
about readiness.
2007-04-09 17:16:07 +02:00
Willy Tarreau
8ae42f42f8 [BUILD] enable kqueue on MacOS X too
MacOS X is said to have kqueue. Let's enable it too.
2007-04-09 16:30:28 +02:00
Willy Tarreau
cd5ce2a514 [MAJOR] kqueue bug in handling infinite timeouts
Calls to kevent() need to pass NULL when there is no timeout.
2007-04-09 16:25:46 +02:00
Willy Tarreau
e1a7a2f0d8 [MAJOR] kqueue was not initialized during startup 2007-04-09 16:11:49 +02:00
Willy Tarreau
a8cff1d6a7 [BUILD] fixed a warning on OpenBSD : MIN/MAX redefined 2007-04-09 16:10:57 +02:00
Willy Tarreau
cf83df3d16 [BUILD] fix build on FreeBSD for INT_MIN/INT_MAX
FreeBSD stores INT_MIN and INT_MAX in sys/limits.h only. Other systems
(Solaris) have it in sys/types.h and do not have sys/limits.h. Let's
include sys/limits.h only if INT_MAX is not defined.
2007-04-09 15:57:51 +02:00