if (t)
task_queue(t);
- if (h2c->flags & H2_CF_IS_BACK) {
+ if (h2c->flags & H2_CF_IS_BACK && likely(!conn_is_reverse(h2c->conn))) {
/* FIXME: this is temporary, for outgoing connections we need
* to immediately allocate a stream until the code is modified
* so that the caller calls ->attach(). For now the outgoing sc
goto fail_stream;
}
- proxy_inc_fe_cum_sess_ver_ctr(sess->listener, prx, 2);
+ if (sess)
+ proxy_inc_fe_cum_sess_ver_ctr(sess->listener, prx, 2);
HA_ATOMIC_INC(&h2c->px_counters->open_conns);
HA_ATOMIC_INC(&h2c->px_counters->total_conns);
cli_conn->proxy_netns = l->rx.settings->netns;
- if (conn_prepare(cli_conn, l->rx.proto, l->bind_conf->xprt) < 0)
- goto out_free_conn;
+ /* Active reversed connection has already been initialized before being
+ * accepted. It must not be resetted.
+ * TODO use a dedicated accept_fd callback for reverse protocol
+ */
+ if (!cli_conn->xprt) {
+ if (conn_prepare(cli_conn, l->rx.proto, l->bind_conf->xprt) < 0)
+ goto out_free_conn;
- conn_ctrl_init(cli_conn);
+ conn_ctrl_init(cli_conn);
- /* wait for a PROXY protocol header */
- if (l->bind_conf->options & BC_O_ACC_PROXY)
- cli_conn->flags |= CO_FL_ACCEPT_PROXY;
+ /* wait for a PROXY protocol header */
+ if (l->bind_conf->options & BC_O_ACC_PROXY)
+ cli_conn->flags |= CO_FL_ACCEPT_PROXY;
- /* wait for a NetScaler client IP insertion protocol header */
- if (l->bind_conf->options & BC_O_ACC_CIP)
- cli_conn->flags |= CO_FL_ACCEPT_CIP;
+ /* wait for a NetScaler client IP insertion protocol header */
+ if (l->bind_conf->options & BC_O_ACC_CIP)
+ cli_conn->flags |= CO_FL_ACCEPT_CIP;
- /* Add the handshake pseudo-XPRT */
- if (cli_conn->flags & (CO_FL_ACCEPT_PROXY | CO_FL_ACCEPT_CIP)) {
- if (xprt_add_hs(cli_conn) != 0)
- goto out_free_conn;
+ /* Add the handshake pseudo-XPRT */
+ if (cli_conn->flags & (CO_FL_ACCEPT_PROXY | CO_FL_ACCEPT_CIP)) {
+ if (xprt_add_hs(cli_conn) != 0)
+ goto out_free_conn;
+ }
}
+
sess = session_new(p, l, &cli_conn->obj_type);
if (!sess)
goto out_free_conn;
MSG_DONTWAIT|MSG_NOSIGNAL);
}
- conn_stop_tracking(cli_conn);
- conn_full_close(cli_conn);
- conn_free(cli_conn);
+ if (cli_conn->mux) {
+ /* Mux is already initialized for active reversed connection. */
+ cli_conn->mux->destroy(cli_conn->ctx);
+ }
+ else {
+ conn_stop_tracking(cli_conn);
+ conn_full_close(cli_conn);
+ conn_free(cli_conn);
+ }
listener_release(l);
return ret;
}
goto fail;
session_count_new(sess);
- if (conn_install_mux_fe(conn, NULL) < 0)
- goto fail;
+ if (!conn->mux) {
+ if (conn_install_mux_fe(conn, NULL) < 0)
+ goto fail;
+ }
/* the embryonic session's task is not needed anymore */
task_destroy(sess->task);