]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream-int: add a flag indicating which side the SI is on
authorWilly Tarreau <w@1wt.eu>
Fri, 28 Nov 2014 10:26:07 +0000 (11:26 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 11 Mar 2015 19:41:46 +0000 (20:41 +0100)
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.

include/proto/stream_interface.h
include/types/stream_interface.h
src/hlua.c
src/peers.c
src/proto_http.c
src/session.c

index 4dfd20f81a5e63f5acd2125c6fde4a55ce82b3d2..aba94c753b21051ed1fe98790cd026061d5110c0 100644 (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;
 }
index 03cdd6e32e9184031d9624821bad3929328dc177..49507a4f15be77ee1bd5051509130fd8aad47525 100644 (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. */
index d106dfc25b2b0712463f2dd35d5f74f957914412..e899f08ca68b7a221113ac596fc9e0f46832477e 100644 (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;
index 48f5fc45e86c475248311d474bc3113fb3ba2c07..d16331d9968e2e9fc1385bcdd6c19046e297e3d7 100644 (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);
 
index 30468eef6096097f876913b52dd979657af9fdc1..7bf80ca6817f15f1242ffedda50a6e1f82c00503 100644 (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);
index bb6c6e8df6042cddce5602c2cfba3cb0dc660118..c06e29f50f8473b75da3ff49d1e08b5899c09e8e 100644 (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-