Commit Graph

348 Commits

Author SHA1 Message Date
Willy Tarreau
9641e8f6ee [MINOR] read optimizations based on the MSS
Generally, if a recv() returns less bytes than the MSS, it means that
there is nothing left in the system's buffers, and that it's not worth
trying to read again because we are very likely to get nothing. A
default read low limit has been set to 1460 bytes below which we stop
reading.

This has brought a little speed boost on small objects while maintaining
the same speed on large objects.
2007-03-23 23:02:09 +01:00
Willy Tarreau
b8949f1ed0 [MEDIUM] re-implemented the multiple read polling
Multiple read polling was temporarily disabled, which had the side
effect of burning huge amounts of CPU on large objects. It has now
been re-implemented with a limit of 8 calls per wake-up, which seems
to provide best results at least on Linux.
2007-03-23 22:39:59 +01:00
Willy Tarreau
042cc79e59 [BUG] fix pointer initializations for TCP connections.
Very recent changes consisting in moving some pointers to the
transaction instead of the session have lead to a bug because
those pointers were only initialized if the protocol was HTTP,
but they were freed based on their value. In some cases, it
was possible to cause double frees.
2007-03-19 16:20:06 +01:00
Willy Tarreau
aa9dce3bd6 [MINOR] added new function http_header_match2()
HTTP header matching is now made easier with http_header_match2().
Various locations have been adapted to use it. A small bug was also
fixed causing empty headers to be matched till next one.
2007-03-18 23:50:16 +01:00
Willy Tarreau
4af6f3a9ea [MINOR] HTTP: factorize all the header insertions
Two new functions http_header_add_tail() and http_header_add_tail2()
make it easier to append headers, and also reduce the number of
sprintf() calls and perform stricter checks.
2007-03-18 22:36:26 +01:00
Willy Tarreau
a5e65754e6 [MINOR] used http_flush_cookie_flags() instead of a dirty code block 2007-03-18 20:53:22 +01:00
Willy Tarreau
3d300596bb [MINOR] move some flags from session.h to proto_http.h
Some session flags were clearly related to HTTP transactions.
A new 'flags' field has been added to http_txn, and the
associated flags moved to proto_http.h.
2007-03-18 18:34:41 +01:00
Willy Tarreau
3bac9ffe20 [CLEANUP] move http_txn out of session.h
The http_txn structure definitions moved to proto_http.h
2007-03-18 17:31:28 +01:00
Willy Tarreau
5416b36b43 [CLEANUP] removed useless includes from streamsock.c 2007-03-18 17:03:19 +01:00
Willy Tarreau
e09e0cef62 [MINOR] removed the ->h member in struct buffer
The buffer does not need the header pointer anymore, it has
been removed everywhere.
2007-03-18 16:31:29 +01:00
Willy Tarreau
b49871738e [MINOR] fix accounting for response bytes
A remaining reference to rep->h was replaced.
2007-03-18 16:28:03 +01:00
Willy Tarreau
a15645d435 [MAJOR] completed the HTTP response processing.
Now the response is correctly processed in the backend first
then in the frontend. It has followed intensive tests to
catch regressions, and everything seems OK now, but the code
is young anyway.
2007-03-18 16:22:39 +01:00
Willy Tarreau
117f59e282 [MINOR] code factoring : capture_headers() serves requests and responses
Both request and response captures will have to parse headers following
the same methods. It's better to factorize the code, hence the new
capture_headers() function.
2007-03-04 18:17:17 +01:00
Willy Tarreau
4b89ad4358 [MINOR] implement http_is_ver_token to fix response parsing
This new character map improves accuracy when parsing HTTP version,
which helps inspecting requests, and fixes response handling.
2007-03-04 18:13:58 +01:00
Willy Tarreau
6911fa484c [MINOR] added new str2i* functions
Those functions provide faster and more flexible alternatives to atoi(),
some of which are able to work on sub-strings.
2007-03-04 18:06:08 +01:00
Willy Tarreau
bb046ac8c5 [MINOR] option forwardfor is for frontends too
Finally, if the "option forwardfor" is specified in the frontend
and not in the backend, apply it.
2007-03-03 20:54:01 +01:00
Willy Tarreau
c2168d3ccb [CLEANUP] replaced occurrences of 'hreq' with 'txn' (bis)
Did the same in client.c
2007-03-03 20:53:23 +01:00
Willy Tarreau
4dbc4a2ee4 [CLEANUP] replaced occurrences of 'hreq' with 'txn'
In many places, the variable "hreq" designated a transaction more than
a request. This has been changed to avoid confusion.
2007-03-03 16:23:22 +01:00
Willy Tarreau
b326fcc46a [CLEANUP] renamed several HTTP structures
Some parts of HTTP processing were incorrectly called "request" while
they are messages or transactions. The following structure members
have changed :

  http_msg.hdr_state => msg_state
  http_msg.sor => som
  http_req.req_state => removed
  http_req => http_txn
2007-03-03 13:54:32 +01:00
Willy Tarreau
244b47beef [DOC] add some doc about internal naming rules 2007-03-03 11:46:27 +01:00
Willy Tarreau
5e8f066961 [MINOR] slightly optimize time calculation for rbtree
The new rbtree-based scheduler makes heavy use of tv_cmp2(), and
this function becomes a huge CPU eater. Refine it a little bit in
order to slightly reduce CPU usage.
2007-02-12 00:59:08 +01:00
Willy Tarreau
b1b8272a54 [MINOR] uninline rb_insert_task_queue()
rb_insert_task_queue() was inlined and is quite large. Uninlining
it reduces code size by about 2 kB and slightly improves performance.
2007-02-11 13:52:16 +01:00
Willy Tarreau
92f2ab1b1f [BUG] fix crash when no cookie is set on server
In cookie prefix or rewrite modes, if the elected server had no
cookie, a NULL pointer was passed to the rewrite function, causing
a SIGSEGV.
2007-02-02 22:14:47 +01:00
Willy Tarreau
4266a36c5a [BUG] segfault on some erroneous configurations
If captures were configured in a TCP-only listener, and
the logs were enabled, the proxy could segfault when
trying to scan the capture buffer which was NULL. Such
an erroneous configuration will not be possible anymore
soon, but let's avoid the problem for now by detecting
the NULL condition.
2007-02-01 23:15:45 +01:00
Willy Tarreau
9cabf70db7 [RELEASE] Released version 1.3.7 with the following changes :
- fix critical bug introduced with 1.3.6 : an empty request header
      may lead to a crash due to missing pointer assignment
    - hdr_idx might be left uninitialized in debug mode
    - fixed build on FreeBSD due to missing fd_set declaration
2007-01-26 23:49:01 +01:00
Willy Tarreau
b9ebf70a3a [CRITICAL] an empty header may lead to a crash
A missing pointer assignment in case of an empty header
will result in this header's length being 65535, causing
a SEGV when accessing the next header. It should not be
possible to exploit this problem to run arbitrary code
because the crash occurs while reading the data.
2007-01-26 23:39:38 +01:00
Willy Tarreau
f0d058e8ab [BUG] hdr_idx might be left uninitialized in some cases
When a request is invalid during RQ_BEFORE AND the debug mode is active,
the hdr_idx might be used uninitialized. Let's initialize it right after
the accept() for now.
2007-01-25 12:03:42 +01:00
Willy Tarreau
ca28d1e1cb [BUILD] fix build on FreeBSD (missing fd_set declaration)
Sorin Pop reported a patch to fix build on FreeBSD.
The file common/standard.h used an fd_set in a declaration
but did not include enough headers for it to be known.
2007-01-24 18:20:50 +01:00
Willy Tarreau
e7a2438cae [RELEASE] Released version 1.3.6.1 with the following change :
- change in the header chaining broke cookies and authentication
2007-01-22 08:57:44 +01:00
Willy Tarreau
83969f42ba [MAJOR] invalid header offset broke cookies and authentication
Since the request is no longer part of the headers, cookies and
authentication did not work anymore. Obvious fix is to add the
request offset to the start pointer.
2007-01-22 08:55:47 +01:00
Willy Tarreau
49e1ee83be [RELEASE] Released 1.3.6 with the following changes :
- stats now support the HEAD method too
    - extracted http request from the session
    - huge rework of the HTTP parser which is now a 28-state FSM.
    - linux-style likely/unlikely macros for optimization hints
    - do not create a server socket when there's no server
2007-01-22 00:56:46 +01:00
Willy Tarreau
8973c70f7d [MEDIUM] implemented the status-line parser in http_msg_analyzer().
The status line parser has been written. With it, it should not
be too hard to replace the response parser to benefit from the
new header facilities.
2007-01-21 23:58:29 +01:00
Willy Tarreau
362b34d05c [MINOR] move the response headers to the http_req 2007-01-21 20:49:31 +01:00
Willy Tarreau
ee68cf29bb [DOC] added a link to an excellent paper about HTTP load time 2007-01-21 19:18:55 +01:00
Willy Tarreau
8d5d7f20b9 [MAJOR] huge rework of the HTTP request FSM
The HTTP parser has been rewritten for better compliance to RFC2616.
The same parser is now usable for both requests and responses, and
it now supports HTTP/0.9 as well as multi-line headers. It has also
been improved for speed ; a typicial HTTP request is parsed in about
2 microseconds on a 1 GHz processor.

The monitor-uri check has been moved so that the requests are not
logged. The httpclose option now tries to change as little as
possible in the request, and does not affect the first header if
it is already set to 'close'. HTTP/0.9 requests are converted to
HTTP/1.0 before being forwarded.

Headers and request transformations are now distinct. The headers
list is updated after each insertion/removal/transformation. The
request is re-parsed and checked after each transformation. It is
not possible anymore to remove a request, and requests which lead
to invalid request lines are now rejected.
2007-01-21 19:16:41 +01:00
Willy Tarreau
5d65bbb2aa [BUG] last backend change broke server assignment
Due to a change in the if/else paths, s->flags did not receive
the SN_ASSIGNED value anymore.
2007-01-21 12:47:26 +01:00
Willy Tarreau
1a1158b0bd [MINOR] do not create a socket if there is no server
Since the distinction of backends and frontends, it has become
possible that some requests reach a frontend which has no
backend parameters. We must not create a socket on the backend
side just to destroy it later in such a case. The real problem
comes from the dispatch mode not being explictly stated.
2007-01-20 11:07:46 +01:00
Willy Tarreau
0637fa0671 [MINOR] add the end of line pointer in each HTTP header 2007-01-13 23:07:22 +01:00
Willy Tarreau
7d58a63071 [MINOR] added the Linux-style likely/unlikely macros
Recent GCC versions support the __builtin_expect() macro which
is undecipherable. Let's use likely()/unlikely() like it's done
in Linux.
2007-01-13 23:06:06 +01:00
Willy Tarreau
0f7562b8d3 [MEDIUM] separate the http request from the session (step 1)
A struct http_req has been created to collect every information
related to an HTTP request being processed. Right now, it is
still in the struct session but the frontier is clear now.
2007-01-07 15:46:13 +01:00
Willy Tarreau
6cf932508d Merge branch 'master' into http_parser 2007-01-07 13:49:41 +01:00
Willy Tarreau
0214c3a307 [MEDIUM] Stats: add support for the HEAD method
There are browsers which sometimes send HEAD requests to the stats
page, but it was not handled so it returned a 503 server error or
was simply sent to the default backend servers.

Now with a HEAD request, the stats return the headers and finish
there. Normally, other methods should be blocked so that the stats
page really catches the whole URI. Other methods would need to cause
a 405 Method not allowed to be returned.
2007-01-07 13:47:30 +01:00
Willy Tarreau
d1142aa073 [DOC] imported lots of internal documentations
Those documentations provide nothing to users nor contributors
but at least now I know where they are.
2007-01-07 13:03:59 +01:00
Willy Tarreau
1ba6a73594 [DOC] updated the http_parsing doc 2007-01-07 12:43:29 +01:00
Willy Tarreau
5871f8e9bf [RELEASE] Released 1.3.5 with the following major changes :
- added complete support and doc for TCP Splicing
    - replaced the wait-queue linked list with an rbtree.
    - stats: swap color sets for active and backup servers
    - try to guess server check port when unset
    - a few bugfixes and cleanups
2007-01-07 02:47:01 +01:00
Willy Tarreau
ef00b50011 [MINOR] try to guess server check port when unset
When a server has no port specified and there is a check
enabled on it, the check is disabled because the port is
unknown. However, people expect the "listen" line to set
the check port just like it sets the server's port. Now,
if a port is specified in the listen or in the first bind
and nowhere else, it will be used for the checks as well.
2007-01-07 02:40:09 +01:00
Willy Tarreau
86efac8411 Merge branch 'rbtree' 2007-01-07 02:17:18 +01:00
Willy Tarreau
733fef4add Merge branch 'tcpsplice' 2007-01-07 02:16:59 +01:00
Willy Tarreau
964c936b04 [MAJOR] replace the wait-queue linked list with an rbtree.
This patch from Sin Yu makes use of an rbtree for the wait queue,
which will solve the slowdown problem encountered when timeouts
are heterogenous in the configuration. The next step will be to
turn maintain_proxies() into a per-proxy task so that we won't
have to scan them all after each poll() loop.
2007-01-07 02:14:23 +01:00
Willy Tarreau
d59d22e20a [MINOR] imported the rbtree function from Linux kernel
Those rbtree functions will be used by Sin Yu's new rbtree scheduler.
2007-01-07 02:12:57 +01:00