struct si_applet *app);
void stream_int_unregister_handler(struct stream_interface *si);
+/* initializes a stream interface in the SI_ST_INI state. It's detached from
+ * any endpoint and is only attached to an owner (generally a task).
+ */
+static inline void si_reset(struct stream_interface *si, void *owner)
+{
+ si->owner = owner;
+ si->err_type = SI_ET_NONE;
+ si->conn_retries = 0; /* used for logging too */
+ si->send_proxy_ofs = 0;
+ si->exp = TICK_ETERNITY;
+ si->flags = SI_FL_NONE;
+ si->end = NULL;
+ si->state = si->prev_state = SI_ST_INI;
+}
+
+/* sets the current and previous state of a stream interface to <state>. This
+ * is mainly used to create one in the established state on incoming
+ * conncetions.
+ */
+static inline void si_set_state(struct stream_interface *si, int state)
+{
+ si->state = si->prev_state = state;
+}
+
static inline void si_prepare_none(struct stream_interface *si)
{
si->ops = &si_embedded_ops;
s->req = s->rep = NULL; /* will be allocated later */
s->si[0].conn = NULL;
- s->si[0].owner = t;
- s->si[0].state = s->si[0].prev_state = SI_ST_EST;
- s->si[0].err_type = SI_ET_NONE;
- s->si[0].send_proxy_ofs = 0;
- s->si[0].exp = TICK_ETERNITY;
- s->si[0].flags = SI_FL_NONE;
+ si_reset(&s->si[0], t);
+ si_set_state(&s->si[0], SI_ST_EST);
+
if (s->fe->options2 & PR_O2_INDEPSTR)
s->si[0].flags |= SI_FL_INDEP_STR;
s->si[0].appctx.st0 = PEER_SESSION_CONNECT;
s->si[0].appctx.ctx.peers.ptr = (void *)ps;
- s->si[1].owner = t;
- s->si[1].state = s->si[1].prev_state = SI_ST_ASS;
+ si_reset(&s->si[1], t);
+
+ /* initiate an outgoing connection */
+ si_set_state(&s->si[1], SI_ST_ASS);
s->si[1].conn_retries = p->conn_retries;
- s->si[1].err_type = SI_ET_NONE;
- s->si[1].send_proxy_ofs = 0;
- s->si[1].exp = TICK_ETERNITY;
- s->si[1].flags = SI_FL_NONE;
+
if (s->be->options2 & PR_O2_INDEPSTR)
s->si[1].flags |= SI_FL_INDEP_STR;
LIST_INIT(&s->back_refs);
/* attach the incoming connection to the stream interface now */
+ si_reset(&s->si[0], t);
+ si_set_state(&s->si[0], SI_ST_EST);
+
+ if (likely(s->fe->options2 & PR_O2_INDEPSTR))
+ s->si[0].flags |= SI_FL_INDEP_STR;
+
s->si[0].conn = conn;
si_prepare_conn(&s->si[0], l->proto, l->xprt);
s->stkctr[i].table->data_arg[STKTABLE_DT_SESS_RATE].u, 1);
}
- /* this part should be common with other protocols */
- s->si[0].owner = t;
- s->si[0].state = s->si[0].prev_state = SI_ST_EST;
- s->si[0].err_type = SI_ET_NONE;
- s->si[0].send_proxy_ofs = 0;
- s->si[0].exp = TICK_ETERNITY;
- s->si[0].flags = SI_FL_NONE;
-
- if (likely(s->fe->options2 & PR_O2_INDEPSTR))
- s->si[0].flags |= SI_FL_INDEP_STR;
-
/* pre-initialize the other side's stream interface to an INIT state. The
* callbacks will be initialized before attempting to connect.
*/
- s->si[1].owner = t;
- s->si[1].state = s->si[1].prev_state = SI_ST_INI;
- s->si[1].err_type = SI_ET_NONE;
- s->si[1].conn_retries = 0; /* used for logging too */
- s->si[1].send_proxy_ofs = 0;
- s->si[1].exp = TICK_ETERNITY;
- s->si[1].flags = SI_FL_NONE;
-
+ si_reset(&s->si[1], t);
conn_init(s->si[1].conn);
s->si[1].conn->target = NULL;
si_prepare_none(&s->si[1]);