/* End of data: commit the total strings and return. */
if (ret < 0) {
+ /* Stop to consume */
+ applet_wont_consume(luactx->appctx);
+
luaL_pushresult(&luactx->b);
return 1;
}
luaL_addlstring(&luactx->b, blk2, len2);
applet_skip_input(luactx->appctx, len1+len2);
+
+ /* Stop to consume until the next receive */
+ applet_wont_consume(luactx->appctx);
+
luaL_pushresult(&luactx->b);
return 1;
}
{
struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_tcp(L, 1));
+ /* Restart to consume - could have been disabled by a previous receive */
+ applet_will_consume(luactx->appctx);
+
/* Initialise the string catenation. */
luaL_buffinit(L, &luactx->b);
/* Data not yet available. return yield. */
if (ret == 0) {
if (tick_is_expired(exp_date, now_ms)) {
+ /* Stop to consume until the next receive */
+ applet_wont_consume(luactx->appctx);
+
/* return the result. */
lua_pushnil(L);
return 1;
/* End of data: commit the total strings and return. */
if (ret < 0) {
+ /* Stop to consume */
+ applet_wont_consume(luactx->appctx);
+
luaL_pushresult(&luactx->b);
return 1;
}
applet_skip_input(luactx->appctx, len1+len2);
if (tick_is_expired(exp_date, now_ms)) {
+ /* Stop to consume until the next receive */
+ applet_wont_consume(luactx->appctx);
+
/* return the result. */
luaL_pushresult(&luactx->b);
return 1;
return 0;
}
+ /* Stop to consume until the next receive */
+ applet_wont_consume(luactx->appctx);
+
/* return the result. */
luaL_pushresult(&luactx->b);
return 1;
exp_date = delay ? tick_add(now_ms, delay) : TICK_ETERNITY;
lua_pushinteger(L, exp_date);
+ /* Restart to consume - could have been disabled by a previous receive */
+ applet_will_consume(luactx->appctx);
+
/* Initialise the string catenation. */
luaL_buffinit(L, &luactx->b);
/* set the expiration date (mandatory arg but not relevant here) */
lua_pushinteger(L, now_ms);
+ /* Restart to consume - could have been disabled by a previous receive */
+ applet_will_consume(luactx->appctx);
+
/* Initialise the string catenation. */
luaL_buffinit(L, &luactx->b);
goto out;
/* The applet execution is already done. */
- if (tcp_ctx->flags & APPLET_DONE)
+ if (tcp_ctx->flags & APPLET_DONE) {
+ /* Restart to consume to drain request data */
+ applet_will_consume(ctx);
goto out;
+ }
/* Execute the function. */
switch (hlua_ctx_resume(hlua, 1)) {
case HLUA_E_OK:
tcp_ctx->flags |= APPLET_DONE;
applet_set_eos(ctx);
+
+ /* Restart to consume to drain request data */
+ applet_will_consume(ctx);
break;
/* yield. */