MEDIUM: tree-wide: Move flags about shut from the channel to the SC
The purpose of this patch is only a one-to-one replacement, as far as
possible.
CF_SHUTR(_NOW) and CF_SHUTW(_NOW) flags are now carried by the
stream-connecter. CF_ prefix is replaced by SC_FL_ one. Of course, it is not
so simple because at many places, we were testing if a channel was shut for
reads and writes in same time. To do the same, shut for reads must be tested
on one side on the SC and shut for writes on the other side on the opposite
SC. A special care was taken with process_stream(). flags of SCs must be
saved to be able to detect changes, just like for the channels.
diff --git a/src/backend.c b/src/backend.c
index af39fef..4fa5f24 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1956,7 +1956,7 @@
static int back_may_abort_req(struct channel *req, struct stream *s)
{
return (sc_ep_test(s->scf, SE_FL_ERROR) ||
- ((req->flags & (CF_SHUTW_NOW|CF_SHUTW)) && /* empty and client aborted */
+ ((chn_cons(req)->flags & (SC_FL_SHUTW_NOW|SC_FL_SHUTW)) && /* empty and client aborted */
(channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE))));
}
@@ -2246,8 +2246,8 @@
DBG_TRACE_ENTER(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s);
/* the client might want to abort */
- if ((rep->flags & CF_SHUTW) ||
- ((req->flags & CF_SHUTW_NOW) &&
+ if ((chn_cons(rep)->flags & SC_FL_SHUTW) ||
+ ((chn_cons(req)->flags & SC_FL_SHUTW_NOW) &&
(channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
sc->flags |= SC_FL_NOLINGER;
sc_shutw(sc);
@@ -2470,8 +2470,8 @@
*/
if (!(req->flags & CF_WROTE_DATA)) {
/* client abort ? */
- if ((rep->flags & CF_SHUTW) ||
- ((req->flags & CF_SHUTW_NOW) &&
+ if ((chn_cons(rep)->flags & SC_FL_SHUTW) ||
+ ((chn_cons(req)->flags & SC_FL_SHUTW_NOW) &&
(channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
/* give up */
sc->flags |= SC_FL_NOLINGER;