MINOR: stconn: add sc_hastream() and __sc_hastream() helpers

This patch introduces the sc_hastream() and __sc_hastream() inline
helpers to retrieve a haload stream context (struct hastream) from
a stream connector.

These functions allow the stconn layer to safely access haload-specific
stream data when the application type is OBJ_TYPE_HXLOAD.
This commit is contained in:
Frederic Lecaille 2026-03-19 14:52:39 +01:00
parent 431fc98ce5
commit 0b77eb5039

View file

@ -25,6 +25,7 @@
#include <haproxy/api.h>
#include <haproxy/connection.h>
#include <haproxy/hstream-t.h>
#include <haproxy/hastream-t.h>
#include <haproxy/htx-t.h>
#include <haproxy/obj_type.h>
#include <haproxy/stconn-t.h>
@ -351,6 +352,21 @@ static inline struct hstream *sc_hstream(const struct stconn *sc)
return NULL;
}
/* Returns the haload stream from a sc if the application is a
* haload stream. Otherwise NULL is returned. __sc_hastream() returns the haterm
* stream without any control while sc_hstream() check the application type.
*/
static inline struct hastream *__sc_hastream(const struct stconn *sc)
{
return __objt_hastream(sc->app);
}
static inline struct hastream *sc_hastream(const struct stconn *sc)
{
if (obj_type(sc->app) == OBJ_TYPE_HXLOAD)
return __objt_hastream(sc->app);
return NULL;
}
/* Returns non-zero if the stream connector's Rx path is blocked because of
* lack of room in the input buffer. This usually happens after applets failed
* to deliver data into the channel's buffer and reported it via sc_need_room().