mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-18 17:34:45 +00:00
MINOR: peers: Track number of applets run by thread
Maintain number of peers applets run on all threads. It will be used in next patch for least loaded thread selection.
This commit is contained in:
parent
d9c1d33fa1
commit
d01be2ab13
@ -102,6 +102,7 @@ struct peers {
|
||||
unsigned int resync_timeout; /* resync timeout timer */
|
||||
int count; /* total of peers */
|
||||
int disabled; /* peers proxy disabled if >0 */
|
||||
int applet_count[MAX_THREADS]; /* applet count per thread */
|
||||
};
|
||||
|
||||
/* LRU cache for dictionaies */
|
||||
|
@ -1035,10 +1035,14 @@ static int peer_prepare_ackmsg(char *msg, size_t size, struct peer_prep_params *
|
||||
void __peer_session_deinit(struct peer *peer)
|
||||
{
|
||||
struct peers *peers = peer->peers;
|
||||
int thr;
|
||||
|
||||
if (!peers || !peer->appctx)
|
||||
return;
|
||||
|
||||
thr = my_ffsl(peer->appctx->t->thread_mask) - 1;
|
||||
HA_ATOMIC_DEC(&peers->applet_count[thr]);
|
||||
|
||||
if (peer->appctx->st0 == PEER_SESS_ST_WAITMSG)
|
||||
HA_ATOMIC_DEC(&connected_peers);
|
||||
|
||||
@ -3192,6 +3196,7 @@ void peers_setup_frontend(struct proxy *fe)
|
||||
static struct appctx *peer_session_create(struct peers *peers, struct peer *peer)
|
||||
{
|
||||
struct appctx *appctx;
|
||||
unsigned int thr = tid;
|
||||
|
||||
peer->new_conn++;
|
||||
peer->reconnect = tick_add(now_ms, MS_TO_TICKS(PEER_RECONNECT_TIMEOUT));
|
||||
@ -3210,6 +3215,7 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer
|
||||
if (appctx_init(appctx) == -1)
|
||||
goto out_free_appctx;
|
||||
|
||||
HA_ATOMIC_INC(&peers->applet_count[thr]);
|
||||
return appctx;
|
||||
|
||||
/* Error unrolling */
|
||||
@ -3492,6 +3498,7 @@ int peers_init_sync(struct peers *peers)
|
||||
if (!peers->sync_task)
|
||||
return 0;
|
||||
|
||||
memset(peers->applet_count, 0, sizeof(peers->applet_count));
|
||||
peers->sync_task->process = process_peer_sync;
|
||||
peers->sync_task->context = (void *)peers;
|
||||
peers->sighandler = signal_register_task(0, peers->sync_task, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user