mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
MINOR: server: pass the server and thread to srv_migrate_conns_to_remove()
We'll need to have access to the srv_per_thread element soon from this function, and there's no particular reason for passing it list pointers so let's pass the server and the thread so that it is autonomous. It also makes the calling code simpler.
This commit is contained in:
parent
d1c5df6866
commit
f7d1fc2b08
18
src/server.c
18
src/server.c
@ -7169,25 +7169,27 @@ struct task *srv_cleanup_toremove_conns(struct task *task, void *context, unsign
|
|||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move <toremove_nb> count connections from <list> storage to <toremove_list>
|
/* Move <toremove_nb> count connections from server <srv> list storage
|
||||||
* list storage. -1 means moving all of them.
|
* ->idle_conn_list to the idle_conns list 'toremove_conns' for thread <thr>.
|
||||||
|
* -1 means moving all of them.
|
||||||
*
|
*
|
||||||
* Returns the number of connections moved.
|
* Returns the number of connections moved.
|
||||||
*
|
*
|
||||||
* Must be called with idle_conns_lock held.
|
* Must be called with idle_conns_lock held.
|
||||||
*/
|
*/
|
||||||
static int srv_migrate_conns_to_remove(struct list *list, struct mt_list *toremove_list, int toremove_nb)
|
|
||||||
|
static int srv_migrate_conns_to_remove(struct server *srv, int thr, int toremove_nb)
|
||||||
{
|
{
|
||||||
struct connection *conn;
|
struct connection *conn;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (!LIST_ISEMPTY(list)) {
|
while (!LIST_ISEMPTY(&srv->per_thr[thr].idle_conn_list)) {
|
||||||
if (toremove_nb != -1 && i >= toremove_nb)
|
if (toremove_nb != -1 && i >= toremove_nb)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
conn = LIST_ELEM(list->n, struct connection *, idle_list);
|
conn = LIST_ELEM(srv->per_thr[thr].idle_conn_list.n, struct connection *, idle_list);
|
||||||
conn_delete_from_tree(conn);
|
conn_delete_from_tree(conn);
|
||||||
MT_LIST_APPEND(toremove_list, &conn->toremove_list);
|
MT_LIST_APPEND(&idle_conns[thr].toremove_conns, &conn->toremove_list);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7212,7 +7214,7 @@ static void srv_cleanup_connections(struct server *srv)
|
|||||||
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[i].idle_conns_lock);
|
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[i].idle_conns_lock);
|
||||||
|
|
||||||
/* idle connections */
|
/* idle connections */
|
||||||
if (srv_migrate_conns_to_remove(&srv->per_thr[i].idle_conn_list, &idle_conns[i].toremove_conns, -1) > 0)
|
if (srv_migrate_conns_to_remove(srv, i, -1) > 0)
|
||||||
did_remove = 1;
|
did_remove = 1;
|
||||||
|
|
||||||
/* session attached connections */
|
/* session attached connections */
|
||||||
@ -7466,7 +7468,7 @@ struct task *srv_cleanup_idle_conns(struct task *task, void *context, unsigned i
|
|||||||
curr_idle + 1;
|
curr_idle + 1;
|
||||||
|
|
||||||
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[i].idle_conns_lock);
|
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[i].idle_conns_lock);
|
||||||
j = srv_migrate_conns_to_remove(&srv->per_thr[i].idle_conn_list, &idle_conns[i].toremove_conns, max_conn);
|
j = srv_migrate_conns_to_remove(srv, i, max_conn);
|
||||||
if (j > 0)
|
if (j > 0)
|
||||||
did_remove = 1;
|
did_remove = 1;
|
||||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[i].idle_conns_lock);
|
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[i].idle_conns_lock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user