From: Quentin Young Date: Fri, 5 May 2017 21:22:25 +0000 (+0000) Subject: *: update thread_add_* calls X-Git-Tag: reindent-master-before~184^2~2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=66e78ae64bc4659848517953b365606e3e70e878;p=matthieu%2Ffrr.git *: update thread_add_* calls Pass pointer to pointer instead of assigning by return value. See previous commit message. To ensure that the behavior stays functionally correct, any assignments with the result of a thread_add* function have been transformed to set the pointer to null before passing it. These can be removed wherever the pointer is known to already be null. Signed-off-by: Quentin Young --- diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index 333f58061f..114e641ebd 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -116,8 +116,8 @@ bgp_reuse_timer (struct thread *t) time_t t_now, t_diff; damp->t_reuse = NULL; - damp->t_reuse = - thread_add_timer(bm->master, bgp_reuse_timer, NULL, DELTA_REUSE, NULL); + thread_add_timer(bm->master, bgp_reuse_timer, NULL, DELTA_REUSE, + &damp->t_reuse); t_now = bgp_clock (); diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index 2e4520c19e..10ddf1660c 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -171,16 +171,16 @@ bgp_dump_interval_add (struct bgp_dump *bgp_dump, int interval) secs_into_day = tm->tm_sec + 60*tm->tm_min + 60*60*tm->tm_hour; interval = interval - secs_into_day % interval; /* always > 0 */ } - bgp_dump->t_interval = thread_add_timer(bm->master, - bgp_dump_interval_func, - bgp_dump, interval, NULL); + bgp_dump->t_interval = NULL; + thread_add_timer(bm->master, bgp_dump_interval_func, bgp_dump, interval, + &bgp_dump->t_interval); } else { /* One-off dump: execute immediately, don't affect any scheduled dumps */ - bgp_dump->t_interval = thread_add_event(bm->master, - bgp_dump_interval_func, - bgp_dump, 0, NULL); + bgp_dump->t_interval = NULL; + thread_add_event(bm->master, bgp_dump_interval_func, bgp_dump, 0, + &bgp_dump->t_interval); } return 0; diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 556b4bedc7..b64d902d88 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -297,8 +297,9 @@ bgp_accept (struct thread *thread) zlog_err ("accept_sock is nevative value %d", accept_sock); return -1; } - listener->thread = thread_add_read(bm->master, bgp_accept, listener, - accept_sock, NULL); + listener->thread = NULL; + thread_add_read(bm->master, bgp_accept, listener, accept_sock, + &listener->thread); /* Accept client connection. */ bgp_sock = sockunion_accept (accept_sock, &su); @@ -705,8 +706,8 @@ bgp_listener (int sock, struct sockaddr *sa, socklen_t salen) listener = XMALLOC (MTYPE_BGP_LISTENER, sizeof(*listener)); listener->fd = sock; memcpy(&listener->su, sa, salen); - listener->thread = thread_add_read(bm->master, bgp_accept, listener, sock, - NULL); + listener->thread = NULL; + thread_add_read(bm->master, bgp_accept, listener, sock, &listener->thread); listnode_add (bm->listen_sockets, listener); return 0; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 13b837a3f4..02b029d9ee 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3089,9 +3089,6 @@ bgp_announce_route_timer_expired (struct thread *t) paf = THREAD_ARG (t); peer = paf->peer; - assert (paf->t_announce_route); - paf->t_announce_route = NULL; - if (peer->status != Established) return 0; diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 88f48cb903..4563ec85f6 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -3176,9 +3176,9 @@ bgp_route_map_mark_update (const char *rmap_name) /* rmap_update_timer of 0 means don't do route updates */ if (bm->rmap_update_timer) { - bm->t_rmap_update = - thread_add_timer(bm->master, bgp_route_map_update_timer, NULL, - bm->rmap_update_timer, NULL); + bm->t_rmap_update = NULL; + thread_add_timer(bm->master, bgp_route_map_update_timer, NULL, bm->rmap_update_timer, + &bm->t_rmap_update); /* Signal the groups that a route-map update event has started */ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 65b569c37f..09089a3b3f 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -1169,9 +1169,9 @@ update_subgroup_trigger_merge_check (struct update_subgroup *subgrp, if (!force && !update_subgroup_ready_for_merge (subgrp)) return 0; - subgrp->t_merge_check = - thread_add_background(bm->master, update_subgroup_merge_check_thread_cb, - subgrp, 0, NULL); + subgrp->t_merge_check = NULL; + thread_add_background(bm->master, update_subgroup_merge_check_thread_cb, subgrp, 0, + &subgrp->t_merge_check); SUBGRP_INCR_STAT (subgrp, merge_checks_triggered); diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index e91bc27ba0..bef4b64d27 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -3033,9 +3033,9 @@ rfapiBiStartWithdrawTimer ( if (lifetime > UINT32_MAX / 1001) { /* sub-optimal case, but will probably never happen */ - bi->extra->vnc.import.timer = thread_add_timer(bm->master, - timer_service_func, wcb, - lifetime, NULL); + bi->extra->vnc.import.timer = NULL; + thread_add_timer(bm->master, timer_service_func, wcb, lifetime, + &bi->extra->vnc.import.timer); } else { @@ -3051,10 +3051,9 @@ rfapiBiStartWithdrawTimer ( lifetime_msec = (lifetime * 1000) + jitter; - bi->extra->vnc.import.timer = thread_add_background(bm->master, - timer_service_func, - wcb, lifetime_msec, - NULL); + bi->extra->vnc.import.timer = NULL; + thread_add_background(bm->master, timer_service_func, wcb, lifetime_msec, + &bi->extra->vnc.import.timer); } /* re-sort route list (BGP_INFO_REMOVED routes are last) */ diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c index cd884a0adb..8eeed0216c 100644 --- a/bgpd/rfapi/rfapi_monitor.c +++ b/bgpd/rfapi/rfapi_monitor.c @@ -852,8 +852,9 @@ rfapiMonitorTimerRestart (struct rfapi_monitor_vpn *m) rfapi_ntop (m->p.family, m->p.u.val, buf, BUFSIZ), m->rfd->response_lifetime); } - m->timer = thread_add_timer(bm->master, rfapiMonitorTimerExpire, m, - m->rfd->response_lifetime, NULL); + m->timer = NULL; + thread_add_timer(bm->master, rfapiMonitorTimerExpire, m, m->rfd->response_lifetime, + &m->timer); } /* @@ -1183,8 +1184,9 @@ rfapiMonitorEthTimerRestart (struct rfapi_monitor_eth *m) rfapiEthAddr2Str (&m->macaddr, buf, BUFSIZ), m->rfd->response_lifetime); } - m->timer = thread_add_timer(bm->master, rfapiMonitorEthTimerExpire, m, - m->rfd->response_lifetime, NULL); + m->timer = NULL; + thread_add_timer(bm->master, rfapiMonitorEthTimerExpire, m, m->rfd->response_lifetime, + &m->timer); } static int diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index 654da95a41..b59db3ab56 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -400,8 +400,9 @@ rfapiRibStartTimer ( prefix2str (&rn->p, buf_prefix, BUFSIZ); vnc_zlog_debug_verbose ("%s: rfd %p pfx %s life %u", __func__, rfd, buf_prefix, ri->lifetime); - ri->timer = thread_add_timer(bm->master, rfapiRibExpireTimer, tcb, - ri->lifetime, NULL); + ri->timer = NULL; + thread_add_timer(bm->master, rfapiRibExpireTimer, tcb, ri->lifetime, + &ri->timer); assert (ri->timer); } diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index fd97f2cd13..55eda907c8 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -1856,8 +1856,9 @@ vnc_direct_bgp_rh_del_route ( if (!eti->timer && eti->lifetime <= INT32_MAX) { - eti->timer = thread_add_timer(bm->master, vncExportWithdrawTimer, eti, - eti->lifetime, NULL); + eti->timer = NULL; + thread_add_timer(bm->master, vncExportWithdrawTimer, eti, eti->lifetime, + &eti->timer); vnc_zlog_debug_verbose ("%s: set expiration timer for %u seconds", __func__, eti->lifetime); } diff --git a/ldpd/accept.c b/ldpd/accept.c index 5b1dacc308..323558d7fd 100644 --- a/ldpd/accept.c +++ b/ldpd/accept.c @@ -58,7 +58,8 @@ accept_add(int fd, int (*cb)(struct thread *), void *arg) av->arg = arg; LIST_INSERT_HEAD(&accept_queue.queue, av, entry); - av->ev = thread_add_read(master, accept_cb, av, av->fd, NULL); + av->ev = NULL; + thread_add_read(master, accept_cb, av, av->fd, &av->ev); log_debug("%s: accepting on fd %d", __func__, fd); @@ -85,8 +86,8 @@ accept_pause(void) { log_debug(__func__); accept_unarm(); - accept_queue.evt = thread_add_timer(master, accept_timeout, NULL, 1, - NULL); + accept_queue.evt = NULL; + thread_add_timer(master, accept_timeout, NULL, 1, &accept_queue.evt); } void @@ -103,8 +104,10 @@ static void accept_arm(void) { struct accept_ev *av; - LIST_FOREACH(av, &accept_queue.queue, entry) - av->ev = thread_add_read(master, accept_cb, av, av->fd, NULL); + LIST_FOREACH(av, &accept_queue.queue, entry) { + av->ev = NULL; + thread_add_read(master, accept_cb, av, av->fd, &av->ev); + } } static void @@ -119,7 +122,8 @@ static int accept_cb(struct thread *thread) { struct accept_ev *av = THREAD_ARG(thread); - av->ev = thread_add_read(master, accept_cb, av, av->fd, NULL); + av->ev = NULL; + thread_add_read(master, accept_cb, av, av->fd, &av->ev); av->accept_cb(thread); return (0); diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c index e8bc58b7e8..52e2776654 100644 --- a/ldpd/adjacency.c +++ b/ldpd/adjacency.c @@ -206,8 +206,9 @@ void adj_start_itimer(struct adj *adj) { THREAD_TIMER_OFF(adj->inactivity_timer); - adj->inactivity_timer = thread_add_timer(master, adj_itimer, adj, - adj->holdtime, NULL); + adj->inactivity_timer = NULL; + thread_add_timer(master, adj_itimer, adj, adj->holdtime, + &adj->inactivity_timer); } void @@ -366,9 +367,9 @@ static void tnbr_start_hello_timer(struct tnbr *tnbr) { THREAD_TIMER_OFF(tnbr->hello_timer); - tnbr->hello_timer = thread_add_timer(master, tnbr_hello_timer, tnbr, - tnbr_get_hello_interval(tnbr), - NULL); + tnbr->hello_timer = NULL; + thread_add_timer(master, tnbr_hello_timer, tnbr, tnbr_get_hello_interval(tnbr), + &tnbr->hello_timer); } static void diff --git a/ldpd/control.c b/ldpd/control.c index 40d8007d76..cde99dc8a9 100644 --- a/ldpd/control.c +++ b/ldpd/control.c @@ -133,8 +133,9 @@ control_accept(struct thread *thread) imsg_init(&c->iev.ibuf, connfd); c->iev.handler_read = control_dispatch_imsg; - c->iev.ev_read = thread_add_read(master, c->iev.handler_read, &c->iev, - c->iev.ibuf.fd, NULL); + c->iev.ev_read = NULL; + thread_add_read(master, c->iev.handler_read, &c->iev, c->iev.ibuf.fd, + &c->iev.ev_read); c->iev.handler_write = ldp_write_handler; c->iev.ev_write = NULL; diff --git a/ldpd/interface.c b/ldpd/interface.c index 42f6ca5f38..a064a58b2e 100644 --- a/ldpd/interface.c +++ b/ldpd/interface.c @@ -440,8 +440,9 @@ static void if_start_hello_timer(struct iface_af *ia) { THREAD_TIMER_OFF(ia->hello_timer); - ia->hello_timer = thread_add_timer(master, if_hello_timer, ia, - if_get_hello_interval(ia), NULL); + ia->hello_timer = NULL; + thread_add_timer(master, if_hello_timer, ia, if_get_hello_interval(ia), + &ia->hello_timer); } static void diff --git a/ldpd/lde.c b/ldpd/lde.c index 2d87161ec2..bef35f3194 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -140,8 +140,9 @@ lde(void) fatal(NULL); imsg_init(&iev_main->ibuf, LDPD_FD_ASYNC); iev_main->handler_read = lde_dispatch_parent; - iev_main->ev_read = thread_add_read(master, iev_main->handler_read, - iev_main, iev_main->ibuf.fd, NULL); + iev_main->ev_read = NULL; + thread_add_read(master, iev_main->handler_read, iev_main, iev_main->ibuf.fd, + &iev_main->ev_read); iev_main->handler_write = ldp_write_handler; if ((iev_main_sync = calloc(1, sizeof(struct imsgev))) == NULL) @@ -526,11 +527,9 @@ lde_dispatch_parent(struct thread *thread) fatal(NULL); imsg_init(&iev_ldpe->ibuf, fd); iev_ldpe->handler_read = lde_dispatch_imsg; - iev_ldpe->ev_read = thread_add_read(master, - iev_ldpe->handler_read, - iev_ldpe, - iev_ldpe->ibuf.fd, - NULL); + iev_ldpe->ev_read = NULL; + thread_add_read(master, iev_ldpe->handler_read, iev_ldpe, iev_ldpe->ibuf.fd, + &iev_ldpe->ev_read); iev_ldpe->handler_write = ldp_write_handler; iev_ldpe->ev_write = NULL; break; diff --git a/ldpd/lde_lib.c b/ldpd/lde_lib.c index 0585a776ad..89aa6d4201 100644 --- a/ldpd/lde_lib.c +++ b/ldpd/lde_lib.c @@ -932,8 +932,9 @@ void lde_gc_start_timer(void) { THREAD_TIMER_OFF(gc_timer); - gc_timer = thread_add_timer(master, lde_gc_timer, NULL, - LDE_GC_INTERVAL, NULL); + gc_timer = NULL; + thread_add_timer(master, lde_gc_timer, NULL, LDE_GC_INTERVAL, + &gc_timer); } void diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index 1fbb4d67f0..a0b021dfd9 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -358,30 +358,30 @@ main(int argc, char *argv[]) fatal(NULL); imsg_init(&iev_ldpe->ibuf, pipe_parent2ldpe[0]); iev_ldpe->handler_read = main_dispatch_ldpe; - iev_ldpe->ev_read = thread_add_read(master, iev_ldpe->handler_read, - iev_ldpe, iev_ldpe->ibuf.fd, NULL); + iev_ldpe->ev_read = NULL; + thread_add_read(master, iev_ldpe->handler_read, iev_ldpe, iev_ldpe->ibuf.fd, + &iev_ldpe->ev_read); iev_ldpe->handler_write = ldp_write_handler; imsg_init(&iev_ldpe_sync->ibuf, pipe_parent2ldpe_sync[0]); iev_ldpe_sync->handler_read = main_dispatch_ldpe; - iev_ldpe_sync->ev_read = thread_add_read(master, - iev_ldpe_sync->handler_read, - iev_ldpe_sync, - iev_ldpe_sync->ibuf.fd, NULL); + iev_ldpe_sync->ev_read = NULL; + thread_add_read(master, iev_ldpe_sync->handler_read, iev_ldpe_sync, iev_ldpe_sync->ibuf.fd, + &iev_ldpe_sync->ev_read); iev_ldpe_sync->handler_write = ldp_write_handler; imsg_init(&iev_lde->ibuf, pipe_parent2lde[0]); iev_lde->handler_read = main_dispatch_lde; - iev_lde->ev_read = thread_add_read(master, iev_lde->handler_read, - iev_lde, iev_lde->ibuf.fd, NULL); + iev_lde->ev_read = NULL; + thread_add_read(master, iev_lde->handler_read, iev_lde, iev_lde->ibuf.fd, + &iev_lde->ev_read); iev_lde->handler_write = ldp_write_handler; imsg_init(&iev_lde_sync->ibuf, pipe_parent2lde_sync[0]); iev_lde_sync->handler_read = main_dispatch_lde; - iev_lde_sync->ev_read = thread_add_read(master, - iev_lde_sync->handler_read, - iev_lde_sync, - iev_lde_sync->ibuf.fd, NULL); + iev_lde_sync->ev_read = NULL; + thread_add_read(master, iev_lde_sync->handler_read, iev_lde_sync, iev_lde_sync->ibuf.fd, + &iev_lde_sync->ev_read); iev_lde_sync->handler_write = ldp_write_handler; if (main_imsg_send_ipc_sockets(&iev_ldpe->ibuf, &iev_lde->ibuf)) diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index 9f87e58c40..ce2441ca2f 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -119,8 +119,9 @@ ldpe(void) fatal(NULL); imsg_init(&iev_main->ibuf, LDPD_FD_ASYNC); iev_main->handler_read = ldpe_dispatch_main; - iev_main->ev_read = thread_add_read(master, iev_main->handler_read, - iev_main, iev_main->ibuf.fd, NULL); + iev_main->ev_read = NULL; + thread_add_read(master, iev_main->handler_read, iev_main, iev_main->ibuf.fd, + &iev_main->ev_read); iev_main->handler_write = ldp_write_handler; if ((iev_main_sync = calloc(1, sizeof(struct imsgev))) == NULL) @@ -164,9 +165,11 @@ ldpe_init(struct ldpd_init *init) fatal("inet_pton"); #ifdef __OpenBSD__ global.pfkeysock = pfkey_init(); - if (sysdep.no_pfkey == 0) - pfkey_ev = thread_add_read(master, ldpe_dispatch_pfkey, NULL, - global.pfkeysock, NULL); + if (sysdep.no_pfkey == 0) { + pfkey_ev = NULL; + thread_add_read(master, ldpe_dispatch_pfkey, NULL, global.pfkeysock, + &pfkey_ev); + } #endif /* mark sockets as closed */ @@ -353,11 +356,9 @@ ldpe_dispatch_main(struct thread *thread) fatal(NULL); imsg_init(&iev_lde->ibuf, fd); iev_lde->handler_read = ldpe_dispatch_lde; - iev_lde->ev_read = thread_add_read(master, - iev_lde->handler_read, - iev_lde, - iev_lde->ibuf.fd, - NULL); + iev_lde->ev_read = NULL; + thread_add_read(master, iev_lde->handler_read, iev_lde, iev_lde->ibuf.fd, + &iev_lde->ev_read); iev_lde->handler_write = ldp_write_handler; iev_lde->ev_write = NULL; break; @@ -697,8 +698,9 @@ ldpe_dispatch_pfkey(struct thread *thread) { int fd = THREAD_FD(thread); - pfkey_ev = thread_add_read(master, ldpe_dispatch_pfkey, NULL, - global.pfkeysock, NULL); + pfkey_ev = NULL; + thread_add_read(master, ldpe_dispatch_pfkey, NULL, global.pfkeysock, + &pfkey_ev); if (pfkey_read(fd, NULL) == -1) fatal("pfkey_read failed, exiting..."); @@ -717,16 +719,15 @@ ldpe_setup_sockets(int af, int disc_socket, int edisc_socket, /* discovery socket */ af_global->ldp_disc_socket = disc_socket; - af_global->disc_ev = thread_add_read(master, disc_recv_packet, - &af_global->disc_ev, - af_global->ldp_disc_socket, NULL); + af_global->disc_ev = NULL; + thread_add_read(master, disc_recv_packet, &af_global->disc_ev, af_global->ldp_disc_socket, + &af_global->disc_ev); /* extended discovery socket */ af_global->ldp_edisc_socket = edisc_socket; - af_global->edisc_ev = thread_add_read(master, disc_recv_packet, - &af_global->edisc_ev, - af_global->ldp_edisc_socket, - NULL); + af_global->edisc_ev = NULL; + thread_add_read(master, disc_recv_packet, &af_global->edisc_ev, af_global->ldp_edisc_socket, + &af_global->edisc_ev); /* session socket */ af_global->ldp_session_socket = session_socket; diff --git a/ldpd/neighbor.c b/ldpd/neighbor.c index 2eb46733ee..f867db228d 100644 --- a/ldpd/neighbor.c +++ b/ldpd/neighbor.c @@ -408,8 +408,8 @@ nbr_start_ktimer(struct nbr *nbr) /* send three keepalives per period */ secs = nbr->keepalive / KEEPALIVE_PER_PERIOD; THREAD_TIMER_OFF(nbr->keepalive_timer); - nbr->keepalive_timer = thread_add_timer(master, nbr_ktimer, nbr, secs, - NULL); + nbr->keepalive_timer = NULL; + thread_add_timer(master, nbr_ktimer, nbr, secs, &nbr->keepalive_timer); } void @@ -438,8 +438,9 @@ static void nbr_start_ktimeout(struct nbr *nbr) { THREAD_TIMER_OFF(nbr->keepalive_timeout); - nbr->keepalive_timeout = thread_add_timer(master, nbr_ktimeout, nbr, - nbr->keepalive, NULL); + nbr->keepalive_timeout = NULL; + thread_add_timer(master, nbr_ktimeout, nbr, nbr->keepalive, + &nbr->keepalive_timeout); } void @@ -469,8 +470,8 @@ nbr_start_itimeout(struct nbr *nbr) secs = INIT_FSM_TIMEOUT; THREAD_TIMER_OFF(nbr->init_timeout); - nbr->init_timeout = thread_add_timer(master, nbr_itimeout, nbr, secs, - NULL); + nbr->init_timeout = NULL; + thread_add_timer(master, nbr_itimeout, nbr, secs, &nbr->init_timeout); } void @@ -518,8 +519,9 @@ nbr_start_idtimer(struct nbr *nbr) } THREAD_TIMER_OFF(nbr->initdelay_timer); - nbr->initdelay_timer = thread_add_timer(master, nbr_idtimer, nbr, - secs, NULL); + nbr->initdelay_timer = NULL; + thread_add_timer(master, nbr_idtimer, nbr, secs, + &nbr->initdelay_timer); } void diff --git a/ldpd/packet.c b/ldpd/packet.c index 73703503f3..be7f2ba649 100644 --- a/ldpd/packet.c +++ b/ldpd/packet.c @@ -143,8 +143,8 @@ disc_recv_packet(struct thread *thread) struct in_addr lsr_id; /* reschedule read */ - *threadp = thread_add_read(master, disc_recv_packet, threadp, fd, - NULL); + *threadp = NULL; + thread_add_read(master, disc_recv_packet, threadp, fd, &*threadp); /* setup buffer */ memset(&m, 0, sizeof(m)); @@ -428,7 +428,8 @@ session_read(struct thread *thread) uint16_t pdu_len, msg_len, msg_size, max_pdu_len; int ret; - tcp->rev = thread_add_read(master, session_read, nbr, fd, NULL); + tcp->rev = NULL; + thread_add_read(master, session_read, nbr, fd, &tcp->rev); if ((n = read(fd, tcp->rbuf->buf + tcp->rbuf->wpos, sizeof(tcp->rbuf->buf) - tcp->rbuf->wpos)) == -1) { @@ -732,8 +733,8 @@ tcp_new(int fd, struct nbr *nbr) if ((tcp->rbuf = calloc(1, sizeof(struct ibuf_read))) == NULL) fatal(__func__); - tcp->rev = thread_add_read(master, session_read, nbr, tcp->fd, - NULL); + tcp->rev = NULL; + thread_add_read(master, session_read, nbr, tcp->fd, &tcp->rev); tcp->nbr = nbr; } @@ -779,9 +780,9 @@ pending_conn_new(int fd, int af, union ldpd_addr *addr) pconn->af = af; pconn->addr = *addr; TAILQ_INSERT_TAIL(&global.pending_conns, pconn, entry); - pconn->ev_timeout = thread_add_timer(master, pending_conn_timeout, - pconn, PENDING_CONN_TIMEOUT, - NULL); + pconn->ev_timeout = NULL; + thread_add_timer(master, pending_conn_timeout, pconn, PENDING_CONN_TIMEOUT, + &pconn->ev_timeout); return (pconn); } diff --git a/lib/agentx.c b/lib/agentx.c index f7b124f25b..eb354b6781 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -85,9 +85,11 @@ agentx_events_update(void) FD_ZERO (&fds); snmp_select_info (&maxfd, &fds, &timeout, &block); - if (!block) - timeout_thr = thread_add_timer_tv(agentx_tm, agentx_timeout, NULL, - &timeout, NULL); + if (!block) { + timeout_thr = NULL; + thread_add_timer_tv(agentx_tm, agentx_timeout, NULL, &timeout, + &timeout_thr); + } ln = listhead (events); thr = ln ? listgetdata (ln) : NULL; @@ -115,7 +117,8 @@ agentx_events_update(void) else if (FD_ISSET (fd, &fds)) { struct listnode *newln; - thr = thread_add_read(agentx_tm, agentx_read, NULL, fd, NULL); + thr = NULL; + thread_add_read(agentx_tm, agentx_read, NULL, fd, &thr); newln = listnode_add_before (events, ln, thr); thr->arg = newln; } diff --git a/lib/sigevent.c b/lib/sigevent.c index 7eda2bcdde..a34fd4946e 100644 --- a/lib/sigevent.c +++ b/lib/sigevent.c @@ -132,8 +132,9 @@ quagga_signal_timer (struct thread *t) int i; sigm = THREAD_ARG (t); - sigm->t = thread_add_timer(sigm->t->master, quagga_signal_timer, &sigmaster, - QUAGGA_SIGNAL_TIMER_INTERVAL, NULL); + sigm->t = NULL; + thread_add_timer(sigm->t->master, quagga_signal_timer, &sigmaster, QUAGGA_SIGNAL_TIMER_INTERVAL, + &sigm->t); return quagga_sigevent_process (); } #endif /* SIGEVENT_SCHEDULE_THREAD */ @@ -378,8 +379,8 @@ signal_init (struct thread_master *m, int sigc, sigmaster.signals = signals; #ifdef SIGEVENT_SCHEDULE_THREAD - sigmaster.t = - thread_add_timer(m, quagga_signal_timer, &sigmaster, - QUAGGA_SIGNAL_TIMER_INTERVAL, NULL); + sigmaster.t = NULL; + thread_add_timer(m, quagga_signal_timer, &sigmaster, QUAGGA_SIGNAL_TIMER_INTERVAL, + &sigmaster.t); #endif /* SIGEVENT_SCHEDULE_THREAD */ } diff --git a/lib/smux.c b/lib/smux.c index e0db87e4b0..6e53061d45 100644 --- a/lib/smux.c +++ b/lib/smux.c @@ -1197,16 +1197,18 @@ smux_event (enum smux_event event, int sock) switch (event) { case SMUX_SCHEDULE: - smux_connect_thread = thread_add_event(smux_master, smux_connect, NULL, - 0, NULL); + smux_connect_thread = NULL; + thread_add_event(smux_master, smux_connect, NULL, 0, + &smux_connect_thread); break; case SMUX_CONNECT: - smux_connect_thread = thread_add_timer(smux_master, smux_connect, NULL, - 10, NULL); + smux_connect_thread = NULL; + thread_add_timer(smux_master, smux_connect, NULL, 10, + &smux_connect_thread); break; case SMUX_READ: - smux_read_thread = thread_add_read(smux_master, smux_read, NULL, sock, - NULL); + smux_read_thread = NULL; + thread_add_read(smux_master, smux_read, NULL, sock, &smux_read_thread); break; default: break; diff --git a/lib/vty.c b/lib/vty.c index a68c5d0bc2..a8e54a57de 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -2618,35 +2618,37 @@ vty_event (enum event event, int sock, struct vty *vty) switch (event) { case VTY_SERV: - vty_serv_thread = thread_add_read(vty_master, vty_accept, vty, sock, - NULL); + vty_serv_thread = NULL; + thread_add_read(vty_master, vty_accept, vty, sock, &vty_serv_thread); vector_set_index (Vvty_serv_thread, sock, vty_serv_thread); break; #ifdef VTYSH case VTYSH_SERV: - vty_serv_thread = thread_add_read(vty_master, vtysh_accept, vty, sock, - NULL); + vty_serv_thread = NULL; + thread_add_read(vty_master, vtysh_accept, vty, sock, &vty_serv_thread); vector_set_index (Vvty_serv_thread, sock, vty_serv_thread); break; case VTYSH_READ: - vty->t_read = thread_add_read(vty_master, vtysh_read, vty, sock, NULL); + vty->t_read = NULL; + thread_add_read(vty_master, vtysh_read, vty, sock, &vty->t_read); break; case VTYSH_WRITE: - vty->t_write = thread_add_write(vty_master, vtysh_write, vty, sock, - NULL); + vty->t_write = NULL; + thread_add_write(vty_master, vtysh_write, vty, sock, &vty->t_write); break; #endif /* VTYSH */ case VTY_READ: - vty->t_read = thread_add_read(vty_master, vty_read, vty, sock, NULL); + vty->t_read = NULL; + thread_add_read(vty_master, vty_read, vty, sock, &vty->t_read); /* Time out treatment. */ if (vty->v_timeout) { if (vty->t_timeout) thread_cancel (vty->t_timeout); - vty->t_timeout = - thread_add_timer(vty_master, vty_timeout, vty, vty->v_timeout, - NULL); + vty->t_timeout = NULL; + thread_add_timer(vty_master, vty_timeout, vty, vty->v_timeout, + &vty->t_timeout); } break; case VTY_WRITE: @@ -2660,9 +2662,9 @@ vty_event (enum event event, int sock, struct vty *vty) } if (vty->v_timeout) { - vty->t_timeout = - thread_add_timer(vty_master, vty_timeout, vty, vty->v_timeout, - NULL); + vty->t_timeout = NULL; + thread_add_timer(vty_master, vty_timeout, vty, vty->v_timeout, + &vty->t_timeout); } break; } diff --git a/lib/workqueue.c b/lib/workqueue.c index 3d481aa899..e997e61b32 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -126,8 +126,9 @@ work_queue_schedule (struct work_queue *wq, unsigned int delay) && (wq->thread == NULL) && (listcount (wq->items) > 0) ) { - wq->thread = thread_add_background(wq->master, work_queue_run, wq, - delay, NULL); + wq->thread = NULL; + thread_add_background(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); diff --git a/lib/zclient.c b/lib/zclient.c index 60e35c66fa..1d3c93d85d 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -310,8 +310,9 @@ zclient_flush_data(struct thread *thread) return zclient_failed(zclient); break; case BUFFER_PENDING: - zclient->t_write = thread_add_write(zclient->master, zclient_flush_data, - zclient, zclient->sock, NULL); + zclient->t_write = NULL; + thread_add_write(zclient->master, zclient_flush_data, zclient, zclient->sock, + &zclient->t_write); break; case BUFFER_EMPTY: break; @@ -2023,9 +2024,9 @@ zclient_event (enum event event, struct zclient *zclient) zclient->fail < 3 ? 10 : 60, &zclient->t_connect); break; case ZCLIENT_READ: - zclient->t_read = - thread_add_read(zclient->master, zclient_read, zclient, zclient->sock, - NULL); + zclient->t_read = NULL; + thread_add_read(zclient->master, zclient_read, zclient, zclient->sock, + &zclient->t_read); break; } } diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c index 3cbeb759d9..eb51e353c5 100644 --- a/ospf6d/ospf6_flood.c +++ b/ospf6d/ospf6_flood.c @@ -112,8 +112,9 @@ ospf6_lsa_originate (struct ospf6_lsa *lsa) lsdb_self = ospf6_get_scoped_lsdb_self (lsa); ospf6_lsdb_add (ospf6_lsa_copy (lsa), lsdb_self); - lsa->refresh = thread_add_timer(master, ospf6_lsa_refresh, lsa, - OSPF_LS_REFRESH_TIME, NULL); + lsa->refresh = NULL; + thread_add_timer(master, ospf6_lsa_refresh, lsa, OSPF_LS_REFRESH_TIME, + &lsa->refresh); if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type) || IS_OSPF6_DEBUG_ORIGINATE_TYPE (lsa->header->type)) @@ -225,10 +226,11 @@ ospf6_install_lsa (struct ospf6_lsa *lsa) } monotime(&now); - if (! OSPF6_LSA_IS_MAXAGE (lsa)) - lsa->expire = thread_add_timer(master, ospf6_lsa_expire, lsa, - OSPF_LSA_MAXAGE + lsa->birth.tv_sec - now.tv_sec, - NULL); + if (! OSPF6_LSA_IS_MAXAGE (lsa)) { + lsa->expire = NULL; + thread_add_timer(master, ospf6_lsa_expire, lsa, OSPF_LSA_MAXAGE + lsa->birth.tv_sec - now.tv_sec, + &lsa->expire); + } else lsa->expire = NULL; @@ -362,10 +364,8 @@ ospf6_flood_interface (struct ospf6_neighbor *from, zlog_debug ("Add retrans-list of this neighbor"); ospf6_increment_retrans_count (lsa); ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list); - if (on->thread_send_lsupdate == NULL) - on->thread_send_lsupdate = - thread_add_timer(master, ospf6_lsupdate_send_neighbor, on, - on->ospf6_if->rxmt_interval, NULL); + thread_add_timer(master, ospf6_lsupdate_send_neighbor, on, on->ospf6_if->rxmt_interval, + &on->thread_send_lsupdate); retrans_added++; } @@ -407,9 +407,8 @@ ospf6_flood_interface (struct ospf6_neighbor *from, (oi->type == OSPF_IFTYPE_POINTOPOINT)) { ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsupdate_list); - if (oi->thread_send_lsupdate == NULL) - oi->thread_send_lsupdate = - thread_add_event(master, ospf6_lsupdate_send_interface, oi, 0, NULL); + thread_add_event(master, ospf6_lsupdate_send_interface, oi, 0, + &oi->thread_send_lsupdate); } else { @@ -417,9 +416,9 @@ ospf6_flood_interface (struct ospf6_neighbor *from, for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) { THREAD_OFF (on->thread_send_lsupdate); - on->thread_send_lsupdate = - thread_add_event(master, ospf6_lsupdate_send_neighbor, on, 0, - NULL); + on->thread_send_lsupdate = NULL; + thread_add_event(master, ospf6_lsupdate_send_neighbor, on, 0, + &on->thread_send_lsupdate); } } } @@ -579,10 +578,8 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent, zlog_debug ("Delayed acknowledgement (BDR & MoreRecent & from DR)"); /* Delayed acknowledgement */ ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list); - if (oi->thread_send_lsack == NULL) - oi->thread_send_lsack = - thread_add_timer(master, ospf6_lsack_send_interface, oi, 3, - NULL); + thread_add_timer(master, ospf6_lsack_send_interface, oi, 3, + &oi->thread_send_lsack); } else { @@ -604,10 +601,8 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent, zlog_debug ("Delayed acknowledgement (BDR & Duplicate & ImpliedAck & from DR)"); /* Delayed acknowledgement */ ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list); - if (oi->thread_send_lsack == NULL) - oi->thread_send_lsack = - thread_add_timer(master, ospf6_lsack_send_interface, oi, 3, - NULL); + thread_add_timer(master, ospf6_lsack_send_interface, oi, 3, + &oi->thread_send_lsack); } else { @@ -625,9 +620,8 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent, if (is_debug) zlog_debug ("Direct acknowledgement (BDR & Duplicate)"); ospf6_lsdb_add (ospf6_lsa_copy (lsa), from->lsack_list); - if (from->thread_send_lsack == NULL) - from->thread_send_lsack = - thread_add_event(master, ospf6_lsack_send_neighbor, from, 0, NULL); + thread_add_event(master, ospf6_lsack_send_neighbor, from, 0, + &from->thread_send_lsack); return; } @@ -669,9 +663,8 @@ ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent, zlog_debug ("Delayed acknowledgement (AllOther & MoreRecent)"); /* Delayed acknowledgement */ ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list); - if (oi->thread_send_lsack == NULL) - oi->thread_send_lsack = - thread_add_timer(master, ospf6_lsack_send_interface, oi, 3, NULL); + thread_add_timer(master, ospf6_lsack_send_interface, oi, 3, + &oi->thread_send_lsack); return; } @@ -693,9 +686,8 @@ ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent, if (is_debug) zlog_debug ("Direct acknowledgement (AllOther & Duplicate)"); ospf6_lsdb_add (ospf6_lsa_copy (lsa), from->lsack_list); - if (from->thread_send_lsack == NULL) - from->thread_send_lsack = - thread_add_event(master, ospf6_lsack_send_neighbor, from, 0, NULL); + thread_add_event(master, ospf6_lsack_send_neighbor, from, 0, + &from->thread_send_lsack); return; } @@ -832,9 +824,8 @@ ospf6_receive_lsa (struct ospf6_neighbor *from, /* a) Acknowledge back to neighbor (Direct acknowledgement, 13.5) */ ospf6_lsdb_add (ospf6_lsa_copy (new), from->lsack_list); - if (from->thread_send_lsack == NULL) - from->thread_send_lsack = - thread_add_event(master, ospf6_lsack_send_neighbor, from, 0, NULL); + thread_add_event(master, ospf6_lsack_send_neighbor, from, 0, + &from->thread_send_lsack); /* b) Discard */ ospf6_lsa_delete (new); @@ -916,8 +907,8 @@ ospf6_receive_lsa (struct ospf6_neighbor *from, zlog_debug ("Newer instance of the self-originated LSA"); zlog_debug ("Schedule reorigination"); } - new->refresh = thread_add_event(master, ospf6_lsa_refresh, new, 0, - NULL); + new->refresh = NULL; + thread_add_event(master, ospf6_lsa_refresh, new, 0, &new->refresh); } return; @@ -1003,10 +994,8 @@ ospf6_receive_lsa (struct ospf6_neighbor *from, /* XXX, MinLSArrival check !? RFC 2328 13 (8) */ ospf6_lsdb_add (ospf6_lsa_copy (old), from->lsupdate_list); - if (from->thread_send_lsupdate == NULL) - from->thread_send_lsupdate = - thread_add_event(master, ospf6_lsupdate_send_neighbor, from, 0, - NULL); + thread_add_event(master, ospf6_lsupdate_send_neighbor, from, 0, + &from->thread_send_lsupdate); ospf6_lsa_delete (new); return; } diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index d75b1098fa..758688c601 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -752,9 +752,10 @@ interface_up (struct thread *thread) /* Schedule Hello */ if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE) && - !if_is_loopback (oi->interface)) - oi->thread_send_hello = thread_add_event(master, ospf6_hello_send, oi, 0, - NULL); + !if_is_loopback (oi->interface)) { + oi->thread_send_hello = NULL; + thread_add_event(master, ospf6_hello_send, oi, 0, &oi->thread_send_hello); + } /* decide next interface state */ if ((if_is_pointopoint (oi->interface)) || @@ -1517,8 +1518,8 @@ DEFUN (no_ipv6_ospf6_passive, UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE); THREAD_OFF (oi->thread_send_hello); - oi->thread_send_hello = - thread_add_event(master, ospf6_hello_send, oi, 0, NULL); + oi->thread_send_hello = NULL; + thread_add_event(master, ospf6_hello_send, oi, 0, &oi->thread_send_hello); return CMD_SUCCESS; } diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c index 3ae368f1d0..a993869a91 100644 --- a/ospf6d/ospf6_lsa.c +++ b/ospf6d/ospf6_lsa.c @@ -722,8 +722,9 @@ ospf6_lsa_refresh (struct thread *thread) new = ospf6_lsa_create (self->header); new->lsdb = old->lsdb; - new->refresh = thread_add_timer(master, ospf6_lsa_refresh, new, - OSPF_LS_REFRESH_TIME, NULL); + new->refresh = NULL; + thread_add_timer(master, ospf6_lsa_refresh, new, OSPF_LS_REFRESH_TIME, + &new->refresh); /* store it in the LSDB for self-originated LSAs */ ospf6_lsdb_add (ospf6_lsa_copy (new), lsdb_self); diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c index 7ad3736d2a..6746b8104f 100644 --- a/ospf6d/ospf6_message.c +++ b/ospf6d/ospf6_message.c @@ -558,9 +558,11 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh, if (! CHECK_FLAG (dbdesc->bits, OSPF6_DBDESC_MBIT) && ! CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT)) thread_add_event (master, exchange_done, on, 0, NULL); - else - on->thread_send_dbdesc = - thread_add_event (master, ospf6_dbdesc_send_newone, on, 0, NULL); + else { + on->thread_send_dbdesc = NULL; + thread_add_event(master, ospf6_dbdesc_send_newone, on, 0, + &on->thread_send_dbdesc); + } /* save last received dbdesc */ memcpy (&on->dbdesc_last, dbdesc, sizeof (struct ospf6_dbdesc)); @@ -636,8 +638,9 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh, if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV)) zlog_debug ("Duplicated dbdesc causes retransmit"); THREAD_OFF (on->thread_send_dbdesc); - on->thread_send_dbdesc = - thread_add_event (master, ospf6_dbdesc_send, on, 0, NULL); + on->thread_send_dbdesc = NULL; + thread_add_event(master, ospf6_dbdesc_send, on, 0, + &on->thread_send_dbdesc); return; } @@ -1971,9 +1974,9 @@ ospf6_lsreq_send (struct thread *thread) /* set next thread */ if (on->request_list->count != 0) { - on->thread_send_lsreq = - thread_add_timer (master, ospf6_lsreq_send, on, - on->ospf6_if->rxmt_interval, NULL); + on->thread_send_lsreq = NULL; + thread_add_timer(master, ospf6_lsreq_send, on, on->ospf6_if->rxmt_interval, + &on->thread_send_lsreq); } return 0; @@ -2090,13 +2093,16 @@ ospf6_lsupdate_send_neighbor (struct thread *thread) on->ospf6_if, oh); } - if (on->lsupdate_list->count != 0) - on->thread_send_lsupdate = - thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0, NULL); - else if (on->retrans_list->count != 0) - on->thread_send_lsupdate = - thread_add_timer (master, ospf6_lsupdate_send_neighbor, on, - on->ospf6_if->rxmt_interval, NULL); + if (on->lsupdate_list->count != 0) { + on->thread_send_lsupdate = NULL; + thread_add_event(master, ospf6_lsupdate_send_neighbor, on, 0, + &on->thread_send_lsupdate); + } + else if (on->retrans_list->count != 0) { + on->thread_send_lsupdate = NULL; + thread_add_timer(master, ospf6_lsupdate_send_neighbor, on, on->ospf6_if->rxmt_interval, + &on->thread_send_lsupdate); + } return 0; } @@ -2171,8 +2177,9 @@ ospf6_lsupdate_send_interface (struct thread *thread) if (oi->lsupdate_list->count > 0) { - oi->thread_send_lsupdate = - thread_add_event (master, ospf6_lsupdate_send_interface, oi, 0, NULL); + oi->thread_send_lsupdate = NULL; + thread_add_event(master, ospf6_lsupdate_send_interface, oi, 0, + &oi->thread_send_lsupdate); } return 0; diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index 35ac40fc85..09d3a523a3 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -238,8 +238,9 @@ hello_received (struct thread *thread) /* reset Inactivity Timer */ THREAD_OFF (on->inactivity_timer); - on->inactivity_timer = thread_add_timer(master, inactivity_timer, on, - on->ospf6_if->dead_interval, NULL); + on->inactivity_timer = NULL; + thread_add_timer(master, inactivity_timer, on, on->ospf6_if->dead_interval, + &on->inactivity_timer); if (on->state <= OSPF6_NEIGHBOR_DOWN) ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on, @@ -278,8 +279,8 @@ twoway_received (struct thread *thread) SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT); THREAD_OFF (on->thread_send_dbdesc); - on->thread_send_dbdesc = - thread_add_event(master, ospf6_dbdesc_send, on, 0, NULL); + on->thread_send_dbdesc = NULL; + thread_add_event(master, ospf6_dbdesc_send, on, 0, &on->thread_send_dbdesc); return 0; } @@ -410,8 +411,9 @@ ospf6_check_nbr_loading (struct ospf6_neighbor *on) { if (on->thread_send_lsreq != NULL) THREAD_OFF (on->thread_send_lsreq); - on->thread_send_lsreq = - thread_add_event(master, ospf6_lsreq_send, on, 0, NULL); + on->thread_send_lsreq = NULL; + thread_add_event(master, ospf6_lsreq_send, on, 0, + &on->thread_send_lsreq); } } } @@ -459,8 +461,9 @@ adj_ok (struct thread *thread) SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT); THREAD_OFF (on->thread_send_dbdesc); - on->thread_send_dbdesc = - thread_add_event(master, ospf6_dbdesc_send, on, 0, NULL); + on->thread_send_dbdesc = NULL; + thread_add_event(master, ospf6_dbdesc_send, on, 0, + &on->thread_send_dbdesc); } else if (on->state >= OSPF6_NEIGHBOR_EXSTART && @@ -514,8 +517,8 @@ seqnumber_mismatch (struct thread *thread) THREAD_OFF (on->thread_send_dbdesc); on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */ - on->thread_send_dbdesc = - thread_add_event(master, ospf6_dbdesc_send, on, 0, NULL); + on->thread_send_dbdesc = NULL; + thread_add_event(master, ospf6_dbdesc_send, on, 0, &on->thread_send_dbdesc); return 0; } @@ -553,8 +556,8 @@ bad_lsreq (struct thread *thread) THREAD_OFF (on->thread_send_dbdesc); on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */ - on->thread_send_dbdesc = - thread_add_event(master, ospf6_dbdesc_send, on, 0, NULL); + on->thread_send_dbdesc = NULL; + thread_add_event(master, ospf6_dbdesc_send, on, 0, &on->thread_send_dbdesc); return 0; } diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index 25a4226665..6a10ba7ad5 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -727,9 +727,9 @@ ospf6_spf_schedule (struct ospf6 *ospf6, unsigned int reason) zlog_info ("SPF: Scheduled in %ld msec", delay); - ospf6->t_spf_calc = - thread_add_timer_msec(master, ospf6_spf_calculation_thread, ospf6, delay, - NULL); + ospf6->t_spf_calc = NULL; + thread_add_timer_msec(master, ospf6_spf_calculation_thread, ospf6, delay, + &ospf6->t_spf_calc); } void diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index fbb3316ba3..85f7e0ce3a 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -286,10 +286,9 @@ ospf6_maxage_remover (struct thread *thread) void ospf6_maxage_remove (struct ospf6 *o) { - if (o && ! o->maxage_remover) - o->maxage_remover = thread_add_timer(master, ospf6_maxage_remover, o, - OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT, - NULL); + if (o) + thread_add_timer(master, ospf6_maxage_remover, o, OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT, + &o->maxage_remover); } /* start ospf6 */ diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index 5c514e18f8..633b22346d 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -304,30 +304,24 @@ ospf_apiserver_event (enum event event, int fd, (void) thread_add_read(master, ospf_apiserver_accept, apiserv, fd, NULL); break; case OSPF_APISERVER_SYNC_READ: - apiserv->t_sync_read = - thread_add_read(master, ospf_apiserver_read, apiserv, fd, NULL); + apiserv->t_sync_read = NULL; + thread_add_read(master, ospf_apiserver_read, apiserv, fd, + &apiserv->t_sync_read); break; #ifdef USE_ASYNC_READ case OSPF_APISERVER_ASYNC_READ: - apiserv->t_async_read = - thread_add_read(master, ospf_apiserver_read, apiserv, fd, NULL); + apiserv->t_async_read = NULL; + thread_add_read(master, ospf_apiserver_read, apiserv, fd, + &apiserv->t_async_read); break; #endif /* USE_ASYNC_READ */ case OSPF_APISERVER_SYNC_WRITE: - if (!apiserv->t_sync_write) - { - apiserv->t_sync_write = - thread_add_write(master, ospf_apiserver_sync_write, apiserv, fd, - NULL); - } + thread_add_write(master, ospf_apiserver_sync_write, apiserv, fd, + &apiserv->t_sync_write); break; case OSPF_APISERVER_ASYNC_WRITE: - if (!apiserv->t_async_write) - { - apiserv->t_async_write = - thread_add_write(master, ospf_apiserver_async_write, apiserv, fd, - NULL); - } + thread_add_write(master, ospf_apiserver_async_write, apiserv, fd, + &apiserv->t_async_write); break; } } diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 570e151764..9067acb7f5 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -3741,9 +3741,9 @@ ospf_lsa_refresh_walker (struct thread *t) } } - ospf->t_lsa_refresher = thread_add_timer(master, ospf_lsa_refresh_walker, - ospf, ospf->lsa_refresh_interval, - NULL); + ospf->t_lsa_refresher = NULL; + thread_add_timer(master, ospf_lsa_refresh_walker, ospf, ospf->lsa_refresh_interval, + &ospf->t_lsa_refresher); ospf->lsa_refresher_started = monotime(NULL); for (ALL_LIST_ELEMENTS (lsa_to_refresh, node, nnode, lsa)) diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index 0c1830166f..af22d0f29a 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -1342,9 +1342,9 @@ ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi, int *delay0) { if (IS_DEBUG_OSPF_EVENT) zlog_debug ("Schedule Type-9 Opaque-LSA origination in %d ms later.", delay); - oi->t_opaque_lsa_self = - thread_add_timer_msec(master, ospf_opaque_type9_lsa_originate, oi, - delay, NULL); + oi->t_opaque_lsa_self = NULL; + thread_add_timer_msec(master, ospf_opaque_type9_lsa_originate, oi, delay, + &oi->t_opaque_lsa_self); delay += top->min_ls_interval; } @@ -1359,9 +1359,9 @@ ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi, int *delay0) */ if (IS_DEBUG_OSPF_EVENT) zlog_debug ("Schedule Type-10 Opaque-LSA origination in %d ms later.", delay); - area->t_opaque_lsa_self = - thread_add_timer_msec(master, ospf_opaque_type10_lsa_originate, area, - delay, NULL); + area->t_opaque_lsa_self = NULL; + thread_add_timer_msec(master, ospf_opaque_type10_lsa_originate, area, delay, + &area->t_opaque_lsa_self); delay += top->min_ls_interval; } @@ -1376,9 +1376,9 @@ ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi, int *delay0) */ if (IS_DEBUG_OSPF_EVENT) zlog_debug ("Schedule Type-11 Opaque-LSA origination in %d ms later.", delay); - top->t_opaque_lsa_self = - thread_add_timer_msec(master, ospf_opaque_type11_lsa_originate, top, - delay, NULL); + top->t_opaque_lsa_self = NULL; + thread_add_timer_msec(master, ospf_opaque_type11_lsa_originate, top, delay, + &top->t_opaque_lsa_self); delay += top->min_ls_interval; } diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 6b5b0e4edd..8446ebcea7 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -487,7 +487,8 @@ ospf_ls_req_event (struct ospf_neighbor *nbr) thread_cancel (nbr->t_ls_req); nbr->t_ls_req = NULL; } - nbr->t_ls_req = thread_add_event(master, ospf_ls_req_timer, nbr, 0, NULL); + nbr->t_ls_req = NULL; + thread_add_event(master, ospf_ls_req_timer, nbr, 0, &nbr->t_ls_req); } /* Cyclic timer function. Fist registered in ospf_nbr_new () in @@ -850,9 +851,10 @@ ospf_write (struct thread *thread) } /* If packets still remain in queue, call write thread. */ - if (!list_isempty (ospf->oi_write_q)) - ospf->t_write = - thread_add_write(master, ospf_write, ospf, ospf->fd, NULL); + if (!list_isempty (ospf->oi_write_q)) { + ospf->t_write = NULL; + thread_add_write(master, ospf_write, ospf, ospf->fd, &ospf->t_write); + } return 0; } @@ -2772,7 +2774,8 @@ ospf_read (struct thread *thread) ospf = THREAD_ARG (thread); /* prepare for next packet. */ - ospf->t_read = thread_add_read(master, ospf_read, ospf, ospf->fd, NULL); + ospf->t_read = NULL; + thread_add_read(master, ospf_read, ospf, ospf->fd, &ospf->t_read); stream_reset(ospf->ibuf); if (!(ibuf = ospf_recv_packet (ospf->fd, &ifp, ospf->ibuf))) @@ -3802,8 +3805,9 @@ ospf_ls_upd_send_queue_event (struct thread *thread) if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_ls_upd_send_queue: update lists not cleared," " %d nodes to try again, raising new event", again); - oi->t_ls_upd_event = - thread_add_event(master, ospf_ls_upd_send_queue_event, oi, 0, NULL); + oi->t_ls_upd_event = NULL; + thread_add_event(master, ospf_ls_upd_send_queue_event, oi, 0, + &oi->t_ls_upd_event); } if (IS_DEBUG_OSPF_EVENT) diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index d54ebc8b43..3d8d7f8e03 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -1464,6 +1464,7 @@ ospf_spf_calculate_schedule (struct ospf *ospf, ospf_spf_reason_t reason) zlog_info ("SPF: Scheduled in %ld msec", delay); - ospf->t_spf_calc = - thread_add_timer_msec(master, ospf_spf_calculate_timer, ospf, delay, NULL); + ospf->t_spf_calc = NULL; + thread_add_timer_msec(master, ospf_spf_calculate_timer, ospf, delay, + &ospf->t_spf_calc); } diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 314c9e72b4..c22793a098 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -1278,9 +1278,9 @@ ospf_distribute_list_update (struct ospf *ospf, uintptr_t type, return; /* Set timer. */ - ospf->t_distribute_update = - thread_add_timer_msec(master, ospf_distribute_list_update_timer, - (void *)type, ospf->min_ls_interval, NULL); + ospf->t_distribute_update = NULL; + thread_add_timer_msec(master, ospf_distribute_list_update_timer, (void *)type, ospf->min_ls_interval, + &ospf->t_distribute_update); } /* If access-list is updated, apply some check. */ diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 40f35c6d33..0c3230d367 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -264,18 +264,18 @@ ospf_new (u_short instance) /* MaxAge init. */ new->maxage_delay = OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT; new->maxage_lsa = route_table_init(); - new->t_maxage_walker = - thread_add_timer(master, ospf_lsa_maxage_walker, new, - OSPF_LSA_MAXAGE_CHECK_INTERVAL, NULL); + new->t_maxage_walker = NULL; + thread_add_timer(master, ospf_lsa_maxage_walker, new, OSPF_LSA_MAXAGE_CHECK_INTERVAL, + &new->t_maxage_walker); /* Distance table init. */ new->distance_table = route_table_init (); new->lsa_refresh_queue.index = 0; new->lsa_refresh_interval = OSPF_LSA_REFRESH_INTERVAL_DEFAULT; - new->t_lsa_refresher = thread_add_timer(master, ospf_lsa_refresh_walker, - new, new->lsa_refresh_interval, - NULL); + new->t_lsa_refresher = NULL; + thread_add_timer(master, ospf_lsa_refresh_walker, new, new->lsa_refresh_interval, + &new->t_lsa_refresher); new->lsa_refresher_started = monotime(NULL); if ((new->fd = ospf_sock_init()) < 0) @@ -290,7 +290,8 @@ ospf_new (u_short instance) OSPF_MAX_PACKET_SIZE+1); exit(1); } - new->t_read = thread_add_read(master, ospf_read, new, new->fd, NULL); + new->t_read = NULL; + thread_add_read(master, ospf_read, new, new->fd, &new->t_read); new->oi_write_q = list_new (); new->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; @@ -1594,9 +1595,8 @@ ospf_timers_refresh_set (struct ospf *ospf, int interval) if (time_left > interval) { OSPF_TIMER_OFF (ospf->t_lsa_refresher); - ospf->t_lsa_refresher = - thread_add_timer(master, ospf_lsa_refresh_walker, ospf, interval, - NULL); + thread_add_timer(master, ospf_lsa_refresh_walker, ospf, interval, + &ospf->t_lsa_refresher); } ospf->lsa_refresh_interval = interval; @@ -1614,9 +1614,9 @@ ospf_timers_refresh_unset (struct ospf *ospf) if (time_left > OSPF_LSA_REFRESH_INTERVAL_DEFAULT) { OSPF_TIMER_OFF (ospf->t_lsa_refresher); - ospf->t_lsa_refresher = - thread_add_timer(master, ospf_lsa_refresh_walker, ospf, - OSPF_LSA_REFRESH_INTERVAL_DEFAULT, NULL); + ospf->t_lsa_refresher = NULL; + thread_add_timer(master, ospf_lsa_refresh_walker, ospf, OSPF_LSA_REFRESH_INTERVAL_DEFAULT, + &ospf->t_lsa_refresher); } ospf->lsa_refresh_interval = OSPF_LSA_REFRESH_INTERVAL_DEFAULT; diff --git a/pimd/pim_msdp_socket.c b/pimd/pim_msdp_socket.c index b09dd635a0..8ceddfa39d 100644 --- a/pimd/pim_msdp_socket.c +++ b/pimd/pim_msdp_socket.c @@ -70,8 +70,9 @@ pim_msdp_sock_accept(struct thread *thread) zlog_err ("accept_sock is negative value %d", accept_sock); return -1; } - listener->thread = thread_add_read(master, pim_msdp_sock_accept, listener, - accept_sock, NULL); + listener->thread = NULL; + thread_add_read(master, pim_msdp_sock_accept, listener, accept_sock, + &listener->thread); /* accept client connection. */ msdp_sock = sockunion_accept(accept_sock, &su); @@ -173,8 +174,9 @@ pim_msdp_sock_listen(void) /* add accept thread */ listener->fd = sock; memcpy(&listener->su, &sin, socklen); - listener->thread = thread_add_read(msdp->master, pim_msdp_sock_accept, - listener, sock, NULL); + listener->thread = NULL; + thread_add_read(msdp->master, pim_msdp_sock_accept, listener, sock, + &listener->thread); msdp->flags |= PIM_MSDPF_LISTENER; return 0; diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index 01632182df..16dbb3ef56 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -88,9 +88,8 @@ static void zclient_lookup_sched(struct zclient *zlookup, int delay) static void zclient_lookup_sched_now(struct zclient *zlookup) { zassert(!zlookup->t_connect); - - zlookup->t_connect = thread_add_event(master, zclient_lookup_connect, - zlookup, 0, NULL); + thread_add_event(master, zclient_lookup_connect, zlookup, 0, + &zlookup->t_connect); zlog_notice("%s: zclient lookup immediate connection scheduled", __PRETTY_FUNCTION__); diff --git a/ripd/rip_peer.c b/ripd/rip_peer.c index f907f43f4b..2477740b9b 100644 --- a/ripd/rip_peer.c +++ b/ripd/rip_peer.c @@ -107,8 +107,9 @@ rip_peer_get (struct in_addr *addr) } /* Update timeout thread. */ - peer->t_timeout = thread_add_timer(master, rip_peer_timeout, peer, - RIP_PEER_TIMER_DEFAULT, NULL); + peer->t_timeout = NULL; + thread_add_timer(master, rip_peer_timeout, peer, RIP_PEER_TIMER_DEFAULT, + &peer->t_timeout); /* Last update time set. */ time (&peer->uptime); diff --git a/ripd/ripd.c b/ripd/ripd.c index 24bb48381e..e9e83a1c7f 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -2625,8 +2625,9 @@ rip_triggered_update (struct thread *t) update is triggered when the timer expires. */ interval = (random () % 5) + 1; - rip->t_triggered_interval = - thread_add_timer(master, rip_triggered_interval, NULL, interval, NULL); + rip->t_triggered_interval = NULL; + thread_add_timer(master, rip_triggered_interval, NULL, interval, + &rip->t_triggered_interval); return 0; } @@ -2781,18 +2782,18 @@ rip_event (enum rip_event event, int sock) switch (event) { case RIP_READ: - rip->t_read = thread_add_read(master, rip_read, NULL, sock, NULL); + rip->t_read = NULL; + thread_add_read(master, rip_read, NULL, sock, &rip->t_read); break; case RIP_UPDATE_EVENT: RIP_TIMER_OFF (rip->t_update); jitter = rip_update_jitter (rip->update_time); - rip->t_update = - thread_add_timer(master, rip_update, NULL, - sock ? 2 : rip->update_time + jitter, NULL); + thread_add_timer(master, rip_update, NULL, sock ? 2 : rip->update_time + jitter, + &rip->t_update); break; case RIP_TRIGGERED_UPDATE: if (rip->t_triggered_interval) - rip->trigger = 1; + rip->trigger = 1; else thread_add_event(master, rip_triggered_update, NULL, 0, &rip->t_triggered_update); break; diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c index 61f7b7b9df..69af4f214f 100644 --- a/ripngd/ripng_peer.c +++ b/ripngd/ripng_peer.c @@ -115,8 +115,9 @@ ripng_peer_get (struct in6_addr *addr) } /* Update timeout thread. */ - peer->t_timeout = thread_add_timer(master, ripng_peer_timeout, peer, - RIPNG_PEER_TIMER_DEFAULT, NULL); + peer->t_timeout = NULL; + thread_add_timer(master, ripng_peer_timeout, peer, RIPNG_PEER_TIMER_DEFAULT, + &peer->t_timeout); /* Last update time set. */ time (&peer->uptime); diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 11334339ab..e65d0b1607 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -1539,8 +1539,9 @@ ripng_triggered_update (struct thread *t) update is triggered when the timer expires. */ interval = (random () % 5) + 1; - ripng->t_triggered_interval = - thread_add_timer(master, ripng_triggered_interval, NULL, interval, NULL); + ripng->t_triggered_interval = NULL; + thread_add_timer(master, ripng_triggered_interval, NULL, interval, + &ripng->t_triggered_interval); return 0; } @@ -1909,9 +1910,9 @@ ripng_event (enum ripng_event event, int sock) /* Update timer jitter. */ jitter = ripng_update_jitter (ripng->update_time); - ripng->t_update = - thread_add_timer(master, ripng_update, NULL, - sock ? 2 : ripng->update_time + jitter, NULL); + ripng->t_update = NULL; + thread_add_timer(master, ripng_update, NULL, sock ? 2 : ripng->update_time + jitter, + &ripng->t_update); break; case RIPNG_TRIGGERED_UPDATE: if (ripng->t_triggered_interval) diff --git a/tests/lib/test_timer_correctness.c b/tests/lib/test_timer_correctness.c index 600aef6f46..b0643b907b 100644 --- a/tests/lib/test_timer_correctness.c +++ b/tests/lib/test_timer_correctness.c @@ -139,8 +139,9 @@ int main(int argc, char **argv) /* Schedule timers to expire in 0..5 seconds */ interval_msec = prng_rand(prng) % 5000; arg = XMALLOC(MTYPE_TMP, TIMESTR_LEN + 1); - timers[i] = thread_add_timer_msec(master, timer_func, arg, - interval_msec, NULL); + timers[i] = NULL; + thread_add_timer_msec(master, timer_func, arg, interval_msec, + &timers[i]); ret = snprintf(arg, TIMESTR_LEN + 1, "%lld.%06lld", (long long)timers[i]->u.sands.tv_sec, (long long)timers[i]->u.sands.tv_usec); diff --git a/tests/lib/test_timer_performance.c b/tests/lib/test_timer_performance.c index d1db4fd1bf..da0355f660 100644 --- a/tests/lib/test_timer_performance.c +++ b/tests/lib/test_timer_performance.c @@ -56,8 +56,10 @@ int main(int argc, char **argv) /* create thread structures so they won't be allocated during the * time measurement */ - for (i = 0; i < SCHEDULE_TIMERS; i++) - timers[i] = thread_add_timer_msec(master, dummy_func, NULL, 0, NULL); + for (i = 0; i < SCHEDULE_TIMERS; i++) { + timers[i] = NULL; + thread_add_timer_msec(master, dummy_func, NULL, 0, &timers[i]); + } for (i = 0; i < SCHEDULE_TIMERS; i++) thread_cancel(timers[i]); @@ -68,8 +70,9 @@ int main(int argc, char **argv) long interval_msec; interval_msec = prng_rand(prng) % (100 * SCHEDULE_TIMERS); - timers[i] = thread_add_timer_msec(master, dummy_func, NULL, - interval_msec, NULL); + timers[i] = NULL; + thread_add_timer_msec(master, dummy_func, NULL, interval_msec, + &timers[i]); } monotime(&tv_lap); diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c index 9676786333..4097cb4d66 100644 --- a/watchfrr/watchfrr.c +++ b/watchfrr/watchfrr.c @@ -373,8 +373,9 @@ static int restart_kill(struct thread *t_kill) (long)delay.tv_sec, (restart->kills ? SIGKILL : SIGTERM)); kill(-restart->pid, (restart->kills ? SIGKILL : SIGTERM)); restart->kills++; - restart->t_kill = thread_add_timer(master, restart_kill, restart, - gs.restart_timeout, NULL); + restart->t_kill = NULL; + thread_add_timer(master, restart_kill, restart, gs.restart_timeout, + &restart->t_kill); return 0; } @@ -487,9 +488,9 @@ run_job(struct restart_info *restart, const char *cmdtype, const char *command, char cmd[strlen(command) + strlen(restart->name) + 1]; snprintf(cmd, sizeof(cmd), command, restart->name); if ((restart->pid = run_background(cmd)) > 0) { - restart->t_kill = - thread_add_timer(master, restart_kill, restart, - gs.restart_timeout, NULL); + restart->t_kill = NULL; + thread_add_timer(master, restart_kill, restart, gs.restart_timeout, + &restart->t_kill); restart->what = cmdtype; gs.numpids++; } else @@ -510,19 +511,31 @@ run_job(struct restart_info *restart, const char *cmdtype, const char *command, } #define SET_READ_HANDLER(DMN) \ - (DMN)->t_read = thread_add_read(master,handle_read,(DMN),(DMN)->fd, NULL) - -#define SET_WAKEUP_DOWN(DMN) \ - (DMN)->t_wakeup = thread_add_timer_msec(master,wakeup_down,(DMN), \ - FUZZY(gs.period), NULL) - -#define SET_WAKEUP_UNRESPONSIVE(DMN) \ - (DMN)->t_wakeup = thread_add_timer_msec(master,wakeup_unresponsive,(DMN), \ - FUZZY(gs.period), NULL) + do { \ + (DMN)->t_read = NULL; \ + thread_add_read (master, handle_read, (DMN), (DMN)->fd, &(DMN)->t_read); \ + } while (0); + +#define SET_WAKEUP_DOWN(DMN) \ + do { \ + (DMN)->t_wakeup = NULL; \ + thread_add_timer_msec (master, wakeup_down, (DMN), FUZZY(gs.period), \ + &(DMN)->t_wakeup); \ + } while (0); + +#define SET_WAKEUP_UNRESPONSIVE(DMN) \ + do { \ + (DMN)->t_wakeup = NULL; \ + thread_add_timer_msec (master, wakeup_unresponsive, (DMN), \ + FUZZY(gs.period), &(DMN)->t_wakeup); \ + } while (0); #define SET_WAKEUP_ECHO(DMN) \ - (DMN)->t_wakeup = thread_add_timer_msec(master,wakeup_send_echo,(DMN), \ - FUZZY(gs.period), NULL) + do { \ + (DMN)->t_wakeup = NULL; \ + thread_add_timer_msec (master, wakeup_send_echo, (DMN), \ + FUZZY(gs.period), &(DMN)->t_wakeup); \ + } while (0); static int wakeup_down(struct thread *t_wakeup) { @@ -775,12 +788,11 @@ static int try_connect(struct daemon *dmn) zlog_debug("%s: connection in progress", dmn->name); dmn->state = DAEMON_CONNECTING; dmn->fd = sock; - dmn->t_write = - thread_add_write(master, check_connect, dmn, dmn->fd, - NULL); - dmn->t_wakeup = - thread_add_timer(master, wakeup_connect_hanging, dmn, - gs.timeout, NULL); + dmn->t_write = NULL; + thread_add_write(master, check_connect, dmn, dmn->fd, + &dmn->t_write);dmn->t_wakeup = NULL; + thread_add_timer(master, wakeup_connect_hanging, dmn, gs.timeout, + &dmn->t_wakeup); SET_READ_HANDLER(dmn); return 0; } @@ -805,8 +817,9 @@ 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 = thread_add_timer(master, phase_hanging, NULL, - PHASE_TIMEOUT, NULL); + gs.t_phase_hanging = NULL; + thread_add_timer(master, phase_hanging, NULL, PHASE_TIMEOUT, + &gs.t_phase_hanging); } static void phase_check(void) @@ -963,9 +976,9 @@ static int wakeup_send_echo(struct thread *t_wakeup) daemon_down(dmn, why); } else { gettimeofday(&dmn->echo_sent, NULL); - dmn->t_wakeup = - thread_add_timer(master, wakeup_no_answer, dmn, - gs.timeout, NULL); + dmn->t_wakeup = NULL; + thread_add_timer(master, wakeup_no_answer, dmn, gs.timeout, + &dmn->t_wakeup); } return 0; } @@ -1312,10 +1325,9 @@ int main(int argc, char **argv) gs.numdaemons++; gs.numdown++; dmn->fd = -1; - dmn->t_wakeup = - thread_add_timer_msec(master, wakeup_init, dmn, - 100 + (random() % 900), - NULL); + dmn->t_wakeup = NULL; + thread_add_timer_msec(master, wakeup_init, dmn, 100 + (random() % 900), + &dmn->t_wakeup); dmn->restart.interval = gs.min_restart_interval; if (tail) tail->next = dmn; diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c index cb0cb349de..21f8beadf2 100644 --- a/zebra/irdp_interface.c +++ b/zebra/irdp_interface.c @@ -259,8 +259,9 @@ irdp_if_start(struct interface *ifp, int multicast, int set_defaults) ifp->name, timer); - irdp->t_advertise = thread_add_timer(zebrad.master, irdp_send_thread, ifp, - timer, NULL); + irdp->t_advertise = NULL; + thread_add_timer(zebrad.master, irdp_send_thread, ifp, timer, + &irdp->t_advertise); } static void diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c index 963c330af4..5c17570f05 100644 --- a/zebra/irdp_main.c +++ b/zebra/irdp_main.c @@ -114,7 +114,8 @@ irdp_sock_init (void) return ret; }; - t_irdp_raw = thread_add_read(zebrad.master, irdp_read_raw, NULL, sock, NULL); + t_irdp_raw = NULL; + thread_add_read(zebrad.master, irdp_read_raw, NULL, sock, &t_irdp_raw); return sock; } @@ -244,8 +245,9 @@ int irdp_send_thread(struct thread *t_advert) if(irdp->flags & IF_DEBUG_MISC) zlog_debug("IRDP: New timer for %s set to %u\n", ifp->name, timer); - irdp->t_advertise = thread_add_timer(zebrad.master, irdp_send_thread, ifp, - timer, NULL); + irdp->t_advertise = NULL; + thread_add_timer(zebrad.master, irdp_send_thread, ifp, timer, + &irdp->t_advertise); return 0; } @@ -297,8 +299,9 @@ void process_solicit (struct interface *ifp) timer = (random () % MAX_RESPONSE_DELAY) + 1; - irdp->t_advertise = thread_add_timer(zebrad.master, irdp_send_thread, ifp, - timer, NULL); + irdp->t_advertise = NULL; + thread_add_timer(zebrad.master, irdp_send_thread, ifp, timer, + &irdp->t_advertise); } void irdp_finish() diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c index ecca40393f..269d4c0449 100644 --- a/zebra/irdp_packet.c +++ b/zebra/irdp_packet.c @@ -232,8 +232,8 @@ int irdp_read_raw(struct thread *r) int ret, ifindex = 0; int irdp_sock = THREAD_FD (r); - t_irdp_raw = thread_add_read(zebrad.master, irdp_read_raw, NULL, irdp_sock, - NULL); + t_irdp_raw = NULL; + thread_add_read(zebrad.master, irdp_read_raw, NULL, irdp_sock, &t_irdp_raw); ret = irdp_recvmsg (irdp_sock, (u_char *) buf, IRDP_RX_BUF, &ifindex); diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c index 59a280f826..763cd4adda 100644 --- a/zebra/kernel_netlink.c +++ b/zebra/kernel_netlink.c @@ -283,8 +283,9 @@ kernel_read (struct thread *thread) { struct zebra_ns *zns = (struct zebra_ns *)THREAD_ARG (thread); netlink_parse_info (netlink_information_fetch, &zns->netlink, zns, 5, 0); - zns->t_netlink = thread_add_read(zebrad.master, kernel_read, zns, - zns->netlink.sock, NULL); + zns->t_netlink = NULL; + thread_add_read(zebrad.master, kernel_read, zns, zns->netlink.sock, + &zns->t_netlink); return 0; } @@ -813,8 +814,9 @@ kernel_init (struct zebra_ns *zns) netlink_recvbuf (&zns->netlink, nl_rcvbufsize); netlink_install_filter (zns->netlink.sock, zns->netlink_cmd.snl.nl_pid); - zns->t_netlink = thread_add_read(zebrad.master, kernel_read, zns, - zns->netlink.sock, NULL); + zns->t_netlink = NULL; + thread_add_read(zebrad.master, kernel_read, zns, zns->netlink.sock, + &zns->t_netlink); } } diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 281672c9ad..e8fa6e116c 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -565,9 +565,9 @@ 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 = thread_add_background(zfpm_g->master, - zfpm_conn_up_thread_cb, 0, 0, - NULL); + zfpm_g->t_conn_up = NULL; + thread_add_background(zfpm_g->master, zfpm_conn_up_thread_cb, 0, 0, + &zfpm_g->t_conn_up); return 0; } @@ -599,9 +599,9 @@ zfpm_connection_up (const char *detail) zfpm_rnodes_iter_init (&zfpm_g->t_conn_up_state.iter); zfpm_debug ("Starting conn_up thread"); - zfpm_g->t_conn_up = thread_add_background(zfpm_g->master, - zfpm_conn_up_thread_cb, 0, 0, - NULL); + zfpm_g->t_conn_up = NULL; + thread_add_background(zfpm_g->master, zfpm_conn_up_thread_cb, 0, 0, + &zfpm_g->t_conn_up); zfpm_g->stats.t_conn_up_starts++; } @@ -690,9 +690,9 @@ 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 = thread_add_background(zfpm_g->master, - zfpm_conn_down_thread_cb, 0, - 0, NULL); + zfpm_g->t_conn_down = NULL; + thread_add_background(zfpm_g->master, zfpm_conn_down_thread_cb, 0, 0, + &zfpm_g->t_conn_down); return 0; } @@ -738,9 +738,9 @@ zfpm_connection_down (const char *detail) assert (!zfpm_g->t_conn_down); zfpm_debug ("Starting conn_down thread"); zfpm_rnodes_iter_init (&zfpm_g->t_conn_down_state.iter); - zfpm_g->t_conn_down = thread_add_background(zfpm_g->master, - zfpm_conn_down_thread_cb, 0, 0, - NULL); + zfpm_g->t_conn_down = NULL; + thread_add_background(zfpm_g->master, zfpm_conn_down_thread_cb, 0, 0, + &zfpm_g->t_conn_down); zfpm_g->stats.t_conn_down_starts++; zfpm_set_state (ZFPM_STATE_IDLE, detail); diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 85f3efae8e..4141cdd907 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -182,13 +182,14 @@ zebra_ptm_flush_messages (struct thread *thread) close(ptm_cb.ptm_sock); ptm_cb.ptm_sock = -1; zebra_ptm_reset_status(0); - ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect, - NULL, ptm_cb.reconnect_time, NULL); + ptm_cb.t_timer = NULL; + thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time, + &ptm_cb.t_timer); return (-1); case BUFFER_PENDING: - ptm_cb.t_write = thread_add_write(zebrad.master, - zebra_ptm_flush_messages, NULL, - ptm_cb.ptm_sock, NULL); + ptm_cb.t_write = NULL; + thread_add_write(zebrad.master, zebra_ptm_flush_messages, NULL, ptm_cb.ptm_sock, + &ptm_cb.t_write); break; case BUFFER_EMPTY: break; @@ -208,8 +209,9 @@ zebra_ptm_send_message(char *data, int size) close(ptm_cb.ptm_sock); ptm_cb.ptm_sock = -1; zebra_ptm_reset_status(0); - ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect, - NULL, ptm_cb.reconnect_time, NULL); + ptm_cb.t_timer = NULL; + thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time, + &ptm_cb.t_timer); return -1; case BUFFER_EMPTY: THREAD_OFF(ptm_cb.t_write); @@ -235,8 +237,9 @@ zebra_ptm_connect (struct thread *t) if (ptm_cb.ptm_sock != -1) { if (init) { - ptm_cb.t_read = thread_add_read(zebrad.master, zebra_ptm_sock_read, - NULL, ptm_cb.ptm_sock, NULL); + ptm_cb.t_read = NULL; + thread_add_read(zebrad.master, zebra_ptm_sock_read, NULL, ptm_cb.ptm_sock, + &ptm_cb.t_read); zebra_bfd_peer_replay_req(); } zebra_ptm_send_status_req(); @@ -246,8 +249,9 @@ zebra_ptm_connect (struct thread *t) if (ptm_cb.reconnect_time > ZEBRA_PTM_RECONNECT_TIME_MAX) ptm_cb.reconnect_time = ZEBRA_PTM_RECONNECT_TIME_MAX; - ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, - ptm_cb.reconnect_time, NULL); + ptm_cb.t_timer = NULL; + thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time, + &ptm_cb.t_timer); } else if (ptm_cb.reconnect_time >= ZEBRA_PTM_RECONNECT_TIME_MAX){ ptm_cb.reconnect_time = ZEBRA_PTM_RECONNECT_TIME_INITIAL; } @@ -654,14 +658,16 @@ zebra_ptm_sock_read (struct thread *thread) close (ptm_cb.ptm_sock); ptm_cb.ptm_sock = -1; zebra_ptm_reset_status(0); - ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect, - NULL, ptm_cb.reconnect_time, NULL); + ptm_cb.t_timer = NULL; + thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time, + &ptm_cb.t_timer); return (-1); } } - ptm_cb.t_read = thread_add_read(zebrad.master, zebra_ptm_sock_read, NULL, - ptm_cb.ptm_sock, NULL); + ptm_cb.t_read = NULL; + thread_add_read(zebrad.master, zebra_ptm_sock_read, NULL, ptm_cb.ptm_sock, + &ptm_cb.t_read); return 0; } @@ -698,8 +704,9 @@ zebra_ptm_bfd_dst_register (struct zserv *client, int sock, u_short length, if (ptm_cb.ptm_sock == -1) { - ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect, - NULL, ptm_cb.reconnect_time, NULL); + ptm_cb.t_timer = NULL; + thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time, + &ptm_cb.t_timer); return -1; } @@ -855,8 +862,9 @@ zebra_ptm_bfd_dst_deregister (struct zserv *client, int sock, u_short length, if (ptm_cb.ptm_sock == -1) { - ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect, - NULL, ptm_cb.reconnect_time, NULL); + ptm_cb.t_timer = NULL; + thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time, + &ptm_cb.t_timer); return -1; } @@ -977,8 +985,9 @@ zebra_ptm_bfd_client_register (struct zserv *client, int sock, u_short length) if (ptm_cb.ptm_sock == -1) { - ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect, - NULL, ptm_cb.reconnect_time, NULL); + ptm_cb.t_timer = NULL; + thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time, + &ptm_cb.t_timer); return -1; } @@ -1027,8 +1036,9 @@ zebra_ptm_bfd_client_deregister (int proto) if (ptm_cb.ptm_sock == -1) { - ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect, - NULL, ptm_cb.reconnect_time, NULL); + ptm_cb.t_timer = NULL; + thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time, + &ptm_cb.t_timer); return; } diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 0b69475dae..1738b0b053 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -1403,10 +1403,11 @@ static void zebra_route_map_mark_update (const char *rmap_name) { /* rmap_update_timer of 0 means don't do route updates */ - if (zebra_rmap_update_timer && !zebra_t_rmap_update) - zebra_t_rmap_update = - thread_add_timer(zebrad.master, zebra_route_map_update_timer, NULL, - zebra_rmap_update_timer, NULL); + if (zebra_rmap_update_timer && !zebra_t_rmap_update) { + zebra_t_rmap_update = NULL; + thread_add_timer(zebrad.master, zebra_route_map_update_timer, NULL, zebra_rmap_update_timer, + &zebra_t_rmap_update); + } } static void diff --git a/zebra/zserv.c b/zebra/zserv.c index 86fea32621..142956bdcf 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -95,8 +95,9 @@ zserv_flush_data(struct thread *thread) client = NULL; break; case BUFFER_PENDING: - client->t_write = thread_add_write(zebrad.master, zserv_flush_data, - client, client->sock, NULL); + client->t_write = NULL; + thread_add_write(zebrad.master, zserv_flush_data, client, client->sock, + &client->t_write); break; case BUFFER_EMPTY: break; @@ -128,8 +129,9 @@ zebra_server_send_message(struct zserv *client) one do not check the return code. They do not allow for the possibility that an I/O error may have caused the client to be deleted. */ - client->t_suicide = thread_add_event(zebrad.master, zserv_delayed_close, - client, 0, NULL); + client->t_suicide = NULL; + thread_add_event(zebrad.master, zserv_delayed_close, client, 0, + &client->t_suicide); return -1; case BUFFER_EMPTY: THREAD_OFF(client->t_write); @@ -2591,8 +2593,9 @@ zebra_event (enum event event, int sock, struct zserv *client) thread_add_read(zebrad.master, zebra_accept, client, sock, NULL); break; case ZEBRA_READ: - client->t_read = - thread_add_read(zebrad.master, zebra_client_read, client, sock, NULL); + client->t_read = NULL; + thread_add_read(zebrad.master, zebra_client_read, client, sock, + &client->t_read); break; case ZEBRA_WRITE: /**/