MEDIUM: stream: implement stream_buf_available()
authorWilly Tarreau <w@1wt.eu>
Tue, 6 Nov 2018 14:50:21 +0000 (15:50 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 11 Nov 2018 09:18:37 +0000 (10:18 +0100)
commitb882dd88cc5996b2057ee0131bd59436002c1427
treef4089d9773e1c76e5eded9f9e3bafda75f0e03a9
parent745f15eba97535c1b7894f81f6bc252e1a41e5d0
MEDIUM: stream: implement stream_buf_available()

This function replaces stream_res_available(), which is used as a callback
for the buffer allocator. It now carefully checks which stream interface
was blocked on a buffer allocation, tries to allocate the input buffer to
this stream interface, and wakes the task up once such a buffer was found.
It will automatically remove the SI_FL_WAIT_ROOM flag upon success since
the info this flag indicates becomes wrong as soon as the buffer is
allocated.

The code is still far from being perfect because if a call to si_cs_recv()
fails to allocate a buffer, we'll still end up passing via process_stream()
again, but this could be improved in the future by using finer-grained
wake-up notifications.
include/proto/stream.h
src/stream.c