From 5941ef0a6ce20dc767a4bb5c83205b8eb0ae56ff Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 18 Jun 2021 18:29:25 +0200 Subject: [PATCH] MINOR: lb/api: remove the locked argument from take_conn/drop_conn This essentially reverts commit 2b4370078 ("MINOR: lb/api: let callers of take_conn/drop_conn tell if they have the lock") that was merged during 2.4 before the various locks could be eliminated at the lower layers. Passing that information complicates the cleanup of the queuing code and it's become useless. --- include/haproxy/backend-t.h | 6 +++--- src/backend.c | 2 +- src/lb_fas.c | 6 ++---- src/lb_fwlc.c | 6 ++---- src/queue.c | 2 +- src/stream.c | 4 ++-- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/include/haproxy/backend-t.h b/include/haproxy/backend-t.h index 8bee110fe..126528400 100644 --- a/include/haproxy/backend-t.h +++ b/include/haproxy/backend-t.h @@ -162,13 +162,13 @@ struct lbprm { /* Call backs for some actions. Any of them may be NULL (thus should be ignored). * Those marked "srvlock" will need to be called with the server lock held. - * The other ones might take it themselves if needed, based on indications. + * The other ones might take it themselves if needed. */ void (*update_server_eweight)(struct server *); /* to be called after eweight change // srvlock */ void (*set_server_status_up)(struct server *); /* to be called after status changes to UP // srvlock */ void (*set_server_status_down)(struct server *); /* to be called after status changes to DOWN // srvlock */ - void (*server_take_conn)(struct server *, int locked); /* to be called when connection is assigned */ - void (*server_drop_conn)(struct server *, int locked); /* to be called when connection is dropped */ + void (*server_take_conn)(struct server *); /* to be called when connection is assigned */ + void (*server_drop_conn)(struct server *); /* to be called when connection is dropped */ }; #endif /* _HAPROXY_BACKEND_T_H */ diff --git a/src/backend.c b/src/backend.c index 9307bac8f..7b14df752 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1702,7 +1702,7 @@ skip_reuse: count = _HA_ATOMIC_ADD_FETCH(&srv->cur_sess, 1); HA_ATOMIC_UPDATE_MAX(&srv->counters.cur_sess_max, count); if (s->be->lbprm.server_take_conn) - s->be->lbprm.server_take_conn(srv, 0); + s->be->lbprm.server_take_conn(srv); } /* Now handle synchronously connected sockets. We know the stream-int diff --git a/src/lb_fas.c b/src/lb_fas.c index fb581eb52..53bd0392d 100644 --- a/src/lb_fas.c +++ b/src/lb_fas.c @@ -60,11 +60,9 @@ static inline void fas_queue_srv(struct server *s) /* Re-position the server in the FS tree after it has been assigned one * connection or after it has released one. Note that it is possible that * the server has been moved out of the tree due to failed health-checks. - * - * must reflect the server's lock ownership. The lbprm's lock will - * be used. + * The lbprm's lock will be used. */ -static void fas_srv_reposition(struct server *s, int locked) +static void fas_srv_reposition(struct server *s) { HA_RWLOCK_WRLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock); if (s->lb_tree) { diff --git a/src/lb_fwlc.c b/src/lb_fwlc.c index 643489690..ba1ca95ae 100644 --- a/src/lb_fwlc.c +++ b/src/lb_fwlc.c @@ -66,11 +66,9 @@ static inline void fwlc_queue_srv(struct server *s, unsigned int eweight) /* Re-position the server in the FWLC tree after it has been assigned one * connection or after it has released one. Note that it is possible that * the server has been moved out of the tree due to failed health-checks. - * - * must reflect the server's lock ownership. The lbprm's lock will - * be used. + * The lbprm's lock will be used. */ -static void fwlc_srv_reposition(struct server *s, int locked) +static void fwlc_srv_reposition(struct server *s) { unsigned int inflight = _HA_ATOMIC_LOAD(&s->served) + _HA_ATOMIC_LOAD(&s->nbpend); unsigned int new_key = inflight ? (inflight + 1) * SRV_EWGHT_MAX / s->cur_eweight : 0; diff --git a/src/queue.c b/src/queue.c index be11227fe..c45db0db2 100644 --- a/src/queue.c +++ b/src/queue.c @@ -367,7 +367,7 @@ void process_srv_queue(struct server *s, int server_locked) _HA_ATOMIC_ADD(&p->served, done); if (done && p->lbprm.server_take_conn) - p->lbprm.server_take_conn(s, server_locked); + p->lbprm.server_take_conn(s); } /* Adds the stream to the pending connection queue of server ->srv diff --git a/src/stream.c b/src/stream.c index bb5a93e8d..b8da93564 100644 --- a/src/stream.c +++ b/src/stream.c @@ -2619,7 +2619,7 @@ void sess_change_server(struct stream *strm, struct server *newsrv) _HA_ATOMIC_DEC(&oldsrv->proxy->served); __ha_barrier_atomic_store(); if (oldsrv->proxy->lbprm.server_drop_conn) - oldsrv->proxy->lbprm.server_drop_conn(oldsrv, 0); + oldsrv->proxy->lbprm.server_drop_conn(oldsrv); stream_del_srv_conn(strm); } @@ -2628,7 +2628,7 @@ void sess_change_server(struct stream *strm, struct server *newsrv) _HA_ATOMIC_INC(&newsrv->proxy->served); __ha_barrier_atomic_store(); if (newsrv->proxy->lbprm.server_take_conn) - newsrv->proxy->lbprm.server_take_conn(newsrv, 0); + newsrv->proxy->lbprm.server_take_conn(newsrv); stream_add_srv_conn(strm, newsrv); } }