From: Willy Tarreau Date: Fri, 28 Nov 2014 10:26:07 +0000 (+0100) Subject: MEDIUM: stream-int: add a flag indicating which side the SI is on X-Git-Tag: v1.6-dev1~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a5f5d8dc693c045c5a1ad8600ef9ad9d776c3ed7;p=thirdparty%2Fhaproxy.git MEDIUM: stream-int: add a flag indicating which side the SI is on This new flag "SI_FL_ISBACK" is set only on the back SI and is cleared on the front SI. That way it's possible only by looking at the SI to know what side it is. --- diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index 4dfd20f81a..aba94c753b 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -108,7 +108,7 @@ static inline void si_reset(struct stream_interface *si, void *owner) si->err_type = SI_ET_NONE; si->conn_retries = 0; /* used for logging too */ si->exp = TICK_ETERNITY; - si->flags = SI_FL_NONE; + si->flags &= SI_FL_ISBACK; si->end = NULL; si->state = si->prev_state = SI_ST_INI; } diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h index 03cdd6e32e..49507a4f15 100644 --- a/include/types/stream_interface.h +++ b/include/types/stream_interface.h @@ -72,7 +72,7 @@ enum { SI_FL_ERR = 0x0002, /* a non-recoverable error has occurred */ SI_FL_WAIT_ROOM = 0x0004, /* waiting for space to store incoming data */ SI_FL_WAIT_DATA = 0x0008, /* waiting for more data to send */ - /* unused 0x0010 */ + SI_FL_ISBACK = 0x0010, /* 0 for front-side SI, 1 for back-side */ SI_FL_DONT_WAKE = 0x0020, /* resync in progress, don't wake up */ SI_FL_INDEP_STR = 0x0040, /* independent streams = don't update rex on write */ SI_FL_NOLINGER = 0x0080, /* may close without lingering. One-shot. */ diff --git a/src/hlua.c b/src/hlua.c index d106dfc25b..e899f08ca6 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -1999,6 +1999,7 @@ __LJMP static int hlua_socket_new(lua_State *L) channel_auto_connect(&socket->s->req); /* don't wait to establish connection */ channel_auto_close(&socket->s->req); /* let the producer forward close requests */ + socket->s->si[0].flags = SI_FL_NONE; si_reset(&socket->s->si[0], socket->s->task); si_set_state(&socket->s->si[0], SI_ST_EST); /* connection established (resource exists) */ @@ -2014,6 +2015,7 @@ __LJMP static int hlua_socket_new(lua_State *L) * and retrieve data from the server. The connection is initialized * with the "struct server". */ + socket->s->si[1].flags = SI_FL_ISBACK; si_reset(&socket->s->si[1], socket->s->task); si_set_state(&socket->s->si[1], SI_ST_INI); socket->s->si[1].conn_retries = socket_proxy.conn_retries; diff --git a/src/peers.c b/src/peers.c index 48f5fc45e8..d16331d996 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1163,6 +1163,9 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio s->be = s->fe = p; s->req.buf = s->res.buf = NULL; + s->si[0].flags = SI_FL_NONE; + s->si[1].flags = SI_FL_ISBACK; + si_reset(&s->si[0], t); si_set_state(&s->si[0], SI_ST_EST); diff --git a/src/proto_http.c b/src/proto_http.c index 30468eef60..7bf80ca681 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -5035,7 +5035,7 @@ void http_end_txn_clean_session(struct session *s) s->req.cons->err_type = SI_ET_NONE; s->req.cons->conn_retries = 0; /* used for logging too */ s->req.cons->exp = TICK_ETERNITY; - s->req.cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ + s->req.cons->flags &= SI_FL_ISBACK | SI_FL_DONT_WAKE; /* we're in the context of process_session */ s->req.flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); s->res.flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); diff --git a/src/session.c b/src/session.c index bb6c6e8df6..c06e29f50f 100644 --- a/src/session.c +++ b/src/session.c @@ -119,6 +119,9 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr) s->listener = l; s->fe = p; + s->si[0].flags = SI_FL_NONE; + s->si[1].flags = SI_FL_ISBACK; + /* On a mini-session, the connection is directly attached to the * session's target so that we don't need to initialize the stream * interfaces. Another benefit is that it's easy to detect a mini-