struct eb_root avail_conns; /* Connections in use, but with still new streams available */
};
+/* Each server will have one occurrence of this structure per thread group */
+struct srv_per_tgroup {
+ unsigned int next_takeover; /* thread ID to try to steal connections from next time */
+};
+
/* Configure the protocol selection for websocket */
enum __attribute__((__packed__)) srv_ws_mode {
SRV_WS_AUTO = 0,
const struct mux_proto_list *mux_proto; /* the mux to use for all outgoing connections (specified by the "proto" keyword) */
unsigned maxconn, minconn; /* max # of active sessions (0 = unlimited), min# for dynamic limit. */
struct srv_per_thread *per_thr; /* array of per-thread stuff such as connections lists */
+ struct srv_per_tgroup *per_tgrp; /* array of per-tgroup stuff such as idle conns */
unsigned int *curr_idle_thr; /* Current number of orphan idling connections per thread */
unsigned int pool_purge_delay; /* Delay before starting to purge the idle conns pool */
unsigned int curr_used_conns; /* Current number of used connections */
unsigned int max_used_conns; /* Max number of used connections (the counter is reset at each connection purges */
unsigned int est_need_conns; /* Estimate on the number of needed connections (max of curr and previous max_used) */
- unsigned int next_takeover; /* thread ID to try to steal connections from next time */
struct queue queue; /* pending connections */
/* Lookup all other threads for an idle connection, starting from last
* unvisited thread, but always staying in the same group.
*/
- stop = srv->next_takeover;
+ stop = srv->per_tgrp[tgid - 1].next_takeover;
if (stop >= tg->count)
stop %= tg->count;
conn = NULL;
done:
if (conn) {
- _HA_ATOMIC_STORE(&srv->next_takeover, (i + 1 == tg->base + tg->count) ? tg->base : i + 1);
+ _HA_ATOMIC_STORE(&srv->per_tgrp[tgid - 1].next_takeover, (i + 1 == tg->base + tg->count) ? tg->base : i + 1);
srv_use_conn(srv, conn);
free(srv->hostname_dn);
free((char*)srv->conf.file);
free(srv->per_thr);
+ free(srv->per_tgrp);
free(srv->curr_idle_thr);
free(srv->resolvers_id);
free(srv->addr_node.key);
int i;
srv->per_thr = calloc(global.nbthread, sizeof(*srv->per_thr));
- if (!srv->per_thr)
+ srv->per_tgrp = calloc(global.nbtgroups, sizeof(*srv->per_tgrp));
+ if (!srv->per_thr || !srv->per_tgrp)
return -1;
for (i = 0; i < global.nbthread; i++) {