flush_all_routes();
babel_interface_close_all();
- /* cancel threads */
- if (babel_routing_process->t_read != NULL) {
- thread_cancel(babel_routing_process->t_read);
- }
- if (babel_routing_process->t_update != NULL) {
- thread_cancel(babel_routing_process->t_update);
- }
+ /* cancel events */
+ thread_cancel(&babel_routing_process->t_read);
+ thread_cancel(&babel_routing_process->t_update);
distribute_list_delete(&babel_routing_process->distribute_ctx);
XFREE(MTYPE_BABEL, babel_routing_process);
babel_set_timer(struct timeval *timeout)
{
long msecs = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
- if (babel_routing_process->t_update != NULL) {
- thread_cancel(babel_routing_process->t_update);
- }
+ thread_cancel(&(babel_routing_process->t_update));
thread_add_timer_msec(master, babel_main_loop, NULL, msecs, &babel_routing_process->t_update);
}
{
struct bfd_control_socket *bcs;
- if (bglobal.bg_csockev) {
- thread_cancel(bglobal.bg_csockev);
- bglobal.bg_csockev = NULL;
- }
+ thread_cancel(&bglobal.bg_csockev);
socket_close(&bglobal.bg_csock);
struct bfd_control_queue *bcq;
struct bfd_notify_peer *bnp;
- if (bcs->bcs_ev) {
- thread_cancel(bcs->bcs_ev);
- bcs->bcs_ev = NULL;
- }
-
- if (bcs->bcs_outev) {
- thread_cancel(bcs->bcs_outev);
- bcs->bcs_outev = NULL;
- }
+ thread_cancel(&(bcs->bcs_ev));
+ thread_cancel(&(bcs->bcs_outev));
close(bcs->bcs_sd);
return 1;
empty_list:
- if (bcs->bcs_outev) {
- thread_cancel(bcs->bcs_outev);
- bcs->bcs_outev = NULL;
- }
+ thread_cancel(&(bcs->bcs_outev));
bcs->bcs_bout = NULL;
return 0;
}
if (!CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
return 0;
- /* Cancel reuse thread. */
- if (bdc->t_reuse)
- thread_cancel(bdc->t_reuse);
- bdc->t_reuse = NULL;
+ /* Cancel reuse event. */
+ thread_cancel(&(bdc->t_reuse));
/* Clean BGP dampening information. */
bgp_damp_info_clean(afi, safi);
bgp_dump->fp = NULL;
}
- /* Removing interval thread. */
- if (bgp_dump->t_interval) {
- thread_cancel(bgp_dump->t_interval);
- bgp_dump->t_interval = NULL;
- }
+ /* Removing interval event. */
+ thread_cancel(&bgp_dump->t_interval);
bgp_dump->interval = 0;
es_next) {
bgp_evpn_es_local_info_clear(es);
}
- thread_cancel(bgp_mh_info->t_cons_check);
+ thread_cancel(&bgp_mh_info->t_cons_check);
list_delete(&bgp_mh_info->local_es_list);
list_delete(&bgp_mh_info->pend_es_list);
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)
&& bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc.import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)
&& bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc
- .import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
"%s: removing holddown bpi matching NVE of new route",
__func__);
if (bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc.import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)
&& bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc
- .import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
"%s: removing holddown bpi matching NVE of new route",
__func__);
if (bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc.import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
continue;
if (bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi
- ->extra->vnc
- .import.timer;
+ struct thread **t =
+ &(bpi->extra->vnc
+ .import.timer);
struct rfapi_withdraw *wcb =
- t->arg;
+ (*t)->arg;
wcb->import_table
->holddown_count[afi] -=
rfapiMonitorDetachImport(m);
}
- if (m->timer) {
- thread_cancel(m->timer);
- m->timer = NULL;
- }
+ thread_cancel(&m->timer);
/*
* remove from rfd list
rfapiMonitorDetachImport(m);
}
- if (m->timer) {
- thread_cancel(m->timer);
- m->timer = NULL;
- }
+ thread_cancel(&m->timer);
XFREE(MTYPE_RFAPI_MONITOR, m);
rn->info = NULL;
#endif
}
- if (mon_eth->timer) {
- thread_cancel(mon_eth->timer);
- mon_eth->timer = NULL;
- }
+ thread_cancel(&mon_eth->timer);
/*
* remove from rfd list
if (m->rfd->response_lifetime - remain < 2)
return;
- thread_cancel(m->timer);
- m->timer = NULL;
+ thread_cancel(&m->timer);
}
{
if (m->rfd->response_lifetime - remain < 2)
return;
- thread_cancel(m->timer);
- m->timer = NULL;
+ thread_cancel(&m->timer);
}
{
rfapiMonitorEthDetachImport(bgp, val);
}
- if (val->timer) {
- thread_cancel(val->timer);
- val->timer = NULL;
- }
+ thread_cancel(&val->timer);
/*
* remove from rfd list
struct rfapi_rib_tcb *tcb;
tcb = goner->timer->arg;
- thread_cancel(goner->timer);
+ thread_cancel(&goner->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
- goner->timer = NULL;
}
XFREE(MTYPE_RFAPI_INFO, goner);
}
struct agg_node *rn, /* route node attached to */
int deleted)
{
- struct thread *t = ri->timer;
struct rfapi_rib_tcb *tcb = NULL;
- if (t) {
- tcb = t->arg;
- thread_cancel(t);
- ri->timer = NULL;
+ if (ri->timer) {
+ tcb = ri->timer->arg;
+ thread_cancel(&ri->timer);
} else {
tcb = XCALLOC(MTYPE_RFAPI_RECENT_DELETE,
sizeof(struct rfapi_rib_tcb));
if (ri->timer) {
struct rfapi_rib_tcb *tcb;
- tcb = ((struct thread *)ri->timer)->arg;
- thread_cancel(ri->timer);
+ tcb = ri->timer->arg;
+ thread_cancel(&ri->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
- ri->timer = NULL;
}
vnc_zlog_debug_verbose(
if (ori->timer) {
struct rfapi_rib_tcb *tcb;
- tcb = ((struct thread *)ori->timer)
- ->arg;
- thread_cancel(ori->timer);
+ tcb = ori->timer->arg;
+ thread_cancel(&ori->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
- ori->timer = NULL;
}
#if DEBUG_PROCESS_PENDING_NODE
if (ri->timer) {
struct rfapi_rib_tcb *tcb;
- tcb = ((struct thread *)ri->timer)->arg;
- thread_cancel(
- (struct thread *)ri->timer);
+ tcb = ri->timer->arg;
+ thread_cancel(&ri->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
- ri->timer = NULL;
}
RFAPI_RIB_CHECK_COUNTS(0, delete_list->count);
rfapiGetVncLifetime(attr, &eti->lifetime);
eti->lifetime = rfapiGetHolddownFromLifetime(eti->lifetime);
- if (eti->timer) {
- /*
- * export expiration timer is already running on
- * this route: cancel it
- */
- thread_cancel(eti->timer);
- eti->timer = NULL;
- }
+ /*
+ * export expiration timer is already running on
+ * this route: cancel it
+ */
+ thread_cancel(&eti->timer);
bgp_update(peer, prefix, /* prefix */
0, /* addpath_id */
rfapiGetVncLifetime(ri->attr,
&eti->lifetime);
- if (eti->timer) {
- /*
- * export expiration timer is
- * already running on
- * this route: cancel it
- */
- thread_cancel(eti->timer);
- eti->timer = NULL;
- }
+ /*
+ * export expiration timer is
+ * already running on
+ * this route: cancel it
+ */
+ thread_cancel(&eti->timer);
vnc_zlog_debug_verbose(
"%s: calling bgp_update",
ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE);
if (eti) {
- if (eti->timer)
- thread_cancel(eti->timer);
+ thread_cancel(&eti->timer);
vnc_eti_delete(eti);
}
#endif
// TODO: check Graceful restart after 10sec
- /* check if there is already GR scheduled */
- if (e->t_distribute != NULL) {
- /* if is, cancel schedule */
- thread_cancel(e->t_distribute);
- }
+ /* cancel GR scheduled */
+ thread_cancel(&(e->t_distribute));
+
/* schedule Graceful restart for whole process in 10sec */
- e->t_distribute = NULL;
thread_add_timer(master, eigrp_distribute_timer_process, e,
(10), &e->t_distribute);
#endif
// TODO: check Graceful restart after 10sec
- /* check if there is already GR scheduled */
- if (ei->t_distribute != NULL) {
- /* if is, cancel schedule */
- thread_cancel(ei->t_distribute);
- }
+ /* Cancel GR scheduled */
+ thread_cancel(&(ei->t_distribute));
/* schedule Graceful restart for interface in 10sec */
e->t_distribute = NULL;
thread_add_timer(master, eigrp_distribute_timer_interface, ei, 10,
if (ei->on_write_q) {
listnode_delete(eigrp->oi_write_q, ei);
if (list_isempty(eigrp->oi_write_q))
- thread_cancel(eigrp->t_write);
+ thread_cancel(&(eigrp->t_write));
ei->on_write_q = 0;
}
}
void fabricd_finish(struct fabricd *f)
{
- if (f->initial_sync_timeout)
- thread_cancel(f->initial_sync_timeout);
+ thread_cancel(&(f->initial_sync_timeout));
- if (f->tier_calculation_timer)
- thread_cancel(f->tier_calculation_timer);
+ thread_cancel(&(f->tier_calculation_timer));
- if (f->tier_set_timer)
- thread_cancel(f->tier_set_timer);
+ thread_cancel(&(f->tier_set_timer));
isis_spftree_del(f->spftree);
neighbor_lists_clear(f);
f->initial_sync_circuit->interface->name);
f->initial_sync_state = FABRICD_SYNC_COMPLETE;
f->initial_sync_circuit = NULL;
- thread_cancel(f->initial_sync_timeout);
- f->initial_sync_timeout = NULL;
+ thread_cancel(&(f->initial_sync_timeout));
}
static void fabricd_bump_tier_calculation_timer(struct fabricd *f);
static void fabricd_bump_tier_calculation_timer(struct fabricd *f)
{
/* Cancel timer if we already know our tier */
- if (f->tier != ISIS_TIER_UNDEFINED
- || f->tier_set_timer) {
- if (f->tier_calculation_timer) {
- thread_cancel(f->tier_calculation_timer);
- f->tier_calculation_timer = NULL;
- }
+ if (f->tier != ISIS_TIER_UNDEFINED || f->tier_set_timer) {
+ thread_cancel(&(f->tier_calculation_timer));
return;
}
/* If we need to calculate the tier, wait some
* time for the topology to settle before running
* the calculation */
- if (f->tier_calculation_timer) {
- thread_cancel(f->tier_calculation_timer);
- f->tier_calculation_timer = NULL;
- }
+ thread_cancel(&(f->tier_calculation_timer));
thread_add_timer(master, fabricd_tier_calculation_cb, f,
2 * f->area->lsp_gen_interval[ISIS_LEVEL2 - 1],
if (!circuit->t_send_csnp[1])
continue;
- thread_cancel(circuit->t_send_csnp[ISIS_LEVEL2 - 1]);
+ thread_cancel(&(circuit->t_send_csnp[ISIS_LEVEL2 - 1]));
thread_add_timer_msec(master, send_l2_csnp, circuit,
isis_jitter(f->csnp_delay, CSNP_JITTER),
&circuit->t_send_csnp[ISIS_LEVEL2 - 1]);
if (thread_timer_remain_msec(*threadp) < (unsigned long)delay)
return;
- thread_cancel(*threadp);
+ thread_cancel(threadp);
}
thread_add_timer_msec(master, send_hello_cb,
{
struct isis_tx_queue_entry *e = element;
- if (e->retry)
- thread_cancel(e->retry);
+ thread_cancel(&(e->retry));
XFREE(MTYPE_TX_QUEUE_ENTRY, e);
}
e->type = type;
- if (e->retry)
- thread_cancel(e->retry);
+ thread_cancel(&(e->retry));
thread_add_event(master, tx_queue_send_event, e, 0, &e->retry);
e->is_retry = false;
func, file, line);
}
- if (e->retry)
- thread_cancel(e->retry);
+ thread_cancel(&(e->retry));
hash_release(queue->hash, e);
XFREE(MTYPE_TX_QUEUE_ENTRY, e);
if (thr_fd == fd) {
struct listnode *nextln = listnextnode(ln);
if (!FD_ISSET(fd, &fds)) {
- thread_cancel(thr);
+ thread_cancel(&thr);
list_delete_node(events, ln);
}
ln = nextln;
*/
while (ln) {
struct listnode *nextln = listnextnode(ln);
- thread_cancel(listgetdata(ln));
+ thr = listgetdata(ln);
+ thread_cancel(&thr);
list_delete_node(events, ln);
ln = nextln;
}
cb->read.cancelled = false;
if (events & ZMQ_POLLIN) {
- if (cb->read.thread) {
- thread_cancel(cb->read.thread);
- cb->read.thread = NULL;
- }
+ thread_cancel(&cb->read.thread);
+
funcname_thread_add_event(master, frrzmq_read_msg, cbp, fd,
&cb->read.thread, funcname, schedfrom,
fromln);
cb->write.cancelled = false;
if (events & ZMQ_POLLOUT) {
- if (cb->write.thread) {
- thread_cancel(cb->write.thread);
- cb->write.thread = NULL;
- }
+ thread_cancel(&cb->write.thread);
+
funcname_thread_add_event(master, frrzmq_write_msg, cbp, fd,
&cb->write.thread, funcname,
schedfrom, fromln);
if (!cb || !*cb)
return;
core->cancelled = true;
- if (core->thread) {
- thread_cancel(core->thread);
- core->thread = NULL;
- }
+ thread_cancel(&core->thread);
+
if ((*cb)->read.cancelled && !(*cb)->read.thread
&& (*cb)->write.cancelled && (*cb)->write.thread)
XFREE(MTYPE_ZEROMQ_CB, *cb);
return;
if (events & event && core->thread && !core->cancelled) {
struct thread_master *tm = core->thread->master;
- thread_cancel(core->thread);
- core->thread = NULL;
+ thread_cancel(&core->thread);
+
thread_add_event(tm, (event == ZMQ_POLLIN ? frrzmq_read_msg
: frrzmq_write_msg),
cbp, cb->fd, &core->thread);
*
* @param thread task to cancel
*/
-void thread_cancel(struct thread *thread)
+void thread_cancel(struct thread **thread)
{
- struct thread_master *master = thread->master;
+ struct thread_master *master;
+
+ if (thread == NULL || *thread == NULL)
+ return;
+
+ master = (*thread)->master;
assert(master->owner == pthread_self());
frr_with_mutex(&master->mtx) {
struct cancel_req *cr =
XCALLOC(MTYPE_TMP, sizeof(struct cancel_req));
- cr->thread = thread;
+ cr->thread = *thread;
listnode_add(master->cancel_req, cr);
do_thread_cancel(master);
}
+
+ *thread = NULL;
}
/**
pthread_t owner;
};
+typedef struct thread_master event_master;
+
/* Thread itself. */
struct thread {
uint8_t type; /* thread type */
#define THREAD_FD(X) ((X)->u.fd)
#define THREAD_VAL(X) ((X)->u.val)
-#define THREAD_OFF(thread) \
- do { \
- if (thread) { \
- thread_cancel(thread); \
- thread = NULL; \
- } \
- } while (0)
-
-#define THREAD_READ_OFF(thread) THREAD_OFF(thread)
-#define THREAD_WRITE_OFF(thread) THREAD_OFF(thread)
-#define THREAD_TIMER_OFF(thread) THREAD_OFF(thread)
+#define THREAD_OFF(thread) thread_cancel(&(thread))
+#define THREAD_READ_OFF(thread) thread_cancel(&(thread))
+#define THREAD_WRITE_OFF(thread) thread_cancel(&(thread))
+#define THREAD_TIMER_OFF(thread) thread_cancel(&(thread))
#define debugargdef const char *funcname, const char *schedfrom, int fromln
debugargdef);
#undef debugargdef
-extern void thread_cancel(struct thread *);
+extern void thread_cancel(struct thread **event);
extern void thread_cancel_async(struct thread_master *, struct thread **,
void *);
extern void thread_cancel_event(struct thread_master *, void *);
struct work_queue *wq = *wqp;
if (wq->thread != NULL)
- thread_cancel(wq->thread);
+ thread_cancel(&(wq->thread));
while (!work_queue_empty(wq)) {
struct work_queue_item *item = work_queue_last_item(wq);
void work_queue_plug(struct work_queue *wq)
{
if (wq->thread)
- thread_cancel(wq->thread);
+ thread_cancel(&(wq->thread));
wq->thread = NULL;
struct listnode *node;
/* Cancel read and write threads. */
- if (apiserv->t_sync_read) {
- thread_cancel(apiserv->t_sync_read);
- }
+ thread_cancel(&apiserv->t_sync_read);
#ifdef USE_ASYNC_READ
- if (apiserv->t_async_read) {
- thread_cancel(apiserv->t_async_read);
- }
+ thread_cancel(&apiserv->t_async_read);
#endif /* USE_ASYNC_READ */
- if (apiserv->t_sync_write) {
- thread_cancel(apiserv->t_sync_write);
- }
-
- if (apiserv->t_async_write) {
- thread_cancel(apiserv->t_async_write);
- }
+ thread_cancel(&apiserv->t_sync_write);
+ thread_cancel(&apiserv->t_async_write);
/* Unregister all opaque types that application registered
and flush opaque LSAs if still in LSDB. */
} while (0)
/* Macro for OSPF ISM timer turn off. */
-#define OSPF_ISM_TIMER_OFF(X) \
- do { \
- if (X) { \
- thread_cancel(X); \
- (X) = NULL; \
- } \
- } while (0)
+#define OSPF_ISM_TIMER_OFF(X) thread_cancel(&(X));
/* Macro for OSPF schedule event. */
#define OSPF_ISM_EVENT_SCHEDULE(I, E) \
#define OSPF_NSM_TIMER_ON(T,F,V) thread_add_timer (master, (F), nbr, (V), &(T))
/* Macro for OSPF NSM timer turn off. */
-#define OSPF_NSM_TIMER_OFF(X) \
- do { \
- if (X) { \
- thread_cancel(X); \
- (X) = NULL; \
- } \
- } while (0)
+#define OSPF_NSM_TIMER_OFF(X) thread_cancel(&(X))
/* Macro for OSPF NSM schedule event. */
#define OSPF_NSM_EVENT_SCHEDULE(N, E) \
void ospf_ls_req_event(struct ospf_neighbor *nbr)
{
- if (nbr->t_ls_req) {
- thread_cancel(nbr->t_ls_req);
- nbr->t_ls_req = NULL;
- }
- nbr->t_ls_req = NULL;
+ thread_cancel(&nbr->t_ls_req);
thread_add_event(master, ospf_ls_req_timer, nbr, 0, &nbr->t_ls_req);
}
}
/* remove update event */
- if (oi->t_ls_upd_event) {
- thread_cancel(oi->t_ls_upd_event);
- oi->t_ls_upd_event = NULL;
- }
+ thread_cancel(&oi->t_ls_upd_event);
}
void ospf_if_update(struct ospf *ospf, struct interface *ifp)
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("%s: ospf old_vrf_id %d unlinked", __func__,
old_vrf_id);
- thread_cancel(ospf->t_read);
+ thread_cancel(&ospf->t_read);
close(ospf->fd);
ospf->fd = -1;
}
#define OSPF_AREA_TIMER_ON(T,F,V) thread_add_timer (master, (F), area, (V), &(T))
#define OSPF_POLL_TIMER_ON(T,F,V) thread_add_timer (master, (F), nbr_nbma, (V), &(T))
#define OSPF_POLL_TIMER_OFF(X) OSPF_TIMER_OFF((X))
-#define OSPF_TIMER_OFF(X) \
- do { \
- if (X) { \
- thread_cancel(X); \
- (X) = NULL; \
- } \
- } while (0)
+#define OSPF_TIMER_OFF(X) thread_cancel(&(X))
/* Extern variables. */
extern struct ospf_master *om;
ri->enable_interface = 0;
ri->running = 0;
- if (ri->t_wakeup) {
- thread_cancel(ri->t_wakeup);
- ri->t_wakeup = NULL;
- }
+ thread_cancel(&ri->t_wakeup);
}
void rip_interfaces_clean(struct rip *rip)
peer = rip_peer_lookup(rip, addr);
if (peer) {
- if (peer->t_timeout)
- thread_cancel(peer->t_timeout);
+ thread_cancel(&peer->t_timeout);
} else {
peer = rip_peer_new();
peer->rip = rip;
ri->enable_interface = 0;
ri->running = 0;
- if (ri->t_wakeup) {
- thread_cancel(ri->t_wakeup);
- ri->t_wakeup = NULL;
- }
+ thread_cancel(&ri->t_wakeup);
}
}
peer = ripng_peer_lookup(ripng, addr);
if (peer) {
- if (peer->t_timeout)
- thread_cancel(peer->t_timeout);
+ thread_cancel(&peer->t_timeout);
} else {
peer = ripng_peer_new();
peer->ripng = ripng;
}
/* Update timeout thread. */
- peer->t_timeout = NULL;
thread_add_timer(master, ripng_peer_timeout, peer,
RIPNG_PEER_TIMER_DEFAULT, &peer->t_timeout);
/* Triggered updates may be suppressed if a regular update is due by
the time the triggered update would be sent. */
- if (ripng->t_triggered_interval) {
- thread_cancel(ripng->t_triggered_interval);
- ripng->t_triggered_interval = NULL;
- }
+ thread_cancel(&ripng->t_triggered_interval);
ripng->trigger = 0;
/* Reset flush event. */
ripng->t_triggered_update = NULL;
/* Cancel interval timer. */
- if (ripng->t_triggered_interval) {
- thread_cancel(ripng->t_triggered_interval);
- ripng->t_triggered_interval = NULL;
- }
+ thread_cancel(&ripng->t_triggered_interval);
ripng->trigger = 0;
/* Logging triggered update. */
&ripng->t_read);
break;
case RIPNG_UPDATE_EVENT:
- if (ripng->t_update) {
- thread_cancel(ripng->t_update);
- ripng->t_update = NULL;
- }
+ thread_cancel(&ripng->t_update);
+
/* Update timer jitter. */
jitter = ripng_update_jitter(ripng->update_time);
RIPNG_TIMER_OFF(ripng->t_triggered_interval);
/* Cancel the read thread */
- if (ripng->t_read) {
- thread_cancel(ripng->t_read);
- ripng->t_read = NULL;
- }
+ thread_cancel(&ripng->t_read);
/* Close the RIPng socket */
if (ripng->sock >= 0) {
/* RIPng timer on/off macro. */
#define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
-#define RIPNG_TIMER_OFF(T) \
- do { \
- if (T) { \
- thread_cancel(T); \
- (T) = NULL; \
- } \
- } while (0)
+#define RIPNG_TIMER_OFF(T) thread_cancel(&(T));
#define RIPNG_OFFSET_LIST_IN 0
#define RIPNG_OFFSET_LIST_OUT 1
continue;
XFREE(MTYPE_TMP, timers[index]->arg);
- thread_cancel(timers[index]);
+ thread_cancel(&timers[index]);
timers[index] = NULL;
timers_pending--;
}
thread_add_timer_msec(master, dummy_func, NULL, 0, &timers[i]);
}
for (i = 0; i < SCHEDULE_TIMERS; i++)
- thread_cancel(timers[i]);
+ thread_cancel(&timers[i]);
monotime(&tv_start);
int index;
index = prng_rand(prng) % SCHEDULE_TIMERS;
- if (timers[index])
- thread_cancel(timers[index]);
+ thread_cancel(&timers[index]);
timers[index] = NULL;
}
what = restart->what;
restart->pid = 0;
gs.numpids--;
- thread_cancel(restart->t_kill);
- restart->t_kill = NULL;
+ thread_cancel(&restart->t_kill);
+
/* Update restart time to reflect the time the command
* completed. */
gettimeofday(&restart->time, NULL);
dmn->name, (long)delay.tv_sec, (long)delay.tv_usec);
SET_READ_HANDLER(dmn);
- if (dmn->t_wakeup)
- thread_cancel(dmn->t_wakeup);
+ thread_cancel(&dmn->t_wakeup);
SET_WAKEUP_ECHO(dmn);
return 0;
static void set_phase(restart_phase_t new_phase)
{
gs.phase = new_phase;
- if (gs.t_phase_hanging)
- thread_cancel(gs.t_phase_hanging);
- gs.t_phase_hanging = NULL;
+ thread_cancel(&gs.t_phase_hanging);
+
thread_add_timer(master, phase_hanging, NULL, PHASE_TIMEOUT,
&gs.t_phase_hanging);
}
if (!irdp)
return;
- if (irdp->t_advertise)
- thread_cancel(irdp->t_advertise);
- irdp->t_advertise = NULL;
+ thread_cancel(&irdp->t_advertise);
if (ifp->connected)
for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, ifc)) {
return;
irdp->flags |= IF_SOLICIT;
- if (irdp->t_advertise)
- thread_cancel(irdp->t_advertise);
- irdp->t_advertise = NULL;
+ thread_cancel(&irdp->t_advertise);
timer = (frr_weak_random() % MAX_RESPONSE_DELAY) + 1;
fd = zebra_netns_notify_current->u.fd;
if (zebra_netns_notify_current->master != NULL)
- thread_cancel(zebra_netns_notify_current);
+ thread_cancel(&zebra_netns_notify_current);
/* auto-removal of notify items */
if (fd > 0)
if (ptm_cb.in_data)
free(ptm_cb.in_data);
- /* Release threads. */
- if (ptm_cb.t_read)
- thread_cancel(ptm_cb.t_read);
- if (ptm_cb.t_write)
- thread_cancel(ptm_cb.t_write);
- if (ptm_cb.t_timer)
- thread_cancel(ptm_cb.t_timer);
+ /* Cancel events. */
+ thread_cancel(&ptm_cb.t_read);
+ thread_cancel(&ptm_cb.t_write);
+ thread_cancel(&ptm_cb.t_timer);
if (ptm_cb.wb)
buffer_free(ptm_cb.wb);
if (!value && zebra_t_rmap_update) {
/* Event driven route map updates is being disabled */
/* But there's a pending timer. Fire it off now */
- thread_cancel(zebra_t_rmap_update);
+ thread_cancel(&zebra_t_rmap_update);
zebra_route_map_update_timer(zebra_t_rmap_update);
}
}