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.
This commit is contained in:
Willy Tarreau 2014-11-28 11:26:07 +01:00
parent 2bb4a96f8f
commit a5f5d8dc69
6 changed files with 11 additions and 3 deletions

View File

@ -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;
}

View File

@ -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. */

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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-