mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-02 20:27:14 +00:00
*: remove THREAD_BACKGROUND
it's just an alias for a millisecond timer used in exactly nine places and serves only to complicate Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
9d693a54fa
commit
a587d00bac
@ -1169,8 +1169,8 @@ update_subgroup_trigger_merge_check (struct update_subgroup *subgrp,
|
||||
return 0;
|
||||
|
||||
subgrp->t_merge_check = NULL;
|
||||
thread_add_background(bm->master, update_subgroup_merge_check_thread_cb, subgrp, 0,
|
||||
&subgrp->t_merge_check);
|
||||
thread_add_timer_msec (bm->master, update_subgroup_merge_check_thread_cb, subgrp,
|
||||
0, &subgrp->t_merge_check);
|
||||
|
||||
SUBGRP_INCR_STAT (subgrp, merge_checks_triggered);
|
||||
|
||||
|
@ -3051,7 +3051,7 @@ rfapiBiStartWithdrawTimer (
|
||||
lifetime_msec = (lifetime * 1000) + jitter;
|
||||
|
||||
bi->extra->vnc.import.timer = NULL;
|
||||
thread_add_background(bm->master, timer_service_func, wcb, lifetime_msec,
|
||||
thread_add_timer_msec(bm->master, timer_service_func, wcb, lifetime_msec,
|
||||
&bi->extra->vnc.import.timer);
|
||||
}
|
||||
|
||||
|
74
lib/thread.c
74
lib/thread.c
@ -96,13 +96,12 @@ vty_out_cpu_thread_history(struct vty* vty,
|
||||
a->total_active, a->cpu.total/1000, a->cpu.total%1000, a->total_calls,
|
||||
a->cpu.total/a->total_calls, a->cpu.max,
|
||||
a->real.total/a->total_calls, a->real.max);
|
||||
vty_out(vty, " %c%c%c%c%c%c %s%s",
|
||||
vty_out(vty, " %c%c%c%c%c %s%s",
|
||||
a->types & (1 << THREAD_READ) ? 'R':' ',
|
||||
a->types & (1 << THREAD_WRITE) ? 'W':' ',
|
||||
a->types & (1 << THREAD_TIMER) ? 'T':' ',
|
||||
a->types & (1 << THREAD_EVENT) ? 'E':' ',
|
||||
a->types & (1 << THREAD_EXECUTE) ? 'X':' ',
|
||||
a->types & (1 << THREAD_BACKGROUND) ? 'B' : ' ',
|
||||
a->funcname, VTY_NEWLINE);
|
||||
}
|
||||
|
||||
@ -195,10 +194,6 @@ DEFUN (show_thread_cpu,
|
||||
case 'X':
|
||||
filter |= (1 << THREAD_EXECUTE);
|
||||
break;
|
||||
case 'b':
|
||||
case 'B':
|
||||
filter |= (1 << THREAD_BACKGROUND);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -287,10 +282,6 @@ DEFUN (clear_thread_cpu,
|
||||
case 'X':
|
||||
filter |= (1 << THREAD_EXECUTE);
|
||||
break;
|
||||
case 'b':
|
||||
case 'B':
|
||||
filter |= (1 << THREAD_BACKGROUND);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -379,9 +370,8 @@ thread_master_create (void)
|
||||
|
||||
/* Initialize the timer queues */
|
||||
rv->timer = pqueue_create();
|
||||
rv->background = pqueue_create();
|
||||
rv->timer->cmp = rv->background->cmp = thread_timer_cmp;
|
||||
rv->timer->update = rv->background->update = thread_timer_update;
|
||||
rv->timer->cmp = thread_timer_cmp;
|
||||
rv->timer->update = thread_timer_update;
|
||||
rv->spin = true;
|
||||
rv->handle_signals = true;
|
||||
rv->owner = pthread_self();
|
||||
@ -540,7 +530,6 @@ thread_master_free (struct thread_master *m)
|
||||
thread_list_free (m, &m->event);
|
||||
thread_list_free (m, &m->ready);
|
||||
thread_list_free (m, &m->unuse);
|
||||
thread_queue_free (m, m->background);
|
||||
pthread_mutex_destroy (&m->mtx);
|
||||
close (m->io_pipe[0]);
|
||||
close (m->io_pipe[1]);
|
||||
@ -757,7 +746,7 @@ funcname_thread_add_timer_timeval (struct thread_master *m,
|
||||
|
||||
assert (m != NULL);
|
||||
|
||||
assert (type == THREAD_TIMER || type == THREAD_BACKGROUND);
|
||||
assert (type == THREAD_TIMER);
|
||||
assert (time_relative);
|
||||
|
||||
pthread_mutex_lock (&m->mtx);
|
||||
@ -768,7 +757,7 @@ funcname_thread_add_timer_timeval (struct thread_master *m,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
queue = ((type == THREAD_TIMER) ? m->timer : m->background);
|
||||
queue = m->timer;
|
||||
thread = thread_get (m, type, func, arg, debugargpass);
|
||||
|
||||
pthread_mutex_lock (&thread->mtx);
|
||||
@ -836,31 +825,6 @@ funcname_thread_add_timer_tv (struct thread_master *m,
|
||||
t_ptr, debugargpass);
|
||||
}
|
||||
|
||||
/* Add a background thread, with an optional millisec delay */
|
||||
struct thread *
|
||||
funcname_thread_add_background (struct thread_master *m,
|
||||
int (*func) (struct thread *), void *arg, long delay,
|
||||
struct thread **t_ptr, debugargdef)
|
||||
{
|
||||
struct timeval trel;
|
||||
|
||||
assert (m != NULL);
|
||||
|
||||
if (delay)
|
||||
{
|
||||
trel.tv_sec = delay / 1000;
|
||||
trel.tv_usec = 1000*(delay % 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
trel.tv_sec = 0;
|
||||
trel.tv_usec = 0;
|
||||
}
|
||||
|
||||
return funcname_thread_add_timer_timeval (m, func, THREAD_BACKGROUND, arg, &trel,
|
||||
t_ptr, debugargpass);
|
||||
}
|
||||
|
||||
/* Add simple event thread. */
|
||||
struct thread *
|
||||
funcname_thread_add_event (struct thread_master *m,
|
||||
@ -957,9 +921,6 @@ thread_cancel (struct thread *thread)
|
||||
case THREAD_READY:
|
||||
list = &thread->master->ready;
|
||||
break;
|
||||
case THREAD_BACKGROUND:
|
||||
queue = thread->master->background;
|
||||
break;
|
||||
default:
|
||||
goto done;
|
||||
break;
|
||||
@ -1181,9 +1142,7 @@ thread_fetch (struct thread_master *m, struct thread *fetch)
|
||||
struct thread *thread;
|
||||
struct timeval now;
|
||||
struct timeval timer_val = { .tv_sec = 0, .tv_usec = 0 };
|
||||
struct timeval timer_val_bg;
|
||||
struct timeval *timer_wait = &timer_val;
|
||||
struct timeval *timer_wait_bg;
|
||||
|
||||
do
|
||||
{
|
||||
@ -1218,11 +1177,6 @@ thread_fetch (struct thread_master *m, struct thread *fetch)
|
||||
if (m->ready.count == 0)
|
||||
{
|
||||
timer_wait = thread_timer_wait (m->timer, &timer_val);
|
||||
timer_wait_bg = thread_timer_wait (m->background, &timer_val_bg);
|
||||
|
||||
if (timer_wait_bg &&
|
||||
(!timer_wait || (timercmp (timer_wait, timer_wait_bg, >))))
|
||||
timer_wait = timer_wait_bg;
|
||||
}
|
||||
|
||||
if (timer_wait && timer_wait->tv_sec < 0)
|
||||
@ -1263,24 +1217,6 @@ thread_fetch (struct thread_master *m, struct thread *fetch)
|
||||
if (num > 0)
|
||||
thread_process_io (m, m->handler.copy, num, count);
|
||||
|
||||
#if 0
|
||||
/* If any threads were made ready above (I/O or foreground timer),
|
||||
perhaps we should avoid adding background timers to the ready
|
||||
list at this time. If this is code is uncommented, then background
|
||||
timer threads will not run unless there is nothing else to do. */
|
||||
if ((thread = thread_trim_head (&m->ready)) != NULL)
|
||||
{
|
||||
fetch = thread_run (m, thread, fetch);
|
||||
if (fetch->ref)
|
||||
*fetch->ref = NULL;
|
||||
pthread_mutex_unlock (&m->mtx);
|
||||
return fetch;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Background timer/events, lowest priority */
|
||||
thread_process_timers (m->background, &now);
|
||||
|
||||
if ((thread = thread_trim_head (&m->ready)) != NULL)
|
||||
{
|
||||
fetch = thread_run (m, thread, fetch);
|
||||
|
12
lib/thread.h
12
lib/thread.h
@ -68,7 +68,6 @@ struct thread_master
|
||||
struct thread_list event;
|
||||
struct thread_list ready;
|
||||
struct thread_list unuse;
|
||||
struct pqueue *background;
|
||||
int io_pipe[2];
|
||||
int fd_limit;
|
||||
struct fd_handler handler;
|
||||
@ -131,9 +130,8 @@ struct cpu_thread_history
|
||||
#define THREAD_TIMER 2
|
||||
#define THREAD_EVENT 3
|
||||
#define THREAD_READY 4
|
||||
#define THREAD_BACKGROUND 5
|
||||
#define THREAD_UNUSED 6
|
||||
#define THREAD_EXECUTE 7
|
||||
#define THREAD_UNUSED 5
|
||||
#define THREAD_EXECUTE 6
|
||||
|
||||
/* Thread yield time. */
|
||||
#define THREAD_YIELD_TIME_SLOT 10 * 1000L /* 10ms */
|
||||
@ -166,9 +164,6 @@ struct cpu_thread_history
|
||||
#define thread_add_event(m,f,a,v,t) funcname_thread_add_event(m,f,a,v,t,#f,__FILE__,__LINE__)
|
||||
#define thread_execute(m,f,a,v) funcname_thread_execute(m,f,a,v,#f,__FILE__,__LINE__)
|
||||
|
||||
/* The 4th arg to thread_add_background is the # of milliseconds to delay. */
|
||||
#define thread_add_background(m,f,a,v,t) funcname_thread_add_background(m,f,a,v,t,#f,__FILE__,__LINE__)
|
||||
|
||||
/* Prototypes. */
|
||||
extern struct thread_master *thread_master_create (void);
|
||||
extern void thread_master_free (struct thread_master *);
|
||||
@ -189,9 +184,6 @@ extern struct thread * funcname_thread_add_timer_tv (struct thread_master *,
|
||||
extern struct thread * funcname_thread_add_event (struct thread_master *,
|
||||
int (*)(struct thread *), void *, int, struct thread **, debugargdef);
|
||||
|
||||
extern struct thread * funcname_thread_add_background (struct thread_master *,
|
||||
int (*)(struct thread *), void *, long, struct thread **, debugargdef);
|
||||
|
||||
extern void funcname_thread_execute (struct thread_master *,
|
||||
int (*)(struct thread *), void *, int, debugargdef);
|
||||
#undef debugargdef
|
||||
|
@ -126,8 +126,8 @@ work_queue_schedule (struct work_queue *wq, unsigned int delay)
|
||||
&& (listcount (wq->items) > 0) )
|
||||
{
|
||||
wq->thread = NULL;
|
||||
thread_add_background(wq->master, work_queue_run, wq, delay,
|
||||
&wq->thread);
|
||||
thread_add_timer_msec (wq->master, work_queue_run, wq, delay,
|
||||
&wq->thread);
|
||||
/* set thread yield time, if needed */
|
||||
if (wq->thread && wq->spec.yield != THREAD_YIELD_TIME_SLOT)
|
||||
thread_set_yield_time (wq->thread, wq->spec.yield);
|
||||
|
@ -90,7 +90,7 @@ clear_something (struct thread *thread)
|
||||
ws->i++;
|
||||
if (thread_should_yield(thread))
|
||||
{
|
||||
thread_add_background(master, clear_something, ws, 0, NULL);
|
||||
thread_add_timer_msec (master, clear_something, ws, 0, NULL);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -134,7 +134,7 @@ DEFUN (clear_foo,
|
||||
ws->vty = vty;
|
||||
ws->i = ITERS_FIRST;
|
||||
|
||||
thread_add_background(master, clear_something, ws, 0, NULL);
|
||||
thread_add_timer_msec (master, clear_something, ws, 0, NULL);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
@ -564,8 +564,8 @@ zfpm_conn_up_thread_cb (struct thread *thread)
|
||||
zfpm_g->stats.t_conn_up_yields++;
|
||||
zfpm_rnodes_iter_pause (iter);
|
||||
zfpm_g->t_conn_up = NULL;
|
||||
thread_add_background(zfpm_g->master, zfpm_conn_up_thread_cb, 0, 0,
|
||||
&zfpm_g->t_conn_up);
|
||||
thread_add_timer_msec (zfpm_g->master, zfpm_conn_up_thread_cb, NULL, 0,
|
||||
&zfpm_g->t_conn_up);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -598,7 +598,7 @@ zfpm_connection_up (const char *detail)
|
||||
|
||||
zfpm_debug ("Starting conn_up thread");
|
||||
zfpm_g->t_conn_up = NULL;
|
||||
thread_add_background(zfpm_g->master, zfpm_conn_up_thread_cb, 0, 0,
|
||||
thread_add_timer_msec(zfpm_g->master, zfpm_conn_up_thread_cb, NULL, 0,
|
||||
&zfpm_g->t_conn_up);
|
||||
zfpm_g->stats.t_conn_up_starts++;
|
||||
}
|
||||
@ -688,7 +688,7 @@ zfpm_conn_down_thread_cb (struct thread *thread)
|
||||
zfpm_g->stats.t_conn_down_yields++;
|
||||
zfpm_rnodes_iter_pause (iter);
|
||||
zfpm_g->t_conn_down = NULL;
|
||||
thread_add_background(zfpm_g->master, zfpm_conn_down_thread_cb, 0, 0,
|
||||
thread_add_timer_msec(zfpm_g->master, zfpm_conn_down_thread_cb, NULL, 0,
|
||||
&zfpm_g->t_conn_down);
|
||||
return 0;
|
||||
}
|
||||
@ -736,7 +736,7 @@ zfpm_connection_down (const char *detail)
|
||||
zfpm_debug ("Starting conn_down thread");
|
||||
zfpm_rnodes_iter_init (&zfpm_g->t_conn_down_state.iter);
|
||||
zfpm_g->t_conn_down = NULL;
|
||||
thread_add_background(zfpm_g->master, zfpm_conn_down_thread_cb, 0, 0,
|
||||
thread_add_timer_msec(zfpm_g->master, zfpm_conn_down_thread_cb, NULL, 0,
|
||||
&zfpm_g->t_conn_down);
|
||||
zfpm_g->stats.t_conn_down_starts++;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user