CLEANUP: stconn: rename cs_cant_get() to se_need_more_data()
An equivalent applet_need_more_data() was added as well since that function is mostly used from applet code. It makes it much clearer that the applet is waiting for data from the stream layer.
This commit is contained in:
parent
75a8f8e290
commit
90e8b455b7
@ -160,6 +160,15 @@ static inline void applet_wont_consume(struct appctx *appctx)
|
||||
se_fl_clr(appctx->sedesc, SE_FL_WILL_CONSUME);
|
||||
}
|
||||
|
||||
/* The applet indicates that it's willing to consume data from the stream's
|
||||
* output buffer, but that there's not enough, so it doesn't want to be woken
|
||||
* up until more are presented.
|
||||
*/
|
||||
static inline void applet_need_more_data(struct appctx *appctx)
|
||||
{
|
||||
se_fl_set(appctx->sedesc, SE_FL_WILL_CONSUME | SE_FL_WAIT_DATA);
|
||||
}
|
||||
|
||||
/* writes chunk <chunk> into the input channel of the stream attached to this
|
||||
* appctx's endpoint, and marks the SC_FL_NEED_ROOM on a channel full error.
|
||||
* See ci_putchk() for the list of return codes.
|
||||
|
@ -389,10 +389,13 @@ static inline void se_wont_consume(struct sedesc *se)
|
||||
se_fl_clr(se, SE_FL_WILL_CONSUME);
|
||||
}
|
||||
|
||||
/* Report that a stream connector failed to get some data from the output buffer */
|
||||
static inline void cs_cant_get(struct stconn *cs)
|
||||
/* The stream endpoint indicates that it's willing to consume data from the
|
||||
* stream's output buffer, but that there's not enough, so it doesn't want to
|
||||
* be woken up until more are presented.
|
||||
*/
|
||||
static inline void se_need_more_data(struct sedesc *se)
|
||||
{
|
||||
sc_ep_set(cs, SE_FL_WILL_CONSUME | SE_FL_WAIT_DATA);
|
||||
se_fl_set(se, SE_FL_WILL_CONSUME | SE_FL_WAIT_DATA);
|
||||
}
|
||||
|
||||
#endif /* _HAPROXY_CONN_STREAM_H */
|
||||
|
@ -218,7 +218,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
|
||||
* put, it's up to it to change this if needed. This ensures
|
||||
* that one applet which ignores any event will not spin.
|
||||
*/
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(app);
|
||||
applet_have_no_more_data(app);
|
||||
|
||||
/* Now we'll try to allocate the input buffer. We wake up the applet in
|
||||
|
@ -489,7 +489,7 @@ struct appctx *cs_applet_create(struct stconn *cs, struct applet *app)
|
||||
return NULL;
|
||||
cs_attach_applet(cs, appctx);
|
||||
appctx->t->nice = __sc_strm(cs)->task->nice;
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(appctx);
|
||||
appctx_wakeup(appctx);
|
||||
|
||||
cs->state = SC_ST_RDY;
|
||||
|
@ -472,7 +472,7 @@ static void dns_session_io_handler(struct appctx *appctx)
|
||||
* to be notified whenever the connection completes.
|
||||
*/
|
||||
if (cs_opposite(cs)->state < SC_ST_EST) {
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(appctx);
|
||||
se_need_remote_conn(appctx->sedesc);
|
||||
applet_have_more_data(appctx);
|
||||
return;
|
||||
|
@ -1242,7 +1242,7 @@ spoe_init_appctx(struct appctx *appctx)
|
||||
stream_set_backend(s, agent->b.be);
|
||||
|
||||
/* applet is waiting for data */
|
||||
cs_cant_get(s->scf);
|
||||
applet_need_more_data(appctx);
|
||||
|
||||
s->do_log = NULL;
|
||||
s->res.flags |= CF_READ_DONTWAIT;
|
||||
|
22
src/hlua.c
22
src/hlua.c
@ -1956,7 +1956,7 @@ static void hlua_socket_handler(struct appctx *appctx)
|
||||
* to be notified whenever the connection completes.
|
||||
*/
|
||||
if (cs_opposite(cs)->state < SC_ST_EST) {
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(appctx);
|
||||
se_need_remote_conn(appctx->sedesc);
|
||||
applet_have_more_data(appctx);
|
||||
return;
|
||||
@ -2858,7 +2858,7 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
|
||||
/* inform the stream that we want to be notified whenever the
|
||||
* connection completes.
|
||||
*/
|
||||
cs_cant_get(s->scf);
|
||||
applet_need_more_data(appctx);
|
||||
applet_have_more_data(appctx);
|
||||
appctx_wakeup(appctx);
|
||||
|
||||
@ -4491,7 +4491,7 @@ __LJMP static int hlua_applet_tcp_getline_yield(lua_State *L, int status, lua_KC
|
||||
|
||||
/* Data not yet available. return yield. */
|
||||
if (ret == 0) {
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(luactx->appctx);
|
||||
MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_tcp_getline_yield, TICK_ETERNITY, 0));
|
||||
}
|
||||
|
||||
@ -4546,7 +4546,7 @@ __LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KCont
|
||||
|
||||
/* Data not yet available. return yield. */
|
||||
if (ret == 0) {
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(luactx->appctx);
|
||||
MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_tcp_recv_yield, TICK_ETERNITY, 0));
|
||||
}
|
||||
|
||||
@ -4569,7 +4569,7 @@ __LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KCont
|
||||
luaL_addlstring(&luactx->b, blk1, len1);
|
||||
luaL_addlstring(&luactx->b, blk2, len2);
|
||||
co_skip(sc_oc(cs), len1 + len2);
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(luactx->appctx);
|
||||
MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_tcp_recv_yield, TICK_ETERNITY, 0));
|
||||
|
||||
} else {
|
||||
@ -4593,7 +4593,7 @@ __LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KCont
|
||||
if (len > 0) {
|
||||
lua_pushinteger(L, len);
|
||||
lua_replace(L, 2);
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(luactx->appctx);
|
||||
MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_tcp_recv_yield, TICK_ETERNITY, 0));
|
||||
}
|
||||
|
||||
@ -5035,7 +5035,7 @@ __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_K
|
||||
|
||||
htx_to_buf(htx, &req->buf);
|
||||
if (!stop) {
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(luactx->appctx);
|
||||
MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_http_getline_yield, TICK_ETERNITY, 0));
|
||||
}
|
||||
|
||||
@ -5133,7 +5133,7 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon
|
||||
lua_pushinteger(L, len);
|
||||
lua_replace(L, 2);
|
||||
}
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(luactx->appctx);
|
||||
MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_http_recv_yield, TICK_ETERNITY, 0));
|
||||
}
|
||||
|
||||
@ -9305,7 +9305,7 @@ static int hlua_applet_tcp_init(struct appctx *ctx)
|
||||
RESET_SAFE_LJMP(hlua);
|
||||
|
||||
/* Wakeup the applet ASAP. */
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(ctx);
|
||||
applet_have_more_data(ctx);
|
||||
|
||||
return 0;
|
||||
@ -9502,7 +9502,7 @@ static int hlua_applet_http_init(struct appctx *ctx)
|
||||
RESET_SAFE_LJMP(hlua);
|
||||
|
||||
/* Wakeup the applet when data is ready for read. */
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -9538,7 +9538,7 @@ void hlua_applet_http_fct(struct appctx *ctx)
|
||||
if (!HLUA_IS_RUNNING(hlua) &&
|
||||
!(http_ctx->flags & APPLET_DONE)) {
|
||||
if (!co_data(req)) {
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(ctx);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -1018,7 +1018,7 @@ static int httpclient_applet_init(struct appctx *appctx)
|
||||
s->res.flags |= CF_READ_DONTWAIT;
|
||||
|
||||
/* applet is waiting for data */
|
||||
cs_cant_get(s->scf);
|
||||
applet_need_more_data(appctx);
|
||||
appctx_wakeup(appctx);
|
||||
|
||||
hc->appctx = appctx;
|
||||
|
@ -1085,7 +1085,7 @@ static int peer_session_init(struct appctx *appctx)
|
||||
|
||||
s = appctx_strm(appctx);
|
||||
/* applet is waiting for data */
|
||||
cs_cant_get(s->scf);
|
||||
applet_need_more_data(appctx);
|
||||
appctx_wakeup(appctx);
|
||||
|
||||
/* initiate an outgoing connection */
|
||||
|
@ -333,7 +333,7 @@ static void sink_forward_io_handler(struct appctx *appctx)
|
||||
* to be notified whenever the connection completes.
|
||||
*/
|
||||
if (cs_opposite(cs)->state < SC_ST_EST) {
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(appctx);
|
||||
se_need_remote_conn(appctx->sedesc);
|
||||
applet_have_more_data(appctx);
|
||||
return;
|
||||
@ -473,7 +473,7 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
|
||||
* to be notified whenever the connection completes.
|
||||
*/
|
||||
if (cs_opposite(cs)->state < SC_ST_EST) {
|
||||
cs_cant_get(cs);
|
||||
applet_need_more_data(appctx);
|
||||
se_need_remote_conn(appctx->sedesc);
|
||||
applet_have_more_data(appctx);
|
||||
return;
|
||||
|
@ -1013,7 +1013,7 @@ enum act_return process_use_service(struct act_rule *rule, struct proxy *px,
|
||||
}
|
||||
|
||||
/* Now we can schedule the applet. */
|
||||
cs_cant_get(s->scb);
|
||||
applet_need_more_data(appctx);
|
||||
appctx_wakeup(appctx);
|
||||
return ACT_RET_STOP;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user