mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-05 22:56:57 +02:00
MINOR: applet: Improve applet API to take care of inbuf/outbuf alloc failures
applet_get_inbuf() and applet_get_outbuf() functions were not testing if the buffers were available. So, the caller had to check them before calling one of these functions. It is not really handy. So now, these functions take care to have a fully usable buffer before returning. Otherwise NULL is returned.
This commit is contained in:
parent
44aae94ab9
commit
1f9a1cbefc
@ -288,8 +288,11 @@ static inline void applet_expect_data(struct appctx *appctx)
|
||||
*/
|
||||
static inline struct buffer *applet_get_inbuf(struct appctx *appctx)
|
||||
{
|
||||
if (appctx->flags & APPCTX_FL_INOUT_BUFS)
|
||||
if (appctx->flags & APPCTX_FL_INOUT_BUFS) {
|
||||
if (applet_fl_test(appctx, APPCTX_FL_INBLK_ALLOC) || !appctx_get_buf(appctx, &appctx->inbuf))
|
||||
return NULL;
|
||||
return &appctx->inbuf;
|
||||
}
|
||||
else
|
||||
return sc_ob(appctx_sc(appctx));
|
||||
}
|
||||
@ -300,8 +303,12 @@ static inline struct buffer *applet_get_inbuf(struct appctx *appctx)
|
||||
*/
|
||||
static inline struct buffer *applet_get_outbuf(struct appctx *appctx)
|
||||
{
|
||||
if (appctx->flags & APPCTX_FL_INOUT_BUFS)
|
||||
if (appctx->flags & APPCTX_FL_INOUT_BUFS) {
|
||||
if (applet_fl_test(appctx, APPCTX_FL_OUTBLK_ALLOC|APPCTX_FL_OUTBLK_FULL) ||
|
||||
!appctx_get_buf(appctx, &appctx->outbuf))
|
||||
return NULL;
|
||||
return &appctx->outbuf;
|
||||
}
|
||||
else
|
||||
return sc_ib(appctx_sc(appctx));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user