]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: stream: Xfer the input buffer to a fully created stream
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 4 Dec 2020 15:47:41 +0000 (16:47 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 4 Dec 2020 16:15:03 +0000 (17:15 +0100)
commit16df178b6eae0aaca6af874a74e6367f0c475839
tree4ad640f6a1cd59c18415fb879a0a5eaec1c8c7e0
parentb7fdfdfd92b9fdc6a3f742643760d6415fdc6f6b
BUG/MEDIUM: stream: Xfer the input buffer to a fully created stream

The input buffer passed as argument to create a new stream must not be
transferred when the request channel is initialized because the channel
flags are not set at this stage. In addition, the API is a bit confusing
regarding the buffer owner when an error occurred. The caller remains the
owner, but reading the code it is not obvious.

So, first of all, to avoid any ambiguities, comments are added on the
calling chain to make it clear. The buffer owner is the caller if any error
occurred. And the ownership is transferred to the stream on success.

Then, to make things simple, the ownership is transferred at the end of
stream_new(), in case of success. And the input buffer is updated to point
on BUF_NULL. Thus, in all cases, if the caller try to release it calling
b_free() on it, it is not a problem. Of course, it remains the caller
responsibility to release it on error.

The patch fixes a bug introduced by the commit 26256f86e ("MINOR: stream:
Pass an optional input buffer when a stream is created"). No backport is
needed.
include/haproxy/channel.h
src/mux_h1.c
src/stream.c