]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MAJOR: stream: do not allocate request buffers anymore when the left side is an applet
authorWilly Tarreau <w@1wt.eu>
Mon, 20 Apr 2015 13:52:18 +0000 (15:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 23 Apr 2015 15:56:17 +0000 (17:56 +0200)
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.

src/stream.c

index 15c5538f89c23c8d33234d76dbbfd1425cccef0c..77a67b808160ab10cc9d4b36fedcf270a8b1f614 100644 (file)
@@ -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
  * 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
- * an error message may be built and returned. In case where the initiator is
- * an applet (eg: peers), then we need to allocate the request buffer for the
- * applet to be able to send its data (in this case a response is not needed).
- * Request buffers are never picked from the reserved pool, but response
- * 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.
+ * to work fine, which is the response buffer so that an error message may be
+ * built and returned. Response 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 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)) {
                LIST_DEL(&s->buffer_wait);
                LIST_INIT(&s->buffer_wait);
        }
 
-       if (b_alloc_margin(buf, margin))
+       if (b_alloc_margin(&s->res.buf, 0))
                return 1;
 
        LIST_ADDQ(&buffer_wq, &s->buffer_wait);