mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 14:51:27 +02:00
MAJOR: stream: do not allocate request buffers anymore when the left side is an applet
We used to allocate a request buffer so that we could process applets from process_stream(), and this was causing some trouble because it was not possible for an analyzer to return an error to an applet, which we'll need for HTTP/2. Now that we don't call applets anymore from process_stream() we can simplify this and ensure that a response is always allocated to process a stream.
This commit is contained in:
parent
d4da196546
commit
bc39a5d8c8
27
src/stream.c
27
src/stream.c
@ -361,35 +361,20 @@ int stream_alloc_recv_buffer(struct channel *chn)
|
|||||||
|
|
||||||
/* Allocates a work buffer for stream <s>. It is meant to be called inside
|
/* Allocates a work buffer for stream <s>. It is meant to be called inside
|
||||||
* process_stream(). It will only allocate the side needed for the function
|
* process_stream(). It will only allocate the side needed for the function
|
||||||
* to work fine. For a regular connection, only the response is needed so that
|
* to work fine, which is the response buffer so that an error message may be
|
||||||
* an error message may be built and returned. In case where the initiator is
|
* built and returned. Response buffers may be allocated from the reserve, this
|
||||||
* an applet (eg: peers), then we need to allocate the request buffer for the
|
* is critical to ensure that a response may always flow and will never block a
|
||||||
* applet to be able to send its data (in this case a response is not needed).
|
* server from releasing a connection. Returns 0 in case of failure, non-zero
|
||||||
* Request buffers are never picked from the reserved pool, but response
|
* otherwise.
|
||||||
* buffers may be allocated from the reserve. This is critical to ensure that
|
|
||||||
* a response may always flow and will never block a server from releasing a
|
|
||||||
* connection. Returns 0 in case of failure, non-zero otherwise.
|
|
||||||
*/
|
*/
|
||||||
int stream_alloc_work_buffer(struct stream *s)
|
int stream_alloc_work_buffer(struct stream *s)
|
||||||
{
|
{
|
||||||
int margin;
|
|
||||||
struct buffer **buf;
|
|
||||||
|
|
||||||
if (objt_appctx(s->si[0].end)) {
|
|
||||||
buf = &s->req.buf;
|
|
||||||
margin = global.tune.reserved_bufs;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
buf = &s->res.buf;
|
|
||||||
margin = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!LIST_ISEMPTY(&s->buffer_wait)) {
|
if (!LIST_ISEMPTY(&s->buffer_wait)) {
|
||||||
LIST_DEL(&s->buffer_wait);
|
LIST_DEL(&s->buffer_wait);
|
||||||
LIST_INIT(&s->buffer_wait);
|
LIST_INIT(&s->buffer_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b_alloc_margin(buf, margin))
|
if (b_alloc_margin(&s->res.buf, 0))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
LIST_ADDQ(&buffer_wq, &s->buffer_wait);
|
LIST_ADDQ(&buffer_wq, &s->buffer_wait);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user