MINOR: rhttp: add count of active conns per thread
Add a new member <nb_rhttp_conns> in thread_ctx structure. Its purpose is to count the current number of opened reverse HTTP connections regarding from their listeners membership. This patch will be useful to support multi-thread for active reverse HTTP, in order to select the less loaded thread. Note that despite access to <nb_rhttp_conns> are only done by the current thread, atomic operations are used. This is because once multi-thread support will be added, external threads will also retrieve values from others.
This commit is contained in:
parent
55e78ff7e1
commit
a3187fe06c
|
@ -141,6 +141,7 @@ struct thread_ctx {
|
|||
struct list quic_conns; /* list of active quic-conns attached to this thread */
|
||||
struct list quic_conns_clo; /* list of closing quic-conns attached to this thread */
|
||||
struct list queued_checks; /* checks waiting for a connection slot */
|
||||
unsigned int nb_rhttp_conns; /* count of current conns used for active reverse HTTP */
|
||||
|
||||
ALWAYS_ALIGN(2*sizeof(void*));
|
||||
struct list tasklets[TL_CLASSES]; /* tasklets (and/or tasks) to run, by class */
|
||||
|
|
|
@ -592,7 +592,12 @@ void conn_free(struct connection *conn)
|
|||
if (conn_reverse_in_preconnect(conn)) {
|
||||
struct listener *l = conn_active_reverse_listener(conn);
|
||||
rhttp_notify_preconn_err(l);
|
||||
HA_ATOMIC_DEC(&th_ctx->nb_rhttp_conns);
|
||||
}
|
||||
else if (conn->flags & CO_FL_REVERSED) {
|
||||
HA_ATOMIC_DEC(&th_ctx->nb_rhttp_conns);
|
||||
}
|
||||
|
||||
|
||||
conn_force_unsubscribe(conn);
|
||||
pool_free(pool_head_connection, conn);
|
||||
|
|
|
@ -56,6 +56,8 @@ static struct connection *new_reverse_conn(struct listener *l, struct server *sr
|
|||
if (!conn)
|
||||
goto err;
|
||||
|
||||
HA_ATOMIC_INC(&th_ctx->nb_rhttp_conns);
|
||||
|
||||
conn_set_reverse(conn, &l->obj_type);
|
||||
|
||||
if (alloc_bind_address(&bind_addr, srv, srv->proxy, NULL) != SRV_STATUS_OK)
|
||||
|
@ -376,3 +378,14 @@ int rhttp_accepting_conn(const struct receiver *rx)
|
|||
}
|
||||
|
||||
INITCALL1(STG_REGISTER, protocol_register, &proto_rhttp);
|
||||
|
||||
/* perform minimal intializations */
|
||||
static void init_rhttp()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_THREADS; i++)
|
||||
ha_thread_ctx[i].nb_rhttp_conns = 0;
|
||||
}
|
||||
|
||||
INITCALL0(STG_PREPARE, init_rhttp);
|
||||
|
|
Loading…
Reference in New Issue