/* This function initiates a server connection request on a conn-stream
* already in CS_ST_REQ state. Upon success, the state goes to CS_ST_ASS for
* a real connection to a server, indicating that a server has been assigned,
- * or CS_ST_EST for a successful connection to an applet. It may also return
+ * or CS_ST_RDY for a successful connection to an applet. It may also return
* CS_ST_QUE, or CS_ST_CLO upon error.
*/
void back_handle_st_req(struct stream *s)
DBG_TRACE_ENTER(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s);
if (unlikely(obj_type(s->target) == OBJ_TYPE_APPLET)) {
- /* the applet directly goes to the EST state */
- struct appctx *appctx = cs_appctx(s->csb);
-
- if (!appctx)
- appctx = cs_applet_create(cs, objt_applet(s->target));
+ struct appctx *appctx;
+ /* The target is an applet but the CS is in CS_ST_REQ. Thus it
+ * means no appctx are attached to the CS. Otherwise, it will be
+ * in CS_ST_RDY state. So, try to create the appctx now.
+ */
+ BUG_ON(cs_appctx(cs));
+ appctx = cs_applet_create(cs, objt_applet(s->target));
if (!appctx) {
/* No more memory, let's immediately abort. Force the
* error code to ignore the ERR_LOCAL which is not a
goto end;
}
- if (tv_iszero(&s->logs.tv_request))
- s->logs.tv_request = now;
- s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
- cs->state = CS_ST_EST;
- s->conn_err_type = STRM_ET_NONE;
- be_set_sess_last(s->be);
-
DBG_TRACE_STATE("applet registered", STRM_EV_STRM_PROC|STRM_EV_CS_ST, s);
- /* let back_establish() finish the job */
goto end;
}
struct channel *rep = &s->res;
DBG_TRACE_ENTER(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s);
+
+ if (unlikely(obj_type(s->target) == OBJ_TYPE_APPLET)) {
+ /* Here the appctx must exists because the CS was set to
+ * CS_ST_RDY state when the appctx was created.
+ */
+ BUG_ON(!cs_appctx(s->csb));
+
+ if (tv_iszero(&s->logs.tv_request))
+ s->logs.tv_request = now;
+ s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
+ be_set_sess_last(s->be);
+ }
+
/* We know the connection at least succeeded, though it could have
* since met an error for any other reason. At least it didn't time out
* even though the timeout might have been reported right after success.