mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 17:55:07 -05:00
sched: free timer blocks on exit
Save pointers to allocated timer blocks and free them on exit. This fixes the long-standing annoying "possibly lost" leak reported by valgrind.
This commit is contained in:
14
sched.c
14
sched.c
@@ -104,7 +104,10 @@ static unsigned long n_timer_queue_entries;
|
||||
static SCH_TimeoutID next_tqe_id;
|
||||
|
||||
/* Pointer to head of free list */
|
||||
static TimerQueueEntry *tqe_free_list = NULL;
|
||||
static TimerQueueEntry *tqe_free_list;
|
||||
|
||||
/* Array of all allocated tqe blocks to be freed in finalisation */
|
||||
static ARR_Instance tqe_blocks;
|
||||
|
||||
/* Timestamp when was last timeout dispatched for each class */
|
||||
static struct timespec last_class_dispatch[SCH_NumberOfClasses];
|
||||
@@ -133,6 +136,8 @@ SCH_Initialise(void)
|
||||
|
||||
n_timer_queue_entries = 0;
|
||||
next_tqe_id = 0;
|
||||
tqe_free_list = NULL;
|
||||
tqe_blocks = ARR_CreateInstance(sizeof (TimerQueueEntry *));
|
||||
|
||||
timer_queue.next = &timer_queue;
|
||||
timer_queue.prev = &timer_queue;
|
||||
@@ -154,8 +159,14 @@ SCH_Initialise(void)
|
||||
|
||||
void
|
||||
SCH_Finalise(void) {
|
||||
unsigned int i;
|
||||
|
||||
ARR_DestroyInstance(file_handlers);
|
||||
|
||||
for (i = 0; i < ARR_GetSize(tqe_blocks); i++)
|
||||
Free(*(TimerQueueEntry **)ARR_GetElement(tqe_blocks, i));
|
||||
ARR_DestroyInstance(tqe_blocks);
|
||||
|
||||
LCL_RemoveParameterChangeHandler(handle_slew, NULL);
|
||||
|
||||
initialised = 0;
|
||||
@@ -281,6 +292,7 @@ allocate_tqe(void)
|
||||
}
|
||||
new_block[0].next = NULL;
|
||||
tqe_free_list = &(new_block[TQE_ALLOC_QUANTUM - 1]);
|
||||
ARR_AppendElement(tqe_blocks, &new_block);
|
||||
}
|
||||
|
||||
result = tqe_free_list;
|
||||
|
||||
Reference in New Issue
Block a user