}
}
-/* Add the connection <conn> to the private conns list of session <sess>. This
- * function is called only if the connection is private. Nothing is performed
- * if the connection is already in the session list.
+/* Add the connection <conn> to the private conns list of session <sess>. Each
+ * connection is indexed by their respective target in the session. Nothing is
+ * performed if the connection is already in the session list.
+ *
+ * Returns true if conn is inserted or already present else false if a failure
+ * occurs during insertion.
*/
-static inline int session_add_conn(struct session *sess, struct connection *conn, void *target)
+static inline int session_add_conn(struct session *sess, struct connection *conn)
{
struct sess_priv_conns *pconns = NULL;
struct server *srv = objt_server(conn->target);
int found = 0;
- BUG_ON(objt_listener(conn->target));
+ /* Connection target is used to index it in the session. Only BE conns are expected in session list. */
+ BUG_ON(!conn->target || objt_listener(conn->target));
/* A connection cannot be attached already to another session. */
BUG_ON(conn->owner && conn->owner != sess);
return 1;
list_for_each_entry(pconns, &sess->priv_conns, sess_el) {
- if (pconns->target == target) {
+ if (pconns->target == conn->target) {
found = 1;
break;
}
pconns = pool_alloc(pool_head_sess_priv_conns);
if (!pconns)
return 0;
- pconns->target = target;
+ pconns->target = conn->target;
LIST_INIT(&pconns->conn_list);
LIST_APPEND(&sess->priv_conns, &pconns->sess_el);
if (reuse_mode == PR_O_REUSE_SAFE && conn->mux->flags & MX_FL_HOL_RISK) {
/* attach the connection to the session private list */
conn->owner = sess;
- session_add_conn(sess, conn, conn->target);
+ session_add_conn(sess, conn);
}
else {
srv_add_to_avail_list(srv, conn);
(reuse_mode == PR_O_REUSE_SAFE &&
srv_conn->mux->flags & MX_FL_HOL_RISK)) {
/* If it fail now, the same will be done in mux->detach() callback */
- session_add_conn(s->sess, srv_conn, srv_conn->target);
+ session_add_conn(s->sess, srv_conn);
}
}
}
}
else if (conn->flags & CO_FL_PRIVATE) {
/* If it fail now, the same will be done in mux->detach() callback */
- session_add_conn(sess, conn, conn->target);
+ session_add_conn(sess, conn);
}
return 0;
fail:
conn_set_owner(srv_conn, sess, NULL);
conn_set_private(srv_conn);
/* If it fail now, the same will be done in mux->detach() callback */
- session_add_conn(srv_conn->owner, srv_conn, srv_conn->target);
+ session_add_conn(srv_conn->owner, srv_conn);
break;
}
}
(fconn->flags & FCGI_CF_KEEP_CONN)) {
if (fconn->conn->flags & CO_FL_PRIVATE) {
/* Add the connection in the session serverlist, if not already done */
- if (!session_add_conn(sess, fconn->conn, fconn->conn->target)) {
+ if (!session_add_conn(sess, fconn->conn)) {
fconn->conn->owner = NULL;
if (eb_is_empty(&fconn->streams_by_id)) {
/* let's kill the connection right away */
if (h1c->conn->flags & CO_FL_PRIVATE) {
/* Add the connection in the session server list, if not already done */
- if (!session_add_conn(sess, h1c->conn, h1c->conn->target)) {
+ if (!session_add_conn(sess, h1c->conn)) {
h1c->conn->owner = NULL;
h1c->conn->mux->destroy(h1c);
goto released;
if (h2c->conn->flags & CO_FL_PRIVATE) {
/* Add the connection in the session server list, if not already done */
- if (!session_add_conn(sess, h2c->conn, h2c->conn->target)) {
+ if (!session_add_conn(sess, h2c->conn)) {
h2c->conn->owner = NULL;
if (eb_is_empty(&h2c->streams_by_id)) {
h2c->conn->mux->destroy(h2c);
* conn will be closed if idle, or insert will be
* retried on next detach.
*/
- if (!session_add_conn(sess, conn, conn->target)) {
+ if (!session_add_conn(sess, conn)) {
TRACE_ERROR("error during connection insert into session list", QMUX_EV_STRM_END, conn);
conn->owner = NULL;
if (!qcc->nb_sc)
if (!(spop_conn->flags & (SPOP_CF_RCVD_SHUT|SPOP_CF_ERR_PENDING|SPOP_CF_ERROR))) {
if (spop_conn->conn->flags & CO_FL_PRIVATE) {
/* Add the connection in the session server list, if not already done */
- if (!session_add_conn(sess, spop_conn->conn, spop_conn->conn->target)) {
+ if (!session_add_conn(sess, spop_conn->conn)) {
spop_conn->conn->owner = NULL;
if (eb_is_empty(&spop_conn->streams_by_id)) {
spop_conn->conn->mux->destroy(spop_conn);