summaryrefslogtreecommitdiffstats
path: root/ldpd
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2020-07-17 23:09:51 +0200
committerMark Stapp <mjs@voltanet.io>2020-10-23 18:16:52 +0200
commit5047884528ec263215504cb5df12ebd2422cc392 (patch)
tree952121f1a904ef9c86c1f7336a3aae757eeb3434 /ldpd
parent* : update signature of thread_cancel api (diff)
downloadfrr-5047884528ec263215504cb5df12ebd2422cc392.tar.xz
frr-5047884528ec263215504cb5df12ebd2422cc392.zip
*: unify thread/event cancel macros
Replace all lib/thread cancel macros, use thread_cancel() everywhere. Only the THREAD_OFF macro and thread_cancel() api are supported. Also adjust thread_cancel_async() to NULL caller's pointer (if present). Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'ldpd')
-rw-r--r--ldpd/accept.c6
-rw-r--r--ldpd/adjacency.c8
-rw-r--r--ldpd/control.c4
-rw-r--r--ldpd/interface.c10
-rw-r--r--ldpd/lde.c8
-rw-r--r--ldpd/lde_lib.c4
-rw-r--r--ldpd/ldpd.c14
-rw-r--r--ldpd/ldpe.c14
-rw-r--r--ldpd/neighbor.c18
-rw-r--r--ldpd/packet.c6
10 files changed, 45 insertions, 47 deletions
diff --git a/ldpd/accept.c b/ldpd/accept.c
index 323558d7f..9bba0f5dd 100644
--- a/ldpd/accept.c
+++ b/ldpd/accept.c
@@ -74,7 +74,7 @@ accept_del(int fd)
LIST_FOREACH(av, &accept_queue.queue, entry)
if (av->fd == fd) {
log_debug("%s: %d removed from queue", __func__, fd);
- THREAD_READ_OFF(av->ev);
+ thread_cancel(&av->ev);
LIST_REMOVE(av, entry);
free(av);
return;
@@ -95,7 +95,7 @@ accept_unpause(void)
{
if (accept_queue.evt != NULL) {
log_debug(__func__);
- THREAD_TIMER_OFF(accept_queue.evt);
+ thread_cancel(&accept_queue.evt);
accept_arm();
}
}
@@ -115,7 +115,7 @@ accept_unarm(void)
{
struct accept_ev *av;
LIST_FOREACH(av, &accept_queue.queue, entry)
- THREAD_READ_OFF(av->ev);
+ thread_cancel(&av->ev);
}
static int
diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c
index 3923c169d..795a41491 100644
--- a/ldpd/adjacency.c
+++ b/ldpd/adjacency.c
@@ -198,7 +198,7 @@ adj_itimer(struct thread *thread)
void
adj_start_itimer(struct adj *adj)
{
- THREAD_TIMER_OFF(adj->inactivity_timer);
+ thread_cancel(&adj->inactivity_timer);
adj->inactivity_timer = NULL;
thread_add_timer(master, adj_itimer, adj, adj->holdtime,
&adj->inactivity_timer);
@@ -207,7 +207,7 @@ adj_start_itimer(struct adj *adj)
void
adj_stop_itimer(struct adj *adj)
{
- THREAD_TIMER_OFF(adj->inactivity_timer);
+ thread_cancel(&adj->inactivity_timer);
}
/* targeted neighbors */
@@ -359,7 +359,7 @@ tnbr_hello_timer(struct thread *thread)
static void
tnbr_start_hello_timer(struct tnbr *tnbr)
{
- THREAD_TIMER_OFF(tnbr->hello_timer);
+ thread_cancel(&tnbr->hello_timer);
tnbr->hello_timer = NULL;
thread_add_timer(master, tnbr_hello_timer, tnbr, tnbr_get_hello_interval(tnbr),
&tnbr->hello_timer);
@@ -368,7 +368,7 @@ tnbr_start_hello_timer(struct tnbr *tnbr)
static void
tnbr_stop_hello_timer(struct tnbr *tnbr)
{
- THREAD_TIMER_OFF(tnbr->hello_timer);
+ thread_cancel(&tnbr->hello_timer);
}
struct ctl_adj *
diff --git a/ldpd/control.c b/ldpd/control.c
index 6554f0a6f..3b7776595 100644
--- a/ldpd/control.c
+++ b/ldpd/control.c
@@ -183,8 +183,8 @@ control_close(int fd)
msgbuf_clear(&c->iev.ibuf.w);
TAILQ_REMOVE(&ctl_conns, c, entry);
- THREAD_READ_OFF(c->iev.ev_read);
- THREAD_WRITE_OFF(c->iev.ev_write);
+ thread_cancel(&c->iev.ev_read);
+ thread_cancel(&c->iev.ev_write);
close(c->iev.ibuf.fd);
accept_unpause();
free(c);
diff --git a/ldpd/interface.c b/ldpd/interface.c
index 8b3dd71fd..3e9f2fa99 100644
--- a/ldpd/interface.c
+++ b/ldpd/interface.c
@@ -470,7 +470,7 @@ if_hello_timer(struct thread *thread)
static void
if_start_hello_timer(struct iface_af *ia)
{
- THREAD_TIMER_OFF(ia->hello_timer);
+ thread_cancel(&ia->hello_timer);
ia->hello_timer = NULL;
thread_add_timer(master, if_hello_timer, ia, if_get_hello_interval(ia),
&ia->hello_timer);
@@ -479,7 +479,7 @@ if_start_hello_timer(struct iface_af *ia)
static void
if_stop_hello_timer(struct iface_af *ia)
{
- THREAD_TIMER_OFF(ia->hello_timer);
+ thread_cancel(&ia->hello_timer);
}
struct ctl_iface *
@@ -753,8 +753,7 @@ static void start_wait_for_ldp_sync_timer(struct iface *iface)
if (iface->ldp_sync.wait_for_sync_timer)
return;
- THREAD_TIMER_OFF(iface->ldp_sync.wait_for_sync_timer);
- iface->ldp_sync.wait_for_sync_timer = NULL;
+ THREAD_OFF(iface->ldp_sync.wait_for_sync_timer);
thread_add_timer(master, iface_wait_for_ldp_sync_timer, iface,
if_get_wait_for_sync_interval(),
&iface->ldp_sync.wait_for_sync_timer);
@@ -762,8 +761,7 @@ static void start_wait_for_ldp_sync_timer(struct iface *iface)
static void stop_wait_for_ldp_sync_timer(struct iface *iface)
{
- THREAD_TIMER_OFF(iface->ldp_sync.wait_for_sync_timer);
- iface->ldp_sync.wait_for_sync_timer = NULL;
+ THREAD_OFF(iface->ldp_sync.wait_for_sync_timer);
}
static int
diff --git a/ldpd/lde.c b/ldpd/lde.c
index df64f908e..67b695150 100644
--- a/ldpd/lde.c
+++ b/ldpd/lde.c
@@ -415,8 +415,8 @@ lde_dispatch_imsg(struct thread *thread)
imsg_event_add(iev);
else {
/* this pipe is dead, so remove the event handlers and exit */
- THREAD_READ_OFF(iev->ev_read);
- THREAD_WRITE_OFF(iev->ev_write);
+ thread_cancel(&iev->ev_read);
+ thread_cancel(&iev->ev_write);
lde_shutdown();
}
@@ -661,8 +661,8 @@ lde_dispatch_parent(struct thread *thread)
imsg_event_add(iev);
else {
/* this pipe is dead, so remove the event handlers and exit */
- THREAD_READ_OFF(iev->ev_read);
- THREAD_WRITE_OFF(iev->ev_write);
+ thread_cancel(&iev->ev_read);
+ thread_cancel(&iev->ev_write);
lde_shutdown();
}
diff --git a/ldpd/lde_lib.c b/ldpd/lde_lib.c
index bed276c7b..9db931677 100644
--- a/ldpd/lde_lib.c
+++ b/ldpd/lde_lib.c
@@ -1060,7 +1060,7 @@ lde_gc_timer(struct thread *thread)
void
lde_gc_start_timer(void)
{
- THREAD_TIMER_OFF(gc_timer);
+ thread_cancel(&gc_timer);
gc_timer = NULL;
thread_add_timer(master, lde_gc_timer, NULL, LDE_GC_INTERVAL,
&gc_timer);
@@ -1069,5 +1069,5 @@ lde_gc_start_timer(void)
void
lde_gc_stop_timer(void)
{
- THREAD_TIMER_OFF(gc_timer);
+ thread_cancel(&gc_timer);
}
diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c
index 940333f83..d6da45c86 100644
--- a/ldpd/ldpd.c
+++ b/ldpd/ldpd.c
@@ -604,8 +604,8 @@ main_dispatch_ldpe(struct thread *thread)
imsg_event_add(iev);
else {
/* this pipe is dead, so remove the event handlers and exit */
- THREAD_READ_OFF(iev->ev_read);
- THREAD_WRITE_OFF(iev->ev_write);
+ thread_cancel(&iev->ev_read);
+ thread_cancel(&iev->ev_write);
ldpe_pid = 0;
if (lde_pid == 0)
ldpd_shutdown();
@@ -702,8 +702,8 @@ main_dispatch_lde(struct thread *thread)
imsg_event_add(iev);
else {
/* this pipe is dead, so remove the event handlers and exit */
- THREAD_READ_OFF(iev->ev_read);
- THREAD_WRITE_OFF(iev->ev_write);
+ thread_cancel(&iev->ev_read);
+ thread_cancel(&iev->ev_write);
lde_pid = 0;
if (ldpe_pid == 0)
ldpd_shutdown();
@@ -728,8 +728,8 @@ ldp_write_handler(struct thread *thread)
fatal("msgbuf_write");
if (n == 0) {
/* this pipe is dead, so remove the event handlers */
- THREAD_READ_OFF(iev->ev_read);
- THREAD_WRITE_OFF(iev->ev_write);
+ thread_cancel(&iev->ev_read);
+ thread_cancel(&iev->ev_write);
return (0);
}
@@ -816,7 +816,7 @@ evbuf_init(struct evbuf *eb, int fd, int (*handler)(struct thread *),
void
evbuf_clear(struct evbuf *eb)
{
- THREAD_WRITE_OFF(eb->ev);
+ thread_cancel(&eb->ev);
msgbuf_clear(&eb->wbuf);
eb->wbuf.fd = -1;
}
diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c
index d3374a62d..ffc1d17f5 100644
--- a/ldpd/ldpe.c
+++ b/ldpd/ldpe.c
@@ -208,7 +208,7 @@ ldpe_shutdown(void)
#ifdef __OpenBSD__
if (sysdep.no_pfkey == 0) {
- THREAD_READ_OFF(pfkey_ev);
+ thread_cancel(&pfkey_ev);
close(global.pfkeysock);
}
#endif
@@ -580,8 +580,8 @@ ldpe_dispatch_main(struct thread *thread)
imsg_event_add(iev);
else {
/* this pipe is dead, so remove the event handlers and exit */
- THREAD_READ_OFF(iev->ev_read);
- THREAD_WRITE_OFF(iev->ev_write);
+ thread_cancel(&iev->ev_read);
+ thread_cancel(&iev->ev_write);
ldpe_shutdown();
}
@@ -719,8 +719,8 @@ ldpe_dispatch_lde(struct thread *thread)
imsg_event_add(iev);
else {
/* this pipe is dead, so remove the event handlers and exit */
- THREAD_READ_OFF(iev->ev_read);
- THREAD_WRITE_OFF(iev->ev_write);
+ thread_cancel(&iev->ev_read);
+ thread_cancel(&iev->ev_write);
ldpe_shutdown();
}
@@ -778,14 +778,14 @@ ldpe_close_sockets(int af)
af_global = ldp_af_global_get(&global, af);
/* discovery socket */
- THREAD_READ_OFF(af_global->disc_ev);
+ thread_cancel(&af_global->disc_ev);
if (af_global->ldp_disc_socket != -1) {
close(af_global->ldp_disc_socket);
af_global->ldp_disc_socket = -1;
}
/* extended discovery socket */
- THREAD_READ_OFF(af_global->edisc_ev);
+ thread_cancel(&af_global->edisc_ev);
if (af_global->ldp_edisc_socket != -1) {
close(af_global->ldp_edisc_socket);
af_global->ldp_edisc_socket = -1;
diff --git a/ldpd/neighbor.c b/ldpd/neighbor.c
index 423410f29..75deaad2c 100644
--- a/ldpd/neighbor.c
+++ b/ldpd/neighbor.c
@@ -302,7 +302,7 @@ nbr_del(struct nbr *nbr)
nbr->auth.method = AUTH_NONE;
if (nbr_pending_connect(nbr))
- THREAD_WRITE_OFF(nbr->ev_connect);
+ thread_cancel(&nbr->ev_connect);
nbr_stop_ktimer(nbr);
nbr_stop_ktimeout(nbr);
nbr_stop_itimeout(nbr);
@@ -416,7 +416,7 @@ nbr_start_ktimer(struct nbr *nbr)
/* send three keepalives per period */
secs = nbr->keepalive / KEEPALIVE_PER_PERIOD;
- THREAD_TIMER_OFF(nbr->keepalive_timer);
+ thread_cancel(&nbr->keepalive_timer);
nbr->keepalive_timer = NULL;
thread_add_timer(master, nbr_ktimer, nbr, secs, &nbr->keepalive_timer);
}
@@ -424,7 +424,7 @@ nbr_start_ktimer(struct nbr *nbr)
void
nbr_stop_ktimer(struct nbr *nbr)
{
- THREAD_TIMER_OFF(nbr->keepalive_timer);
+ thread_cancel(&nbr->keepalive_timer);
}
/* Keepalive timeout: if the nbr hasn't sent keepalive */
@@ -446,7 +446,7 @@ nbr_ktimeout(struct thread *thread)
static void
nbr_start_ktimeout(struct nbr *nbr)
{
- THREAD_TIMER_OFF(nbr->keepalive_timeout);
+ thread_cancel(&nbr->keepalive_timeout);
nbr->keepalive_timeout = NULL;
thread_add_timer(master, nbr_ktimeout, nbr, nbr->keepalive,
&nbr->keepalive_timeout);
@@ -455,7 +455,7 @@ nbr_start_ktimeout(struct nbr *nbr)
void
nbr_stop_ktimeout(struct nbr *nbr)
{
- THREAD_TIMER_OFF(nbr->keepalive_timeout);
+ thread_cancel(&nbr->keepalive_timeout);
}
/* Session initialization timeout: if nbr got stuck in the initialization FSM */
@@ -478,7 +478,7 @@ nbr_start_itimeout(struct nbr *nbr)
int secs;
secs = INIT_FSM_TIMEOUT;
- THREAD_TIMER_OFF(nbr->init_timeout);
+ thread_cancel(&nbr->init_timeout);
nbr->init_timeout = NULL;
thread_add_timer(master, nbr_itimeout, nbr, secs, &nbr->init_timeout);
}
@@ -486,7 +486,7 @@ nbr_start_itimeout(struct nbr *nbr)
void
nbr_stop_itimeout(struct nbr *nbr)
{
- THREAD_TIMER_OFF(nbr->init_timeout);
+ thread_cancel(&nbr->init_timeout);
}
/* Init delay timer: timer to retry to iniziatize session */
@@ -527,7 +527,7 @@ nbr_start_idtimer(struct nbr *nbr)
break;
}
- THREAD_TIMER_OFF(nbr->initdelay_timer);
+ thread_cancel(&nbr->initdelay_timer);
nbr->initdelay_timer = NULL;
thread_add_timer(master, nbr_idtimer, nbr, secs,
&nbr->initdelay_timer);
@@ -536,7 +536,7 @@ nbr_start_idtimer(struct nbr *nbr)
void
nbr_stop_idtimer(struct nbr *nbr)
{
- THREAD_TIMER_OFF(nbr->initdelay_timer);
+ thread_cancel(&nbr->initdelay_timer);
}
int
diff --git a/ldpd/packet.c b/ldpd/packet.c
index 06ada5957..fdcaa79d2 100644
--- a/ldpd/packet.c
+++ b/ldpd/packet.c
@@ -662,7 +662,7 @@ session_shutdown(struct nbr *nbr, uint32_t status, uint32_t msg_id,
switch (nbr->state) {
case NBR_STA_PRESENT:
if (nbr_pending_connect(nbr))
- THREAD_WRITE_OFF(nbr->ev_connect);
+ thread_cancel(&nbr->ev_connect);
break;
case NBR_STA_INITIAL:
case NBR_STA_OPENREC:
@@ -762,7 +762,7 @@ tcp_close(struct tcp_conn *tcp)
evbuf_clear(&tcp->wbuf);
if (tcp->nbr) {
- THREAD_READ_OFF(tcp->rev);
+ thread_cancel(&tcp->rev);
free(tcp->rbuf);
tcp->nbr->tcp = NULL;
}
@@ -794,7 +794,7 @@ pending_conn_new(int fd, int af, union ldpd_addr *addr)
void
pending_conn_del(struct pending_conn *pconn)
{
- THREAD_TIMER_OFF(pconn->ev_timeout);
+ thread_cancel(&pconn->ev_timeout);
TAILQ_REMOVE(&global.pending_conns, pconn, entry);
free(pconn);
}