relay: trigger close if in header read state with pending data
authorJo-Philipp Wich <jo@mein.io>
Tue, 2 Aug 2022 22:23:54 +0000 (00:23 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 2 Aug 2022 22:47:03 +0000 (00:47 +0200)
In case a relay process exits without printing at least one newline,
relay_close_if_done() will not close the relay context because there's
still pending data in the ustream.

Extend the relevant condition to only consider pending data if the relay
context is not in the header parsing state anymore.

Without this fix, requests triggering such a behaviour will never conclude.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
relay.c

diff --git a/relay.c b/relay.c
index 7331a0a59d2eedbe25e984b8b60a0d62580581c9..6db58acac786910896f24184b16d6b326d6ca632 100644 (file)
--- a/relay.c
+++ b/relay.c
@@ -155,7 +155,7 @@ static void relay_close_if_done(struct uloop_timeout *timeout)
 
        while (ustream_poll(&r->sfd.stream));
 
-       if (!(r->process_done || s->eof) || ustream_pending_data(s, false))
+       if (!(r->process_done || s->eof) || (ustream_pending_data(s, false) && !r->header_cb))
                return;
 
        uh_relay_close(r, r->ret);