mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-03 10:42:07 +00:00
MINOR: applet: report about buffer allocation success
When appctx_buf_available() is called, it now sets APPCTX_FL_IN_MAYALLOC or APPCTX_FL_OUT_MAYALLOC depending on the reportedly permitted buffer allocation, and these flags are cleared when the said buffers are allocated. For now they're not used for anything else.
This commit is contained in:
parent
17d8916bb1
commit
cb2d758043
@ -48,6 +48,8 @@
|
||||
#define APPCTX_FL_WANT_DIE 0x00000200 /* applet was running and requested to die */
|
||||
#define APPCTX_FL_INOUT_BUFS 0x00000400 /* applet uses its own buffers */
|
||||
#define APPCTX_FL_FASTFWD 0x00000800 /* zero-copy forwarding is in-use, don't fill the outbuf */
|
||||
#define APPCTX_FL_IN_MAYALLOC 0x00001000 /* applet may try again to allocate its inbuf */
|
||||
#define APPCTX_FL_OUT_MAYALLOC 0x00002000 /* applet may try again to allocate its outbuf */
|
||||
|
||||
struct appctx;
|
||||
struct proxy;
|
||||
|
@ -60,6 +60,7 @@ size_t appctx_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, unsig
|
||||
int appctx_fastfwd(struct stconn *sc, unsigned int count, unsigned int flags);
|
||||
ssize_t applet_append_line(void *ctx, struct ist v1, struct ist v2, size_t ofs, size_t len);
|
||||
static forceinline void applet_fl_set(struct appctx *appctx, uint on);
|
||||
static forceinline void applet_fl_clr(struct appctx *appctx, uint off);
|
||||
|
||||
static inline struct appctx *appctx_new_here(struct applet *applet, struct sedesc *sedesc)
|
||||
{
|
||||
@ -87,7 +88,8 @@ static inline void appctx_release_buf(struct appctx *appctx, struct buffer *bptr
|
||||
/*
|
||||
* Allocate a buffer. If if fails, it adds the appctx in buffer wait queue and
|
||||
* sets the relevant blocking flag depending on the side (assuming that bptr is
|
||||
* either &appctx->inbuf or &appctx->outbuf)
|
||||
* either &appctx->inbuf or &appctx->outbuf). Upon success it will also clear
|
||||
* the equivalent MAYALLOC flags.
|
||||
*/
|
||||
static inline struct buffer *appctx_get_buf(struct appctx *appctx, struct buffer *bptr)
|
||||
{
|
||||
@ -98,6 +100,8 @@ static inline struct buffer *appctx_get_buf(struct appctx *appctx, struct buffer
|
||||
if (unlikely((buf = b_alloc(bptr, is_inbuf ? DB_MUX_TX : DB_SE_RX)) == NULL)) {
|
||||
b_queue(is_inbuf ? DB_MUX_TX : DB_SE_RX, &appctx->buffer_wait, appctx, appctx_buf_available);
|
||||
applet_fl_set(appctx, is_inbuf ? APPCTX_FL_INBLK_ALLOC : APPCTX_FL_OUTBLK_ALLOC);
|
||||
} else {
|
||||
applet_fl_clr(appctx, is_inbuf ? APPCTX_FL_IN_MAYALLOC : APPCTX_FL_OUT_MAYALLOC);
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
|
@ -447,12 +447,14 @@ int appctx_buf_available(void *arg)
|
||||
|
||||
if (applet_fl_test(appctx, APPCTX_FL_INBLK_ALLOC)) {
|
||||
applet_fl_clr(appctx, APPCTX_FL_INBLK_ALLOC);
|
||||
applet_fl_set(appctx, APPCTX_FL_IN_MAYALLOC);
|
||||
TRACE_STATE("unblocking appctx on inbuf allocation", APPLET_EV_RECV|APPLET_EV_BLK|APPLET_EV_WAKE, appctx);
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
if (applet_fl_test(appctx, APPCTX_FL_OUTBLK_ALLOC)) {
|
||||
applet_fl_clr(appctx, APPCTX_FL_OUTBLK_ALLOC);
|
||||
applet_fl_set(appctx, APPCTX_FL_OUT_MAYALLOC);
|
||||
TRACE_STATE("unblocking appctx on outbuf allocation", APPLET_EV_SEND|APPLET_EV_BLK|APPLET_EV_WAKE, appctx);
|
||||
ret = 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user