MEDIUM: channel: don't always set CF_WAKE_WRITE on bi_put*
It was inappropriate to put this flag on every failed write into an
input buffer because it depends where it happens. When it's in the
context of an analyser (eg: hlua) it makes sense. When it's in the
context of an applet (eg: dumpstats), it does not make sense, and
it only happens to work because currently applets are scheduled by
the sessions. The proper solution for applets would be to add the
flag SI_FL_WAIT_ROOM on the stream interface.
Thus, we now don't set any flag anymore in bi_put* and it's up to the
caller to either set CF_WAKE_WRITE on the channel or SI_FL_WAIT_ROOM
on the stream interface. Changes were applied to hlua, peers and
dumpstats.
diff --git a/src/peers.c b/src/peers.c
index 53e5035..792260f 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -450,7 +450,7 @@
repl = bi_putblk(si_ic(si), trash.str, repl);
if (repl <= 0) {
if (repl == -1)
- goto out;
+ goto full;
appctx->st0 = PEER_SESS_ST_END;
goto switchstate;
}
@@ -514,7 +514,7 @@
repl = bi_putblk(si_ic(si), trash.str, repl);
if (repl <= 0) {
if (repl == -1)
- goto out;
+ goto full;
appctx->st0 = PEER_SESS_ST_END;
goto switchstate;
}
@@ -848,7 +848,7 @@
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
- goto out;
+ goto full;
appctx->st0 = PEER_SESS_ST_END;
goto switchstate;
}
@@ -865,7 +865,7 @@
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
- goto out;
+ goto full;
appctx->st0 = PEER_SESS_ST_END;
goto switchstate;
}
@@ -884,7 +884,7 @@
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
- goto out;
+ goto full;
appctx->st0 = PEER_SESS_ST_END;
goto switchstate;
}
@@ -920,7 +920,7 @@
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
- goto out;
+ goto full;
appctx->st0 = PEER_SESS_ST_END;
goto switchstate;
}
@@ -954,7 +954,7 @@
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
- goto out;
+ goto full;
appctx->st0 = PEER_SESS_ST_END;
goto switchstate;
}
@@ -970,7 +970,7 @@
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
- goto out;
+ goto full;
appctx->st0 = PEER_SESS_ST_END;
goto switchstate;
}
@@ -1012,7 +1012,7 @@
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
- goto out;
+ goto full;
appctx->st0 = PEER_SESS_ST_END;
goto switchstate;
}
@@ -1028,7 +1028,7 @@
repl = snprintf(trash.str, trash.size, "%d\n", appctx->st1);
if (bi_putblk(si_ic(si), trash.str, repl) == -1)
- goto out;
+ goto full;
appctx->st0 = PEER_SESS_ST_END;
/* fall through */
case PEER_SESS_ST_END: {
@@ -1047,6 +1047,9 @@
si_oc(si)->wex = TICK_ETERNITY;
quit:
return;
+full:
+ si->flags |= SI_FL_WAIT_ROOM;
+ goto out;
}
static struct si_applet peer_applet = {