#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;
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)
{
/*
* 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)
{
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;
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;
}