mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
MINOR: session: remove redundant target argument from session_add_conn()
session_add_conn() uses three argument : connection and session instances, plus a void pointer labelled as target. Typically, it represents the server, but can also be a backend instance (for example on dispatch). In fact, this argument is redundant as <target> is already a member of the connection. This commit simplifies session_add_conn() by removing it. A BUG_ON() on target is extended to ensure it is never NULL.
This commit is contained in:
parent
668c2cfb09
commit
ec1ab8d171
@ -171,17 +171,21 @@ static inline void session_unown_conn(struct session *sess, struct connection *c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the connection <conn> to the private conns list of session <sess>. This
|
/* Add the connection <conn> to the private conns list of session <sess>. Each
|
||||||
* function is called only if the connection is private. Nothing is performed
|
* connection is indexed by their respective target in the session. Nothing is
|
||||||
* if the connection is already in the session list.
|
* 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 sess_priv_conns *pconns = NULL;
|
||||||
struct server *srv = objt_server(conn->target);
|
struct server *srv = objt_server(conn->target);
|
||||||
int found = 0;
|
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. */
|
/* A connection cannot be attached already to another session. */
|
||||||
BUG_ON(conn->owner && conn->owner != sess);
|
BUG_ON(conn->owner && conn->owner != sess);
|
||||||
@ -191,7 +195,7 @@ static inline int session_add_conn(struct session *sess, struct connection *conn
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
list_for_each_entry(pconns, &sess->priv_conns, sess_el) {
|
list_for_each_entry(pconns, &sess->priv_conns, sess_el) {
|
||||||
if (pconns->target == target) {
|
if (pconns->target == conn->target) {
|
||||||
found = 1;
|
found = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -201,7 +205,7 @@ static inline int session_add_conn(struct session *sess, struct connection *conn
|
|||||||
pconns = pool_alloc(pool_head_sess_priv_conns);
|
pconns = pool_alloc(pool_head_sess_priv_conns);
|
||||||
if (!pconns)
|
if (!pconns)
|
||||||
return 0;
|
return 0;
|
||||||
pconns->target = target;
|
pconns->target = conn->target;
|
||||||
LIST_INIT(&pconns->conn_list);
|
LIST_INIT(&pconns->conn_list);
|
||||||
LIST_APPEND(&sess->priv_conns, &pconns->sess_el);
|
LIST_APPEND(&sess->priv_conns, &pconns->sess_el);
|
||||||
|
|
||||||
|
@ -1425,7 +1425,7 @@ struct connection *conn_backend_get(int reuse_mode,
|
|||||||
if (reuse_mode == PR_O_REUSE_SAFE && conn->mux->flags & MX_FL_HOL_RISK) {
|
if (reuse_mode == PR_O_REUSE_SAFE && conn->mux->flags & MX_FL_HOL_RISK) {
|
||||||
/* attach the connection to the session private list */
|
/* attach the connection to the session private list */
|
||||||
conn->owner = sess;
|
conn->owner = sess;
|
||||||
session_add_conn(sess, conn, conn->target);
|
session_add_conn(sess, conn);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
srv_add_to_avail_list(srv, conn);
|
srv_add_to_avail_list(srv, conn);
|
||||||
@ -2159,7 +2159,7 @@ int connect_server(struct stream *s)
|
|||||||
(reuse_mode == PR_O_REUSE_SAFE &&
|
(reuse_mode == PR_O_REUSE_SAFE &&
|
||||||
srv_conn->mux->flags & MX_FL_HOL_RISK)) {
|
srv_conn->mux->flags & MX_FL_HOL_RISK)) {
|
||||||
/* If it fail now, the same will be done in mux->detach() callback */
|
/* 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ int conn_create_mux(struct connection *conn, int *closed_connection)
|
|||||||
}
|
}
|
||||||
else if (conn->flags & CO_FL_PRIVATE) {
|
else if (conn->flags & CO_FL_PRIVATE) {
|
||||||
/* If it fail now, the same will be done in mux->detach() callback */
|
/* 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;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
|
@ -1641,7 +1641,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
|||||||
conn_set_owner(srv_conn, sess, NULL);
|
conn_set_owner(srv_conn, sess, NULL);
|
||||||
conn_set_private(srv_conn);
|
conn_set_private(srv_conn);
|
||||||
/* If it fail now, the same will be done in mux->detach() callback */
|
/* 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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3723,7 +3723,7 @@ static void fcgi_detach(struct sedesc *sd)
|
|||||||
(fconn->flags & FCGI_CF_KEEP_CONN)) {
|
(fconn->flags & FCGI_CF_KEEP_CONN)) {
|
||||||
if (fconn->conn->flags & CO_FL_PRIVATE) {
|
if (fconn->conn->flags & CO_FL_PRIVATE) {
|
||||||
/* Add the connection in the session serverlist, if not already done */
|
/* 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;
|
fconn->conn->owner = NULL;
|
||||||
if (eb_is_empty(&fconn->streams_by_id)) {
|
if (eb_is_empty(&fconn->streams_by_id)) {
|
||||||
/* let's kill the connection right away */
|
/* let's kill the connection right away */
|
||||||
|
@ -1138,7 +1138,7 @@ static int h1s_finish_detach(struct h1s *h1s)
|
|||||||
|
|
||||||
if (h1c->conn->flags & CO_FL_PRIVATE) {
|
if (h1c->conn->flags & CO_FL_PRIVATE) {
|
||||||
/* Add the connection in the session server list, if not already done */
|
/* 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->owner = NULL;
|
||||||
h1c->conn->mux->destroy(h1c);
|
h1c->conn->mux->destroy(h1c);
|
||||||
goto released;
|
goto released;
|
||||||
|
@ -5533,7 +5533,7 @@ static void h2_detach(struct sedesc *sd)
|
|||||||
|
|
||||||
if (h2c->conn->flags & CO_FL_PRIVATE) {
|
if (h2c->conn->flags & CO_FL_PRIVATE) {
|
||||||
/* Add the connection in the session server list, if not already done */
|
/* 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;
|
h2c->conn->owner = NULL;
|
||||||
if (eb_is_empty(&h2c->streams_by_id)) {
|
if (eb_is_empty(&h2c->streams_by_id)) {
|
||||||
h2c->conn->mux->destroy(h2c);
|
h2c->conn->mux->destroy(h2c);
|
||||||
|
@ -3788,7 +3788,7 @@ static void qmux_strm_detach(struct sedesc *sd)
|
|||||||
* conn will be closed if idle, or insert will be
|
* conn will be closed if idle, or insert will be
|
||||||
* retried on next detach.
|
* 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);
|
TRACE_ERROR("error during connection insert into session list", QMUX_EV_STRM_END, conn);
|
||||||
conn->owner = NULL;
|
conn->owner = NULL;
|
||||||
if (!qcc->nb_sc)
|
if (!qcc->nb_sc)
|
||||||
|
@ -2977,7 +2977,7 @@ static void spop_detach(struct sedesc *sd)
|
|||||||
if (!(spop_conn->flags & (SPOP_CF_RCVD_SHUT|SPOP_CF_ERR_PENDING|SPOP_CF_ERROR))) {
|
if (!(spop_conn->flags & (SPOP_CF_RCVD_SHUT|SPOP_CF_ERR_PENDING|SPOP_CF_ERROR))) {
|
||||||
if (spop_conn->conn->flags & CO_FL_PRIVATE) {
|
if (spop_conn->conn->flags & CO_FL_PRIVATE) {
|
||||||
/* Add the connection in the session server list, if not already done */
|
/* 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;
|
spop_conn->conn->owner = NULL;
|
||||||
if (eb_is_empty(&spop_conn->streams_by_id)) {
|
if (eb_is_empty(&spop_conn->streams_by_id)) {
|
||||||
spop_conn->conn->mux->destroy(spop_conn);
|
spop_conn->conn->mux->destroy(spop_conn);
|
||||||
|
Loading…
Reference in New Issue
Block a user