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.
diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h
index 35b600b..d695d04 100644
--- a/include/haproxy/applet.h
+++ b/include/haproxy/applet.h
@@ -160,6 +160,15 @@
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.
diff --git a/include/haproxy/conn_stream.h b/include/haproxy/conn_stream.h
index 2f7b457..b48b4f1 100644
--- a/include/haproxy/conn_stream.h
+++ b/include/haproxy/conn_stream.h
@@ -389,10 +389,13 @@
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 */
diff --git a/src/applet.c b/src/applet.c
index 7e7f47d..834c479 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -218,7 +218,7 @@
* 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
diff --git a/src/conn_stream.c b/src/conn_stream.c
index 3e89512..1695541 100644
--- a/src/conn_stream.c
+++ b/src/conn_stream.c
@@ -489,7 +489,7 @@
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;
diff --git a/src/dns.c b/src/dns.c
index 3bb2653..69f16bc 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -472,7 +472,7 @@
* 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;
diff --git a/src/flt_spoe.c b/src/flt_spoe.c
index fc41f52..53c8def 100644
--- a/src/flt_spoe.c
+++ b/src/flt_spoe.c
@@ -1242,7 +1242,7 @@
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;
diff --git a/src/hlua.c b/src/hlua.c
index 64a6ae8..292d8f2 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -1956,7 +1956,7 @@
* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;
}
}
diff --git a/src/http_client.c b/src/http_client.c
index da774e7..ee0c69a 100644
--- a/src/http_client.c
+++ b/src/http_client.c
@@ -1018,7 +1018,7 @@
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;
diff --git a/src/peers.c b/src/peers.c
index 81af529..ae650a6 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1085,7 +1085,7 @@
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 */
diff --git a/src/sink.c b/src/sink.c
index f8e9404..4f39c05 100644
--- a/src/sink.c
+++ b/src/sink.c
@@ -333,7 +333,7 @@
* 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 @@
* 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;
diff --git a/src/stream.c b/src/stream.c
index 4ca48fe..16456e0 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -1013,7 +1013,7 @@
}
/* Now we can schedule the applet. */
- cs_cant_get(s->scb);
+ applet_need_more_data(appctx);
appctx_wakeup(appctx);
return ACT_RET_STOP;
}