mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 11:18:43 +00:00
lib: Remove counter and a function
The `alloc` counter was tracking the current active number of events in the system and if it went to 0 when freeing a new one it would assert. This assert is a duplicate of what would happen with the XFREE in the same situation. As such it is not necessary. Also remove the `event_master_free_unused` function from the system. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
2b1e5ced04
commit
cd80fa0af4
23
lib/event.c
23
lib/event.c
@ -669,24 +669,6 @@ static void thread_array_free(struct event_loop *m, struct event **thread_array)
|
|||||||
XFREE(MTYPE_EVENT_POLL, thread_array);
|
XFREE(MTYPE_EVENT_POLL, thread_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* event_master_free_unused
|
|
||||||
*
|
|
||||||
* As threads are finished with they are put on the
|
|
||||||
* unuse list for later reuse.
|
|
||||||
* If we are shutting down, Free up unused threads
|
|
||||||
* So we can see if we forget to shut anything off
|
|
||||||
*/
|
|
||||||
void event_master_free_unused(struct event_loop *m)
|
|
||||||
{
|
|
||||||
frr_with_mutex (&m->mtx) {
|
|
||||||
struct event *t;
|
|
||||||
|
|
||||||
while ((t = event_list_pop(&m->unuse)))
|
|
||||||
thread_free(m, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Stop thread scheduler. */
|
/* Stop thread scheduler. */
|
||||||
void event_master_free(struct event_loop *m)
|
void event_master_free(struct event_loop *m)
|
||||||
{
|
{
|
||||||
@ -793,7 +775,6 @@ static struct event *thread_get(struct event_loop *m, uint8_t type,
|
|||||||
thread = XCALLOC(MTYPE_THREAD, sizeof(struct event));
|
thread = XCALLOC(MTYPE_THREAD, sizeof(struct event));
|
||||||
/* mutex only needs to be initialized at struct creation. */
|
/* mutex only needs to be initialized at struct creation. */
|
||||||
pthread_mutex_init(&thread->mtx, NULL);
|
pthread_mutex_init(&thread->mtx, NULL);
|
||||||
m->alloc++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->type = type;
|
thread->type = type;
|
||||||
@ -832,10 +813,6 @@ static struct event *thread_get(struct event_loop *m, uint8_t type,
|
|||||||
|
|
||||||
static void thread_free(struct event_loop *master, struct event *thread)
|
static void thread_free(struct event_loop *master, struct event *thread)
|
||||||
{
|
{
|
||||||
/* Update statistics. */
|
|
||||||
assert(master->alloc > 0);
|
|
||||||
master->alloc--;
|
|
||||||
|
|
||||||
/* Free allocated resources. */
|
/* Free allocated resources. */
|
||||||
pthread_mutex_destroy(&thread->mtx);
|
pthread_mutex_destroy(&thread->mtx);
|
||||||
XFREE(MTYPE_THREAD, thread);
|
XFREE(MTYPE_THREAD, thread);
|
||||||
|
@ -85,7 +85,6 @@ struct event_loop {
|
|||||||
int io_pipe[2];
|
int io_pipe[2];
|
||||||
int fd_limit;
|
int fd_limit;
|
||||||
struct fd_handler handler;
|
struct fd_handler handler;
|
||||||
unsigned long alloc;
|
|
||||||
long selectpoll_timeout;
|
long selectpoll_timeout;
|
||||||
bool spin;
|
bool spin;
|
||||||
bool handle_signals;
|
bool handle_signals;
|
||||||
@ -227,7 +226,6 @@ static inline unsigned long timeval_elapsed(struct timeval a, struct timeval b)
|
|||||||
extern struct event_loop *event_master_create(const char *name);
|
extern struct event_loop *event_master_create(const char *name);
|
||||||
void event_master_set_name(struct event_loop *master, const char *name);
|
void event_master_set_name(struct event_loop *master, const char *name);
|
||||||
extern void event_master_free(struct event_loop *m);
|
extern void event_master_free(struct event_loop *m);
|
||||||
extern void event_master_free_unused(struct event_loop *m);
|
|
||||||
|
|
||||||
extern void _event_add_read_write(const struct xref_eventsched *xref,
|
extern void _event_add_read_write(const struct xref_eventsched *xref,
|
||||||
struct event_loop *master,
|
struct event_loop *master,
|
||||||
|
Loading…
Reference in New Issue
Block a user