summaryrefslogtreecommitdiffstats
path: root/lib/event.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2022-12-11 17:20:40 +0100
committerDonald Sharp <sharpd@nvidia.com>2023-03-24 13:32:17 +0100
commit2453d15dbf7fff2d897c2182886486732be8ac35 (patch)
tree7a054859acf25689f67d5df7aa9d50b20bca4b62 /lib/event.c
parent*: Convert a bunch of thread_XX to event_XX (diff)
downloadfrr-2453d15dbf7fff2d897c2182886486732be8ac35.tar.xz
frr-2453d15dbf7fff2d897c2182886486732be8ac35.zip
*: Convert struct thread_master to struct event_master and it's ilk
Convert the `struct thread_master` to `struct event_master` across the code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'lib/event.c')
-rw-r--r--lib/event.c89
1 files changed, 43 insertions, 46 deletions
diff --git a/lib/event.c b/lib/event.c
index f5f9c9540..97bc11509 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -73,7 +73,7 @@ pthread_key_t thread_current;
static pthread_mutex_t masters_mtx = PTHREAD_MUTEX_INITIALIZER;
static struct list *masters;
-static void thread_free(struct thread_master *master, struct event *thread);
+static void thread_free(struct event_master *master, struct event *thread);
#ifndef EXCLUDE_CPU_TIME
#define EXCLUDE_CPU_TIME 0
@@ -185,7 +185,7 @@ static void cpu_record_print(struct vty *vty, uint8_t filter)
{
struct cpu_thread_history tmp;
void *args[3] = {&tmp, vty, &filter};
- struct thread_master *m;
+ struct event_master *m;
struct listnode *ln;
if (!cputime_enabled)
@@ -263,7 +263,7 @@ static void cpu_record_hash_clear(struct hash_bucket *bucket, void *args[])
static void cpu_record_clear(uint8_t filter)
{
uint8_t *tmp = &filter;
- struct thread_master *m;
+ struct event_master *m;
struct listnode *ln;
frr_with_mutex (&masters_mtx) {
@@ -395,7 +395,7 @@ ALIAS (service_walltime_warning,
"Set up miscellaneous service\n"
"Warn for tasks exceeding total wallclock threshold\n")
-static void show_thread_poll_helper(struct vty *vty, struct thread_master *m)
+static void show_thread_poll_helper(struct vty *vty, struct event_master *m)
{
const char *name = m->name ? m->name : "main";
char underline[strlen(name) + 1];
@@ -444,7 +444,7 @@ DEFUN_NOSH (show_thread_poll,
"Show poll FD's and information\n")
{
struct listnode *node;
- struct thread_master *m;
+ struct event_master *m;
frr_with_mutex (&masters_mtx) {
for (ALL_LIST_ELEMENTS_RO(masters, node, m)) {
@@ -481,7 +481,7 @@ DEFUN (clear_thread_cpu,
return CMD_SUCCESS;
}
-static void show_thread_timers_helper(struct vty *vty, struct thread_master *m)
+static void show_thread_timers_helper(struct vty *vty, struct event_master *m)
{
const char *name = m->name ? m->name : "main";
char underline[strlen(name) + 1];
@@ -506,7 +506,7 @@ DEFPY_NOSH (show_thread_timers,
"Show all timers and how long they have in the system\n")
{
struct listnode *node;
- struct thread_master *m;
+ struct event_master *m;
frr_with_mutex (&masters_mtx) {
for (ALL_LIST_ELEMENTS_RO(masters, node, m))
@@ -544,14 +544,14 @@ static void initializer(void)
pthread_key_create(&thread_current, NULL);
}
-struct thread_master *thread_master_create(const char *name)
+struct event_master *thread_master_create(const char *name)
{
- struct thread_master *rv;
+ struct event_master *rv;
struct rlimit limit;
pthread_once(&init_once, &initializer);
- rv = XCALLOC(MTYPE_EVENT_MASTER, sizeof(struct thread_master));
+ rv = XCALLOC(MTYPE_EVENT_MASTER, sizeof(struct event_master));
/* Initialize master mutex */
pthread_mutex_init(&rv->mtx, NULL);
@@ -623,7 +623,7 @@ struct thread_master *thread_master_create(const char *name)
return rv;
}
-void thread_master_set_name(struct thread_master *master, const char *name)
+void thread_master_set_name(struct event_master *master, const char *name)
{
frr_with_mutex (&master->mtx) {
XFREE(MTYPE_EVENT_MASTER, master->name);
@@ -634,7 +634,7 @@ void thread_master_set_name(struct thread_master *master, const char *name)
#define EVENT_UNUSED_DEPTH 10
/* Move thread to unuse list. */
-static void thread_add_unuse(struct thread_master *m, struct event *thread)
+static void thread_add_unuse(struct event_master *m, struct event *thread)
{
pthread_mutex_t mtxc = thread->mtx;
@@ -656,8 +656,8 @@ static void thread_add_unuse(struct thread_master *m, struct event *thread)
}
/* Free all unused thread. */
-static void thread_list_free(struct thread_master *m,
- struct thread_list_head *list)
+static void thread_list_free(struct event_master *m,
+ struct thread_list_head *list)
{
struct event *t;
@@ -665,7 +665,7 @@ static void thread_list_free(struct thread_master *m,
thread_free(m, t);
}
-static void thread_array_free(struct thread_master *m,
+static void thread_array_free(struct event_master *m,
struct event **thread_array)
{
struct event *t;
@@ -689,7 +689,7 @@ static void thread_array_free(struct thread_master *m,
* If we are shutting down, Free up unused threads
* So we can see if we forget to shut anything off
*/
-void thread_master_free_unused(struct thread_master *m)
+void thread_master_free_unused(struct event_master *m)
{
frr_with_mutex (&m->mtx) {
struct event *t;
@@ -699,7 +699,7 @@ void thread_master_free_unused(struct thread_master *m)
}
/* Stop thread scheduler. */
-void thread_master_free(struct thread_master *m)
+void thread_master_free(struct event_master *m)
{
struct event *t;
@@ -791,7 +791,7 @@ char *event_timer_to_hhmmss(char *buf, int buf_size, struct event *t_timer)
}
/* Get new thread. */
-static struct event *thread_get(struct thread_master *m, uint8_t type,
+static struct event *thread_get(struct event_master *m, uint8_t type,
void (*func)(struct event *), void *arg,
const struct xref_threadsched *xref)
{
@@ -838,7 +838,7 @@ static struct event *thread_get(struct thread_master *m, uint8_t type,
return thread;
}
-static void thread_free(struct thread_master *master, struct event *thread)
+static void thread_free(struct event_master *master, struct event *thread)
{
/* Update statistics. */
assert(master->alloc > 0);
@@ -849,7 +849,7 @@ static void thread_free(struct thread_master *master, struct event *thread)
XFREE(MTYPE_THREAD, thread);
}
-static int fd_poll(struct thread_master *m, const struct timeval *timer_wait,
+static int fd_poll(struct event_master *m, const struct timeval *timer_wait,
bool *eintr_p)
{
sigset_t origsigs;
@@ -948,9 +948,8 @@ done:
/* Add new read thread. */
void _event_add_read_write(const struct xref_threadsched *xref,
- struct thread_master *m,
- void (*func)(struct event *), void *arg, int fd,
- struct event **t_ptr)
+ struct event_master *m, void (*func)(struct event *),
+ void *arg, int fd, struct event **t_ptr)
{
int dir = xref->event_type;
struct event *thread = NULL;
@@ -1028,7 +1027,7 @@ void _event_add_read_write(const struct xref_threadsched *xref,
}
static void _event_add_timer_timeval(const struct xref_threadsched *xref,
- struct thread_master *m,
+ struct event_master *m,
void (*func)(struct event *), void *arg,
struct timeval *time_relative,
struct event **t_ptr)
@@ -1082,7 +1081,7 @@ static void _event_add_timer_timeval(const struct xref_threadsched *xref,
/* Add timer event thread. */
void _event_add_timer(const struct xref_threadsched *xref,
- struct thread_master *m, void (*func)(struct event *),
+ struct event_master *m, void (*func)(struct event *),
void *arg, long timer, struct event **t_ptr)
{
struct timeval trel;
@@ -1097,9 +1096,8 @@ void _event_add_timer(const struct xref_threadsched *xref,
/* Add timer event thread with "millisecond" resolution */
void _event_add_timer_msec(const struct xref_threadsched *xref,
- struct thread_master *m,
- void (*func)(struct event *), void *arg, long timer,
- struct event **t_ptr)
+ struct event_master *m, void (*func)(struct event *),
+ void *arg, long timer, struct event **t_ptr)
{
struct timeval trel;
@@ -1113,7 +1111,7 @@ void _event_add_timer_msec(const struct xref_threadsched *xref,
/* Add timer event thread with "timeval" resolution */
void _event_add_timer_tv(const struct xref_threadsched *xref,
- struct thread_master *m, void (*func)(struct event *),
+ struct event_master *m, void (*func)(struct event *),
void *arg, struct timeval *tv, struct event **t_ptr)
{
_event_add_timer_timeval(xref, m, func, arg, tv, t_ptr);
@@ -1121,7 +1119,7 @@ void _event_add_timer_tv(const struct xref_threadsched *xref,
/* Add simple event thread. */
void _event_add_event(const struct xref_threadsched *xref,
- struct thread_master *m, void (*func)(struct event *),
+ struct event_master *m, void (*func)(struct event *),
void *arg, int val, struct event **t_ptr)
{
struct event *thread = NULL;
@@ -1168,7 +1166,7 @@ void _event_add_event(const struct xref_threadsched *xref,
* - POLLIN
* - POLLOUT
*/
-static void event_cancel_rw(struct thread_master *master, int fd, short state,
+static void event_cancel_rw(struct event_master *master, int fd, short state,
int idx_hint)
{
bool found = false;
@@ -1234,7 +1232,7 @@ static void event_cancel_rw(struct thread_master *master, int fd, short state,
* Process task cancellation given a task argument: iterate through the
* various lists of tasks, looking for any that match the argument.
*/
-static void cancel_arg_helper(struct thread_master *master,
+static void cancel_arg_helper(struct event_master *master,
const struct cancel_req *cr)
{
struct event *t;
@@ -1327,7 +1325,7 @@ static void cancel_arg_helper(struct thread_master *master,
* @param master the thread master to process
* @REQUIRE master->mtx
*/
-static void do_event_cancel(struct thread_master *master)
+static void do_event_cancel(struct event_master *master)
{
struct thread_list_head *list = NULL;
struct event **thread_array = NULL;
@@ -1409,7 +1407,7 @@ static void do_event_cancel(struct thread_master *master)
/*
* Helper function used for multiple flavors of arg-based cancellation.
*/
-static void cancel_event_helper(struct thread_master *m, void *arg, int flags)
+static void cancel_event_helper(struct event_master *m, void *arg, int flags)
{
struct cancel_req *cr;
@@ -1438,7 +1436,7 @@ static void cancel_event_helper(struct thread_master *m, void *arg, int flags)
* @param m the thread_master to cancel from
* @param arg the argument passed when creating the event
*/
-void event_cancel_event(struct thread_master *master, void *arg)
+void event_cancel_event(struct event_master *master, void *arg)
{
cancel_event_helper(master, arg, 0);
}
@@ -1451,7 +1449,7 @@ void event_cancel_event(struct thread_master *master, void *arg)
* @param m the thread_master to cancel from
* @param arg the argument passed when creating the event
*/
-void event_cancel_event_ready(struct thread_master *m, void *arg)
+void event_cancel_event_ready(struct event_master *m, void *arg)
{
/* Only cancel ready/event tasks */
@@ -1467,7 +1465,7 @@ void event_cancel_event_ready(struct thread_master *m, void *arg)
*/
void event_cancel(struct event **thread)
{
- struct thread_master *master;
+ struct event_master *master;
if (thread == NULL || *thread == NULL)
return;
@@ -1516,7 +1514,7 @@ void event_cancel(struct event **thread)
* @param thread pointer to thread to cancel
* @param eventobj the event
*/
-void event_cancel_async(struct thread_master *master, struct event **thread,
+void event_cancel_async(struct event_master *master, struct event **thread,
void *eventobj)
{
assert(!(thread && eventobj) && (thread || eventobj));
@@ -1569,7 +1567,7 @@ static struct timeval *thread_timer_wait(struct thread_timer_list_head *timers,
return timer_val;
}
-static struct event *thread_run(struct thread_master *m, struct event *thread,
+static struct event *thread_run(struct event_master *m, struct event *thread,
struct event *fetch)
{
*fetch = *thread;
@@ -1577,7 +1575,7 @@ static struct event *thread_run(struct thread_master *m, struct event *thread,
return fetch;
}
-static int thread_process_io_helper(struct thread_master *m,
+static int thread_process_io_helper(struct event_master *m,
struct event *thread, short state,
short actual_state, int pos)
{
@@ -1625,7 +1623,7 @@ static int thread_process_io_helper(struct thread_master *m,
* @param m the thread master
* @param num the number of active file descriptors (return value of poll())
*/
-static void thread_process_io(struct thread_master *m, unsigned int num)
+static void thread_process_io(struct event_master *m, unsigned int num)
{
unsigned int ready = 0;
struct pollfd *pfds = m->handler.copy;
@@ -1683,7 +1681,7 @@ static void thread_process_io(struct thread_master *m, unsigned int num)
}
/* Add all timers that have popped to the ready list. */
-static unsigned int thread_process_timers(struct thread_master *m,
+static unsigned int thread_process_timers(struct event_master *m,
struct timeval *timenow)
{
struct timeval prev = *timenow;
@@ -1740,7 +1738,7 @@ static unsigned int thread_process(struct thread_list_head *list)
/* Fetch next ready thread. */
-struct event *event_fetch(struct thread_master *m, struct event *fetch)
+struct event *event_fetch(struct event_master *m, struct event *fetch)
{
struct event *thread = NULL;
struct timeval now;
@@ -2057,9 +2055,8 @@ void event_call(struct event *thread)
}
/* Execute thread */
-void _event_execute(const struct xref_threadsched *xref,
- struct thread_master *m, void (*func)(struct event *),
- void *arg, int val)
+void _event_execute(const struct xref_threadsched *xref, struct event_master *m,
+ void (*func)(struct event *), void *arg, int val)
{
struct event *thread;