]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Remove counter and a function 17280/head
authorDonald Sharp <sharpd@nvidia.com>
Mon, 28 Oct 2024 21:52:54 +0000 (17:52 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 31 Oct 2024 18:07:04 +0000 (14:07 -0400)
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>
lib/event.c
lib/frrevent.h

index c573923f519155b7fcca388b8af7f58b9bca2705..cfe8c3adc049893999771e864e1ad252f552afe4 100644 (file)
@@ -669,24 +669,6 @@ static void thread_array_free(struct event_loop *m, struct event **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. */
 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));
                /* mutex only needs to be initialized at struct creation. */
                pthread_mutex_init(&thread->mtx, NULL);
-               m->alloc++;
        }
 
        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)
 {
-       /* Update statistics. */
-       assert(master->alloc > 0);
-       master->alloc--;
-
        /* Free allocated resources. */
        pthread_mutex_destroy(&thread->mtx);
        XFREE(MTYPE_THREAD, thread);
index 94640a76b70f46a233f336a034a56629ecace284..44776b29a7e189ee6e67a73ecca8ea3306d1da4f 100644 (file)
@@ -85,7 +85,6 @@ struct event_loop {
        int io_pipe[2];
        int fd_limit;
        struct fd_handler handler;
-       unsigned long alloc;
        long selectpoll_timeout;
        bool spin;
        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);
 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_unused(struct event_loop *m);
 
 extern void _event_add_read_write(const struct xref_eventsched *xref,
                                  struct event_loop *master,