mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 02:46:37 +00:00
lib, pimd: Convert timer_wheel to use thread_execute_name
Allow at timer wheel creation time the ability to specify a name for what we want the 'show thread cpu' to show up as. Modify pim to note this. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
b7fb24ce6f
commit
c2cfa843b4
21
lib/wheel.c
21
lib/wheel.c
@ -29,7 +29,9 @@ DEFINE_MTYPE_STATIC(LIB, TIMER_WHEEL_LIST, "Timer Wheel Slot List")
|
||||
|
||||
static int debug_timer_wheel = 0;
|
||||
|
||||
static int wheel_timer_thread(struct thread *t)
|
||||
static int wheel_timer_thread(struct thread *t);
|
||||
|
||||
static int wheel_timer_thread_helper(struct thread *t)
|
||||
{
|
||||
struct listnode *node, *nextnode;
|
||||
unsigned long long curr_slot;
|
||||
@ -65,15 +67,29 @@ static int wheel_timer_thread(struct thread *t)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wheel_timer_thread(struct thread *t)
|
||||
{
|
||||
struct timer_wheel *wheel;
|
||||
|
||||
wheel = THREAD_ARG(t);
|
||||
|
||||
thread_execute_name(wheel->master, wheel_timer_thread_helper,
|
||||
wheel, 0, wheel->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct timer_wheel *wheel_init(struct thread_master *master, int period,
|
||||
size_t slots, unsigned int (*slot_key)(void *),
|
||||
void (*slot_run)(void *))
|
||||
void (*slot_run)(void *),
|
||||
const char *run_name)
|
||||
{
|
||||
struct timer_wheel *wheel;
|
||||
size_t i;
|
||||
|
||||
wheel = XCALLOC(MTYPE_TIMER_WHEEL, sizeof(struct timer_wheel));
|
||||
|
||||
wheel->name = XSTRDUP(MTYPE_TIMER_WHEEL, run_name);
|
||||
wheel->slot_key = slot_key;
|
||||
wheel->slot_run = slot_run;
|
||||
|
||||
@ -104,6 +120,7 @@ void wheel_delete(struct timer_wheel *wheel)
|
||||
|
||||
THREAD_OFF(wheel->timer);
|
||||
XFREE(MTYPE_TIMER_WHEEL_LIST, wheel->wheel_slot_lists);
|
||||
XFREE(MTYPE_TIMER_WHEEL, wheel->name);
|
||||
XFREE(MTYPE_TIMER_WHEEL, wheel);
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define __WHEEL_H__
|
||||
|
||||
struct timer_wheel {
|
||||
char *name;
|
||||
struct thread_master *master;
|
||||
int slots;
|
||||
long long curr_slot;
|
||||
@ -76,7 +77,8 @@ struct timer_wheel {
|
||||
*/
|
||||
struct timer_wheel *wheel_init(struct thread_master *master, int period,
|
||||
size_t slots, unsigned int (*slot_key)(void *),
|
||||
void (*slot_run)(void *));
|
||||
void (*slot_run)(void *),
|
||||
const char *run_name);
|
||||
|
||||
/*
|
||||
* Delete the specified timer wheel created
|
||||
|
@ -1764,15 +1764,18 @@ void pim_upstream_remove_lhr_star_pimreg(struct pim_instance *pim,
|
||||
|
||||
void pim_upstream_init(struct pim_instance *pim)
|
||||
{
|
||||
char hash_name[64];
|
||||
char name[64];
|
||||
|
||||
snprintf(name, 64, "PIM %s Timer Wheel",
|
||||
pim->vrf->name);
|
||||
pim->upstream_sg_wheel =
|
||||
wheel_init(master, 31000, 100, pim_upstream_hash_key,
|
||||
pim_upstream_sg_running);
|
||||
pim_upstream_sg_running, name);
|
||||
|
||||
snprintf(hash_name, 64, "PIM %s Upstream Hash", pim->vrf->name);
|
||||
snprintf(name, 64, "PIM %s Upstream Hash",
|
||||
pim->vrf->name);
|
||||
pim->upstream_hash = hash_create_size(8192, pim_upstream_hash_key,
|
||||
pim_upstream_equal, hash_name);
|
||||
pim_upstream_equal, name);
|
||||
|
||||
pim->upstream_list = list_new();
|
||||
pim->upstream_list->cmp = pim_upstream_compare;
|
||||
|
Loading…
Reference in New Issue
Block a user