]> git.proxmox.com Git - mirror_frr.git/commitdiff
*: remove THREAD_ON macros, add nullity check
authorQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 24 Apr 2017 22:33:25 +0000 (22:33 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 9 May 2017 20:44:19 +0000 (20:44 +0000)
The way thread.c is written, a caller who wishes to be able to cancel a
thread or avoid scheduling it twice must keep a reference to the thread.
Typically this is done with a long lived pointer whose value is checked
for null in order to know if the thread is currently scheduled.  The
check-and-schedule idiom is so common that several wrapper macros in
thread.h existed solely to provide it.

This patch removes those macros and adds a new parameter to all
thread_add_* functions which is a pointer to the struct thread * to
store the result of a scheduling call. If the value passed is non-null,
the thread will only be scheduled if the value is null. This helps with
consistency.

A Coccinelle spatch has been used to transform code of the form:

  if (t == NULL)
    t = thread_add_* (...)

to the form

  thread_add_* (..., &t)

The THREAD_ON macros have also been transformed to the underlying
thread.c calls.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
113 files changed:
bgpd/bgp_damp.c
bgpd/bgp_dump.c
bgpd/bgp_fsm.c
bgpd/bgp_fsm.h
bgpd/bgp_network.c
bgpd/bgp_route.c
bgpd/bgp_routemap.c
bgpd/bgp_updgrp.c
bgpd/bgp_updgrp_adv.c
bgpd/bgpd.c
bgpd/rfapi/rfapi_import.c
bgpd/rfapi/rfapi_monitor.c
bgpd/rfapi/rfapi_rib.c
bgpd/rfapi/vnc_export_bgp.c
isisd/isis_circuit.c
isisd/isis_dr.c
isisd/isis_dynhn.c
isisd/isis_events.c
isisd/isis_lsp.c
isisd/isis_pdu.c
isisd/isis_spf.c
isisd/isisd.c
ldpd/accept.c
ldpd/adjacency.c
ldpd/control.c
ldpd/interface.c
ldpd/lde.c
ldpd/lde_lib.c
ldpd/ldpd.c
ldpd/ldpe.c
ldpd/neighbor.c
ldpd/packet.c
lib/agentx.c
lib/sigevent.c
lib/smux.c
lib/spf_backoff.c
lib/systemd.c
lib/thread.c
lib/thread.h
lib/vty.c
lib/wheel.c
lib/workqueue.c
lib/zclient.c
nhrpd/netlink_arp.c
nhrpd/nhrp_cache.c
nhrpd/nhrp_event.c
nhrpd/nhrp_nhs.c
nhrpd/nhrp_packet.c
nhrpd/nhrp_peer.c
nhrpd/nhrp_shortcut.c
nhrpd/resolver.c
nhrpd/vici.c
ospf6d/ospf6_bfd.c
ospf6d/ospf6_flood.c
ospf6d/ospf6_interface.c
ospf6d/ospf6_intra.h
ospf6d/ospf6_lsa.c
ospf6d/ospf6_message.c
ospf6d/ospf6_neighbor.c
ospf6d/ospf6_spf.c
ospf6d/ospf6_top.c
ospf6d/ospf6d.c
ospfclient/ospfclient.c
ospfd/ospf_abr.c
ospfd/ospf_apiserver.c
ospfd/ospf_ase.c
ospfd/ospf_ism.h
ospfd/ospf_lsa.c
ospfd/ospf_nsm.h
ospfd/ospf_opaque.c
ospfd/ospf_packet.c
ospfd/ospf_spf.c
ospfd/ospf_zebra.c
ospfd/ospfd.c
ospfd/ospfd.h
pimd/pim_assert.c
pimd/pim_ifchannel.c
pimd/pim_igmp.c
pimd/pim_igmpv3.c
pimd/pim_mroute.c
pimd/pim_msdp.c
pimd/pim_msdp.h
pimd/pim_msdp_socket.c
pimd/pim_neighbor.c
pimd/pim_pim.c
pimd/pim_ssmpingd.c
pimd/pim_upstream.c
pimd/pim_zebra.c
pimd/pim_zlookup.c
ripd/rip_interface.c
ripd/rip_peer.c
ripd/ripd.c
ripd/ripd.h
ripngd/ripng_interface.c
ripngd/ripng_peer.c
ripngd/ripngd.c
ripngd/ripngd.h
tests/helpers/c/main.c
tests/lib/test_heavy_thread.c
tests/lib/test_timer_correctness.c
tests/lib/test_timer_performance.c
watchfrr/watchfrr.c
zebra/irdp_interface.c
zebra/irdp_main.c
zebra/irdp_packet.c
zebra/kernel_netlink.c
zebra/kernel_socket.c
zebra/label_manager.c
zebra/rtadv.c
zebra/zebra_fpm.c
zebra/zebra_ptm.c
zebra/zebra_routemap.c
zebra/zserv.c

index 168dbd0122f653fd1644e4de1efd154db5d0aced..333f58061feda0bc896c718b26d9b93cb4befc65 100644 (file)
@@ -117,7 +117,7 @@ bgp_reuse_timer (struct thread *t)
     
   damp->t_reuse = NULL;
   damp->t_reuse =
-    thread_add_timer (bm->master, bgp_reuse_timer, NULL, DELTA_REUSE);
+    thread_add_timer(bm->master, bgp_reuse_timer, NULL, DELTA_REUSE, NULL);
 
   t_now = bgp_clock ();
 
@@ -447,9 +447,8 @@ bgp_damp_enable (struct bgp *bgp, afi_t afi, safi_t safi, time_t half,
   bgp_damp_parameter_set (half, reuse, suppress, max);
 
   /* Register reuse timer.  */
-  if (! damp->t_reuse)
-    damp->t_reuse = 
-      thread_add_timer (bm->master, bgp_reuse_timer, NULL, DELTA_REUSE);
+  thread_add_timer(bm->master, bgp_reuse_timer, NULL, DELTA_REUSE,
+                   &damp->t_reuse);
 
   return 0;
 }
index 84ece4885001722c625b620a1833a48289513c6e..2e4520c19e9f447e0563ef5f873de94833df3c85 100644 (file)
@@ -171,14 +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);
+      bgp_dump->t_interval = thread_add_timer(bm->master,
+                                              bgp_dump_interval_func,
+                                              bgp_dump, interval, NULL);
     }
   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);
+      bgp_dump->t_interval = thread_add_event(bm->master,
+                                              bgp_dump_interval_func,
+                                              bgp_dump, 0, NULL);
     }
 
   return 0;
index b17888482489aacd11944cf0b532099ece4126dd..2d0349b6a404fdc3ad2314991730202a890bf65f 100644 (file)
@@ -808,9 +808,8 @@ bgp_maxmed_onstartup_begin (struct bgp *bgp)
   zlog_info ("Begin maxmed onstartup mode - timer %d seconds",
              bgp->v_maxmed_onstartup);
 
-  THREAD_TIMER_ON (bm->master, bgp->t_maxmed_onstartup,
-                   bgp_maxmed_onstartup_timer,
-                   bgp, bgp->v_maxmed_onstartup);
+  thread_add_timer(bm->master, bgp_maxmed_onstartup_timer, bgp,
+                   bgp->v_maxmed_onstartup, &bgp->t_maxmed_onstartup);
 
   if (!bgp->v_maxmed_admin)
     {
@@ -877,12 +876,12 @@ bgp_update_delay_begin (struct bgp *bgp)
     peer->update_delay_over = 0;
 
   /* Start the update-delay timer */
-  THREAD_TIMER_ON (bm->master, bgp->t_update_delay, bgp_update_delay_timer,
-                   bgp, bgp->v_update_delay);
+  thread_add_timer(bm->master, bgp_update_delay_timer, bgp,
+                   bgp->v_update_delay, &bgp->t_update_delay);
 
   if (bgp->v_establish_wait != bgp->v_update_delay)
-    THREAD_TIMER_ON (bm->master, bgp->t_establish_wait, bgp_establish_wait_timer,
-                     bgp, bgp->v_establish_wait);
+    thread_add_timer(bm->master, bgp_establish_wait_timer, bgp,
+                     bgp->v_establish_wait, &bgp->t_establish_wait);
 
   quagga_timestamp(3, bgp->update_delay_begin_time,
                    sizeof(bgp->update_delay_begin_time));
index 4d0b48f5296e8f47c6788e4a0e4dc0ae88ccd9ee..67ba387eb94261cbfbc52d7c5a10869073fd523c 100644 (file)
@@ -23,58 +23,58 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #define _QUAGGA_BGP_FSM_H
 
 /* Macro for BGP read, write and timer thread.  */
-#define BGP_READ_ON(T,F,V)                     \
-  do {                                         \
-    if (!(T) && (peer->status != Deleted))     \
-      THREAD_READ_ON(bm->master,T,F,peer,V);   \
+#define BGP_READ_ON(T,F,V) \
+  do { \
+    if ((peer->status != Deleted)) \
+      thread_add_read (bm->master,(F),peer,(V),&(T)); \
   } while (0)
 
-#define BGP_READ_OFF(T)                                \
-  do {                                         \
-    if (T)                                     \
-      THREAD_READ_OFF(T);                      \
+#define BGP_READ_OFF(T) \
+  do { \
+    if (T) \
+      THREAD_READ_OFF(T); \
   } while (0)
 
-#define BGP_WRITE_ON(T,F,V)                    \
-  do {                                         \
-    if (!(T) && (peer->status != Deleted))     \
-      THREAD_WRITE_ON(bm->master,(T),(F),peer,(V)); \
+#define BGP_WRITE_ON(T,F,V) \
+  do { \
+    if ((peer)->status != Deleted) \
+      thread_add_write (bm->master,(F),(peer),(V),&(T)); \
   } while (0)
 
-#define BGP_PEER_WRITE_ON(T,F,V, peer)                 \
-  do {                                                 \
-    if (!(T) && ((peer)->status != Deleted))           \
-      THREAD_WRITE_ON(bm->master,(T),(F),(peer),(V));  \
+#define BGP_PEER_WRITE_ON(T,F,V, peer) \
+  do { \
+    if ((peer)->status != Deleted) \
+      thread_add_write (bm->master,(F),(peer),(V),&(T)); \
   } while (0)
 
-#define BGP_WRITE_OFF(T)                       \
-  do {                                         \
-    if (T)                                     \
-      THREAD_WRITE_OFF(T);                     \
+#define BGP_WRITE_OFF(T) \
+  do { \
+    if (T) \
+      THREAD_WRITE_OFF(T); \
   } while (0)
 
-#define BGP_TIMER_ON(T,F,V)                    \
-  do {                                         \
-    if (!(T) && (peer->status != Deleted))     \
-      THREAD_TIMER_ON(bm->master,(T),(F),peer,(V)); \
+#define BGP_TIMER_ON(T,F,V) \
+  do { \
+    if ((peer->status != Deleted)) \
+      thread_add_timer (bm->master,(F),peer,(V),&(T)); \
   } while (0)
 
-#define BGP_TIMER_OFF(T)                       \
-  do {                                         \
-    if (T)                                     \
-      THREAD_TIMER_OFF(T);                     \
+#define BGP_TIMER_OFF(T) \
+  do { \
+    if (T) \
+      THREAD_TIMER_OFF(T); \
   } while (0)
 
-#define BGP_EVENT_ADD(P,E)                     \
-  do {                                         \
-    if ((P)->status != Deleted)                        \
-      thread_add_event (bm->master, bgp_event, (P), (E)); \
+#define BGP_EVENT_ADD(P,E) \
+  do { \
+    if ((P)->status != Deleted) \
+      thread_add_event (bm->master, bgp_event, (P), (E), NULL); \
   } while (0)
 
-#define BGP_EVENT_FLUSH(P)                     \
-  do {                                                 \
-    assert (peer);                             \
-    thread_cancel_event (bm->master, (P));             \
+#define BGP_EVENT_FLUSH(P) \
+  do { \
+    assert (peer); \
+    thread_cancel_event (bm->master, (P)); \
   } while (0)
 
 #define BGP_MSEC_JITTER 10
index 46ae882b2ec59e7cd40dd5e545c4fa50eed4c404..556b4bedc7d6a390273f5fb5cfddedbbd1df15fe 100644 (file)
@@ -297,7 +297,8 @@ 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);
+  listener->thread = thread_add_read(bm->master, bgp_accept, listener,
+                                     accept_sock, NULL);
 
   /* Accept client connection. */
   bgp_sock = sockunion_accept (accept_sock, &su);
@@ -704,7 +705,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);
+  listener->thread = thread_add_read(bm->master, bgp_accept, listener, sock,
+                                     NULL);
   listnode_add (bm->listen_sockets, listener);
 
   return 0;
index f327e34f2ac42bd39c5530ada904ea65e4375f6a..13b837a3f4d736b83802ec7478d5dc0d17f4d3c0 100644 (file)
@@ -2017,9 +2017,10 @@ bgp_process_main (struct work_queue *wq, void *data)
       if (!bgp->t_rmap_def_originate_eval)
         {
           bgp_lock (bgp);
-          THREAD_TIMER_ON(bm->master, bgp->t_rmap_def_originate_eval,
-                          update_group_refresh_default_originate_route_map,
-                          bgp, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER);
+          thread_add_timer(bm->master,
+                           update_group_refresh_default_originate_route_map,
+                           bgp, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER,
+                           &bgp->t_rmap_def_originate_eval);
         }
     }
 
@@ -3130,11 +3131,9 @@ bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
    * multiple peers and the announcement doesn't happen in the
    * vty context.
    */
-  THREAD_TIMER_MSEC_ON (bm->master, paf->t_announce_route,
-                       bgp_announce_route_timer_expired, paf,
-                        (subgrp->peer_count == 1) ?
-                       BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS :
-                       BGP_ANNOUNCE_ROUTE_DELAY_MS);
+  thread_add_timer_msec(bm->master, bgp_announce_route_timer_expired, paf,
+                        (subgrp->peer_count == 1) ? BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS : BGP_ANNOUNCE_ROUTE_DELAY_MS,
+                        &paf->t_announce_route);
 }
 
 /*
index 9b3a6a513ad5d1f65a70d5c9e1a5928aceb1d351..88f48cb90316f1e9f2970b3007b820f30c6dac1b 100644 (file)
@@ -3178,7 +3178,7 @@ bgp_route_map_mark_update (const char *rmap_name)
         {
           bm->t_rmap_update =
             thread_add_timer(bm->master, bgp_route_map_update_timer, NULL,
-                             bm->rmap_update_timer);
+                             bm->rmap_update_timer, NULL);
 
           /* Signal the groups that a route-map update event has started */
           for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
index 9e5ec4b26de64de285c1994e1749917025c51548..65b569c37f63d4971214e53206c0d0fae61a51a5 100644 (file)
@@ -1170,9 +1170,8 @@ update_subgroup_trigger_merge_check (struct update_subgroup *subgrp,
     return 0;
 
   subgrp->t_merge_check =
-    thread_add_background (bm->master,
-                          update_subgroup_merge_check_thread_cb,
-                          subgrp, 0);
+    thread_add_background(bm->master, update_subgroup_merge_check_thread_cb,
+                          subgrp, 0, NULL);
 
   SUBGRP_INCR_STAT (subgrp, merge_checks_triggered);
 
index ac5f77474c79b55c6946b9ac954d6f399e146e8f..3ed295825482093471dfe4412f2815143133c105 100644 (file)
@@ -828,8 +828,8 @@ subgroup_announce_all (struct update_subgroup *subgrp)
    */
   if (!subgrp->t_coalesce)
     {
-      THREAD_TIMER_MSEC_ON (bm->master, subgrp->t_coalesce, subgroup_coalesce_timer,
-                           subgrp, subgrp->v_coalesce);
+      thread_add_timer_msec(bm->master, subgroup_coalesce_timer, subgrp,
+                            subgrp->v_coalesce, &subgrp->t_coalesce);
     }
 }
 
index 1c73fb9407d9d78857076419ea3f9cc23d162c6b..f14d6f6862b3b5416ed15ea2ddc7a38869d118e8 100644 (file)
@@ -2967,8 +2967,8 @@ bgp_create (as_t *as, const char *name, enum bgp_instance_type inst_type)
   else
     {
       /* TODO - The startup timer needs to be run for the whole of BGP */
-      THREAD_TIMER_ON (bm->master, bgp->t_startup, bgp_startup_timer_expire,
-                       bgp, bgp->restart_time);
+      thread_add_timer(bm->master, bgp_startup_timer_expire, bgp,
+                       bgp->restart_time, &bgp->t_startup);
     }
 
   bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX;
index 4a05018d2358062e617f6e06ca33f1024a0d57a2..e91bc27ba0d2854f72cee6f1a194bb5bcb76138e 100644 (file)
@@ -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);
+      bi->extra->vnc.import.timer = thread_add_timer(bm->master,
+                                                     timer_service_func, wcb,
+                                                     lifetime, NULL);
     }
   else
     {
@@ -3051,10 +3051,10 @@ rfapiBiStartWithdrawTimer (
 
       lifetime_msec = (lifetime * 1000) + jitter;
 
-      bi->extra->vnc.import.timer = thread_add_background (bm->master,
-                                                           timer_service_func,
-                                                           wcb,
-                                                           lifetime_msec);
+      bi->extra->vnc.import.timer = thread_add_background(bm->master,
+                                                          timer_service_func,
+                                                          wcb, lifetime_msec,
+                                                          NULL);
     }
 
   /* re-sort route list (BGP_INFO_REMOVED routes are last) */
index a9e6e4f934f386d4048d82305758b21d345710f8..cd884a0adb744f9c0922f9a0ad7c5dd22d1358e5 100644 (file)
@@ -852,8 +852,8 @@ 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);
+  m->timer = thread_add_timer(bm->master, rfapiMonitorTimerExpire, m,
+                              m->rfd->response_lifetime, NULL);
 }
 
 /* 
@@ -1183,8 +1183,8 @@ 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);
+  m->timer = thread_add_timer(bm->master, rfapiMonitorEthTimerExpire, m,
+                              m->rfd->response_lifetime, NULL);
 }
 
 static int
index d633023dcf86e26cc60270569ef68a8a16b3d745..654da95a41c13f2229dfd9a92fbeae823eab5b15 100644 (file)
@@ -400,8 +400,8 @@ 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);
+  ri->timer = thread_add_timer(bm->master, rfapiRibExpireTimer, tcb,
+                               ri->lifetime, NULL);
   assert (ri->timer);
 }
 
index 9b2dc2582394c17fd099c93b7a628d576aebc643..fd97f2cd136b263b597d1dc8b070a08fe8df3061 100644 (file)
@@ -1856,9 +1856,8 @@ vnc_direct_bgp_rh_del_route (
 
   if (!eti->timer && eti->lifetime <= INT32_MAX)
     {
-      eti->timer = thread_add_timer (bm->master,
-                                     vncExportWithdrawTimer,
-                                     eti, eti->lifetime);
+      eti->timer = thread_add_timer(bm->master, vncExportWithdrawTimer, eti,
+                                    eti->lifetime, NULL);
       vnc_zlog_debug_verbose ("%s: set expiration timer for %u seconds",
                   __func__, eti->lifetime);
     }
index 6caf8200eeb14b0cbca81019e13f0cdcba0f6d15..190811bac45ce4676c8c2931308e5d564a6efe36 100644 (file)
@@ -607,11 +607,12 @@ void
 isis_circuit_prepare (struct isis_circuit *circuit)
 {
 #ifdef GNU_LINUX
-  THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
-                  circuit->fd);
+  thread_add_read(master, isis_receive, circuit, circuit->fd,
+                  &circuit->t_read);
 #else
-  THREAD_TIMER_MSEC_ON (master, circuit->t_read, isis_receive, circuit,
-                       listcount (circuit->area->circuit_list) * 100);
+  thread_add_timer_msec(master, isis_receive, circuit,
+                        listcount(circuit->area->circuit_list) * 100,
+                        &circuit->t_read);
 #endif
 }
 
@@ -672,13 +673,13 @@ isis_circuit_up (struct isis_circuit *circuit)
 
       if (circuit->is_type & IS_LEVEL_1)
         {
-          thread_add_event (master, send_lan_l1_hello, circuit, 0);
+          thread_add_event(master, send_lan_l1_hello, circuit, 0, NULL);
           circuit->u.bc.lan_neighs[0] = list_new ();
         }
 
       if (circuit->is_type & IS_LEVEL_2)
         {
-          thread_add_event (master, send_lan_l2_hello, circuit, 0);
+          thread_add_event(master, send_lan_l2_hello, circuit, 0, NULL);
           circuit->u.bc.lan_neighs[1] = list_new ();
         }
 
@@ -688,11 +689,13 @@ isis_circuit_up (struct isis_circuit *circuit)
       /* 8.4.1 d) */
       /* dr election will commence in... */
       if (circuit->is_type & IS_LEVEL_1)
-        THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
-            circuit, 2 * circuit->hello_interval[0]);
+        thread_add_timer(master, isis_run_dr_l1, circuit,
+                         2 * circuit->hello_interval[0],
+                         &circuit->u.bc.t_run_dr[0]);
       if (circuit->is_type & IS_LEVEL_2)
-        THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
-            circuit, 2 * circuit->hello_interval[1]);
+        thread_add_timer(master, isis_run_dr_l2, circuit,
+                         2 * circuit->hello_interval[1],
+                         &circuit->u.bc.t_run_dr[1]);
     }
   else
     {
@@ -700,17 +703,19 @@ isis_circuit_up (struct isis_circuit *circuit)
        * for a ptp IF
        */
       circuit->u.p2p.neighbor = NULL;
-      thread_add_event (master, send_p2p_hello, circuit, 0);
+      thread_add_event(master, send_p2p_hello, circuit, 0, NULL);
     }
 
   /* initializing PSNP timers */
   if (circuit->is_type & IS_LEVEL_1)
-    THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
-                     isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
+    thread_add_timer(master, send_l1_psnp, circuit,
+                     isis_jitter(circuit->psnp_interval[0], PSNP_JITTER),
+                     &circuit->t_send_psnp[0]);
 
   if (circuit->is_type & IS_LEVEL_2)
-    THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
-                     isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
+    thread_add_timer(master, send_l2_psnp, circuit,
+                     isis_jitter(circuit->psnp_interval[1], PSNP_JITTER),
+                     &circuit->t_send_psnp[1]);
 
   /* unified init for circuits; ignore warnings below this level */
   retv = isis_sock_init (circuit);
index bc6ec11962797b3000db9be37c1b630fa5c08aea..def6e3860e5f7388980f2553fc8a5b51a84f0093 100644 (file)
@@ -259,12 +259,13 @@ isis_dr_resign (struct isis_circuit *circuit, int level)
 
       THREAD_TIMER_OFF (circuit->t_send_csnp[0]);
 
-      THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
-                      circuit, 2 * circuit->hello_interval[0]);
+      thread_add_timer(master, isis_run_dr_l1, circuit,
+                       2 * circuit->hello_interval[0],
+                       &circuit->u.bc.t_run_dr[0]);
 
-      THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
-                      isis_jitter (circuit->psnp_interval[level - 1],
-                                   PSNP_JITTER));
+      thread_add_timer(master, send_l1_psnp, circuit,
+                       isis_jitter(circuit->psnp_interval[level - 1], PSNP_JITTER),
+                       &circuit->t_send_psnp[0]);
     }
   else
     {
@@ -272,15 +273,16 @@ isis_dr_resign (struct isis_circuit *circuit, int level)
 
       THREAD_TIMER_OFF (circuit->t_send_csnp[1]);
 
-      THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
-                      circuit, 2 * circuit->hello_interval[1]);
+      thread_add_timer(master, isis_run_dr_l2, circuit,
+                       2 * circuit->hello_interval[1],
+                       &circuit->u.bc.t_run_dr[1]);
 
-      THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
-                      isis_jitter (circuit->psnp_interval[level - 1],
-                                   PSNP_JITTER));
+      thread_add_timer(master, send_l2_psnp, circuit,
+                       isis_jitter(circuit->psnp_interval[level - 1], PSNP_JITTER),
+                       &circuit->t_send_psnp[1]);
     }
 
-  thread_add_event (master, isis_event_dis_status_change, circuit, 0);
+  thread_add_event(master, isis_event_dis_status_change, circuit, 0, NULL);
 
   return ISIS_OK;
 }
@@ -296,11 +298,13 @@ isis_dr_commence (struct isis_circuit *circuit, int level)
   /* Lets keep a pause in DR election */
   circuit->u.bc.run_dr_elect[level - 1] = 0;
   if (level == 1)
-    THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
-                    circuit, 2 * circuit->hello_interval[0]);
+    thread_add_timer(master, isis_run_dr_l1, circuit,
+                     2 * circuit->hello_interval[0],
+                     &circuit->u.bc.t_run_dr[0]);
   else
-    THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
-                    circuit, 2 * circuit->hello_interval[1]);
+    thread_add_timer(master, isis_run_dr_l2, circuit,
+                     2 * circuit->hello_interval[1],
+                     &circuit->u.bc.t_run_dr[1]);
   circuit->u.bc.is_dr[level - 1] = 1;
 
   if (level == 1)
@@ -321,12 +325,13 @@ isis_dr_commence (struct isis_circuit *circuit, int level)
       lsp_generate_pseudo (circuit, 1);
 
       THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
-      THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
-                      circuit, 2 * circuit->hello_interval[0]);
+      thread_add_timer(master, isis_run_dr_l1, circuit,
+                       2 * circuit->hello_interval[0],
+                       &circuit->u.bc.t_run_dr[0]);
 
-      THREAD_TIMER_ON (master, circuit->t_send_csnp[0], send_l1_csnp, circuit,
-                      isis_jitter (circuit->csnp_interval[level - 1],
-                                   CSNP_JITTER));
+      thread_add_timer(master, send_l1_csnp, circuit,
+                       isis_jitter(circuit->csnp_interval[level - 1], CSNP_JITTER),
+                       &circuit->t_send_csnp[0]);
 
     }
   else
@@ -347,15 +352,16 @@ isis_dr_commence (struct isis_circuit *circuit, int level)
       lsp_generate_pseudo (circuit, 2);
 
       THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
-      THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
-                      circuit, 2 * circuit->hello_interval[1]);
+      thread_add_timer(master, isis_run_dr_l2, circuit,
+                       2 * circuit->hello_interval[1],
+                       &circuit->u.bc.t_run_dr[1]);
 
-      THREAD_TIMER_ON (master, circuit->t_send_csnp[1], send_l2_csnp, circuit,
-                      isis_jitter (circuit->csnp_interval[level - 1],
-                                   CSNP_JITTER));
+      thread_add_timer(master, send_l2_csnp, circuit,
+                       isis_jitter(circuit->csnp_interval[level - 1], CSNP_JITTER),
+                       &circuit->t_send_csnp[1]);
     }
 
-  thread_add_event (master, isis_event_dis_status_change, circuit, 0);
+  thread_add_event(master, isis_event_dis_status_change, circuit, 0, NULL);
 
   return ISIS_OK;
 }
index 412f098a1bacb4078a8b70d3ca33af983adcd97a..541bfe4a5c3a1151c5792025d10e900776c46199 100644 (file)
@@ -51,7 +51,7 @@ dyn_cache_init (void)
 {
   if (dyn_cache == NULL)
     dyn_cache = list_new ();
-  THREAD_TIMER_ON (master, isis->t_dync_clean, dyn_cache_cleanup, NULL, 120);
+  thread_add_timer(master, dyn_cache_cleanup, NULL, 120, &isis->t_dync_clean);
   return;
 }
 
@@ -73,7 +73,7 @@ dyn_cache_cleanup (struct thread *thread)
       XFREE (MTYPE_ISIS_DYNHN, dyn);
     }
 
-  THREAD_TIMER_ON (master, isis->t_dync_clean, dyn_cache_cleanup, NULL, 120);
+  thread_add_timer(master, dyn_cache_cleanup, NULL, 120, &isis->t_dync_clean);
   return ISIS_OK;
 }
 
index ab42a1e367b9cd882894556c9ac37a84d5ecb079..32415092a4705398790dfd91336fbb7cb709f344 100644 (file)
@@ -82,18 +82,19 @@ circuit_commence_level (struct isis_circuit *circuit, int level)
   if (level == 1)
     {
       if (! circuit->is_passive)
-        THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
-                        isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
+        thread_add_timer(master, send_l1_psnp, circuit,
+                         isis_jitter(circuit->psnp_interval[0], PSNP_JITTER),
+                         &circuit->t_send_psnp[0]);
 
       if (circuit->circ_type == CIRCUIT_T_BROADCAST)
        {
-         THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
-                          circuit, 2 * circuit->hello_interval[0]);
+         thread_add_timer(master, isis_run_dr_l1, circuit,
+                           2 * circuit->hello_interval[0],
+                           &circuit->u.bc.t_run_dr[0]);
 
-         THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[0],
-                          send_lan_l1_hello, circuit,
-                          isis_jitter (circuit->hello_interval[0],
-                                       IIH_JITTER));
+         thread_add_timer(master, send_lan_l1_hello, circuit,
+                           isis_jitter(circuit->hello_interval[0], IIH_JITTER),
+                           &circuit->u.bc.t_send_lan_hello[0]);
 
          circuit->u.bc.lan_neighs[0] = list_new ();
        }
@@ -101,18 +102,19 @@ circuit_commence_level (struct isis_circuit *circuit, int level)
   else
     {
       if (! circuit->is_passive)
-        THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
-                        isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
+        thread_add_timer(master, send_l2_psnp, circuit,
+                         isis_jitter(circuit->psnp_interval[1], PSNP_JITTER),
+                         &circuit->t_send_psnp[1]);
 
       if (circuit->circ_type == CIRCUIT_T_BROADCAST)
        {
-         THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
-                          circuit, 2 * circuit->hello_interval[1]);
+         thread_add_timer(master, isis_run_dr_l2, circuit,
+                           2 * circuit->hello_interval[1],
+                           &circuit->u.bc.t_run_dr[1]);
 
-         THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[1],
-                          send_lan_l2_hello, circuit,
-                          isis_jitter (circuit->hello_interval[1],
-                                       IIH_JITTER));
+         thread_add_timer(master, send_lan_l2_hello, circuit,
+                           isis_jitter(circuit->hello_interval[1], IIH_JITTER),
+                           &circuit->u.bc.t_send_lan_hello[1]);
 
          circuit->u.bc.lan_neighs[1] = list_new ();
        }
index 955a73ef6128e169719cd4e17aafbb5ebb55af74..b7e66d13a14d07b2b25d056e3a0e6295a718e30e 100644 (file)
@@ -2034,11 +2034,11 @@ lsp_generate (struct isis_area *area, int level)
   THREAD_TIMER_OFF (area->t_lsp_refresh[level - 1]);
   area->lsp_regenerate_pending[level - 1] = 0;
   if (level == IS_LEVEL_1)
-    THREAD_TIMER_ON (master, area->t_lsp_refresh[level - 1],
-                     lsp_l1_refresh, area, refresh_time);
+    thread_add_timer(master, lsp_l1_refresh, area, refresh_time,
+                     &area->t_lsp_refresh[level - 1]);
   else if (level == IS_LEVEL_2)
-    THREAD_TIMER_ON (master, area->t_lsp_refresh[level - 1],
-                     lsp_l2_refresh, area, refresh_time);
+    thread_add_timer(master, lsp_l2_refresh, area, refresh_time,
+                     &area->t_lsp_refresh[level - 1]);
 
   if (isis->debugs & DEBUG_UPDATE_PACKETS)
     {
@@ -2111,11 +2111,11 @@ lsp_regenerate (struct isis_area *area, int level)
 
   refresh_time = lsp_refresh_time (lsp, rem_lifetime);
   if (level == IS_LEVEL_1)
-    THREAD_TIMER_ON (master, area->t_lsp_refresh[level - 1],
-                     lsp_l1_refresh, area, refresh_time);
+    thread_add_timer(master, lsp_l1_refresh, area, refresh_time,
+                     &area->t_lsp_refresh[level - 1]);
   else if (level == IS_LEVEL_2)
-    THREAD_TIMER_ON (master, area->t_lsp_refresh[level - 1],
-                     lsp_l2_refresh, area, refresh_time);
+    thread_add_timer(master, lsp_l2_refresh, area, refresh_time,
+                     &area->t_lsp_refresh[level - 1]);
   area->lsp_regenerate_pending[level - 1] = 0;
 
   if (isis->debugs & DEBUG_UPDATE_PACKETS)
@@ -2249,13 +2249,13 @@ lsp_regenerate_schedule (struct isis_area *area, int level, int all_pseudo)
       area->lsp_regenerate_pending[lvl - 1] = 1;
       if (lvl == IS_LEVEL_1)
         {
-          THREAD_TIMER_MSEC_ON(master, area->t_lsp_refresh[lvl - 1],
-                               lsp_l1_refresh, area, timeout);
+          thread_add_timer_msec(master, lsp_l1_refresh, area, timeout,
+                                &area->t_lsp_refresh[lvl - 1]);
         }
       else if (lvl == IS_LEVEL_2)
         {
-          THREAD_TIMER_MSEC_ON(master, area->t_lsp_refresh[lvl - 1],
-                               lsp_l2_refresh, area, timeout);
+          thread_add_timer_msec(master, lsp_l2_refresh, area, timeout,
+                                &area->t_lsp_refresh[lvl - 1]);
         }
     }
 
@@ -2465,11 +2465,11 @@ lsp_generate_pseudo (struct isis_circuit *circuit, int level)
   THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[level - 1]);
   circuit->lsp_regenerate_pending[level - 1] = 0;
   if (level == IS_LEVEL_1)
-    THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[level - 1],
-                     lsp_l1_refresh_pseudo, circuit, refresh_time);
+    thread_add_timer(master, lsp_l1_refresh_pseudo, circuit, refresh_time,
+                     &circuit->u.bc.t_refresh_pseudo_lsp[level - 1]);
   else if (level == IS_LEVEL_2)
-    THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[level - 1],
-                     lsp_l2_refresh_pseudo, circuit, refresh_time);
+    thread_add_timer(master, lsp_l2_refresh_pseudo, circuit, refresh_time,
+                     &circuit->u.bc.t_refresh_pseudo_lsp[level - 1]);
 
   if (isis->debugs & DEBUG_UPDATE_PACKETS)
     {
@@ -2528,11 +2528,11 @@ lsp_regenerate_pseudo (struct isis_circuit *circuit, int level)
 
   refresh_time = lsp_refresh_time (lsp, rem_lifetime);
   if (level == IS_LEVEL_1)
-    THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[level - 1],
-                     lsp_l1_refresh_pseudo, circuit, refresh_time);
+    thread_add_timer(master, lsp_l1_refresh_pseudo, circuit, refresh_time,
+                     &circuit->u.bc.t_refresh_pseudo_lsp[level - 1]);
   else if (level == IS_LEVEL_2)
-    THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[level - 1],
-                     lsp_l2_refresh_pseudo, circuit, refresh_time);
+    thread_add_timer(master, lsp_l2_refresh_pseudo, circuit, refresh_time,
+                     &circuit->u.bc.t_refresh_pseudo_lsp[level - 1]);
 
   if (isis->debugs & DEBUG_UPDATE_PACKETS)
     {
@@ -2684,15 +2684,15 @@ lsp_regenerate_schedule_pseudo (struct isis_circuit *circuit, int level)
 
       if (lvl == IS_LEVEL_1)
         {
-          THREAD_TIMER_MSEC_ON(master,
-                               circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1],
-                               lsp_l1_refresh_pseudo, circuit, timeout);
+          thread_add_timer_msec(master, lsp_l1_refresh_pseudo, circuit,
+                                timeout,
+                                &circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1]);
         }
       else if (lvl == IS_LEVEL_2)
         {
-          THREAD_TIMER_MSEC_ON(master,
-                               circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1],
-                               lsp_l2_refresh_pseudo, circuit, timeout);
+          thread_add_timer_msec(master, lsp_l2_refresh_pseudo, circuit,
+                                timeout,
+                                &circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1]);
         }
     }
 
@@ -2721,7 +2721,7 @@ lsp_tick (struct thread *thread)
   area = THREAD_ARG (thread);
   assert (area);
   area->t_tick = NULL;
-  THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
+  thread_add_timer(master, lsp_tick, area, 1, &area->t_tick);
 
   /*
    * Build a list of LSPs with (any) SRMflag set
@@ -2799,7 +2799,8 @@ lsp_tick (struct thread *thread)
                           if (! listnode_lookup (circuit->lsp_queue, lsp))
                             {
                               listnode_add (circuit->lsp_queue, lsp);
-                              thread_add_event (master, send_lsp, circuit, 0);
+                              thread_add_event(master, send_lsp, circuit, 0,
+                                               NULL);
                             }
                         }
                     }
index 5232666bda42db0b9c98d9004a6f982d6da070a3..f13a2f30eaab72fa913b5417b272d63c8fa86f44 100644 (file)
@@ -569,8 +569,8 @@ process_p2p_hello (struct isis_circuit *circuit)
 
   /* lets take care of the expiry */
   THREAD_TIMER_OFF (adj->t_expire);
-  THREAD_TIMER_ON (master, adj->t_expire, isis_adj_expire, adj,
-                  (long) adj->hold_time);
+  thread_add_timer(master, isis_adj_expire, adj, (long)adj->hold_time,
+                   &adj->t_expire);
 
   /* 8.2.5.2 a) a match was detected */
   if (area_match (circuit->area->area_addrs, tlvs.area_addrs))
@@ -1124,7 +1124,8 @@ process_lan_hello (int level, struct isis_circuit *circuit, const u_char *ssnpa)
       case 1:
        if (memcmp (circuit->u.bc.l1_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1))
          {
-            thread_add_event (master, isis_event_dis_status_change, circuit, 0);
+            thread_add_event(master, isis_event_dis_status_change, circuit, 0,
+                             NULL);
            memcpy (&circuit->u.bc.l1_desig_is, hdr.lan_id,
                    ISIS_SYS_ID_LEN + 1);
          }
@@ -1132,7 +1133,8 @@ process_lan_hello (int level, struct isis_circuit *circuit, const u_char *ssnpa)
       case 2:
        if (memcmp (circuit->u.bc.l2_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1))
          {
-            thread_add_event (master, isis_event_dis_status_change, circuit, 0);
+            thread_add_event(master, isis_event_dis_status_change, circuit, 0,
+                             NULL);
            memcpy (&circuit->u.bc.l2_desig_is, hdr.lan_id,
                    ISIS_SYS_ID_LEN + 1);
          }
@@ -1167,8 +1169,8 @@ process_lan_hello (int level, struct isis_circuit *circuit, const u_char *ssnpa)
 
   /* lets take care of the expiry */
   THREAD_TIMER_OFF (adj->t_expire);
-  THREAD_TIMER_ON (master, adj->t_expire, isis_adj_expire, adj,
-                   (long) adj->hold_time);
+  thread_add_timer(master, isis_adj_expire, adj, (long)adj->hold_time,
+                   &adj->t_expire);
 
   /*
    * If the snpa for this circuit is found from LAN Neighbours TLV
@@ -2389,9 +2391,9 @@ send_lan_l1_hello (struct thread *thread)
   retval = send_hello (circuit, 1);
 
   /* set next timer thread */
-  THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[0],
-                  send_lan_l1_hello, circuit,
-                  isis_jitter (circuit->hello_interval[0], IIH_JITTER));
+  thread_add_timer(master, send_lan_l1_hello, circuit,
+                   isis_jitter(circuit->hello_interval[0], IIH_JITTER),
+                   &circuit->u.bc.t_send_lan_hello[0]);
 
   return retval;
 }
@@ -2419,9 +2421,9 @@ send_lan_l2_hello (struct thread *thread)
   retval = send_hello (circuit, 2);
 
   /* set next timer thread */
-  THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[1],
-                  send_lan_l2_hello, circuit,
-                  isis_jitter (circuit->hello_interval[1], IIH_JITTER));
+  thread_add_timer(master, send_lan_l2_hello, circuit,
+                   isis_jitter(circuit->hello_interval[1], IIH_JITTER),
+                   &circuit->u.bc.t_send_lan_hello[1]);
 
   return retval;
 }
@@ -2438,9 +2440,9 @@ send_p2p_hello (struct thread *thread)
   send_hello (circuit, 1);
 
   /* set next timer thread */
-  THREAD_TIMER_ON (master, circuit->u.p2p.t_send_p2p_hello, send_p2p_hello,
-                  circuit, isis_jitter (circuit->hello_interval[1],
-                                        IIH_JITTER));
+  thread_add_timer(master, send_p2p_hello, circuit,
+                   isis_jitter(circuit->hello_interval[1], IIH_JITTER),
+                   &circuit->u.p2p.t_send_p2p_hello);
 
   return ISIS_OK;
 }
@@ -2740,8 +2742,9 @@ send_l1_csnp (struct thread *thread)
       send_csnp (circuit, 1);
     }
   /* set next timer thread */
-  THREAD_TIMER_ON (master, circuit->t_send_csnp[0], send_l1_csnp, circuit,
-                  isis_jitter (circuit->csnp_interval[0], CSNP_JITTER));
+  thread_add_timer(master, send_l1_csnp, circuit,
+                   isis_jitter(circuit->csnp_interval[0], CSNP_JITTER),
+                   &circuit->t_send_csnp[0]);
 
   return retval;
 }
@@ -2762,8 +2765,9 @@ send_l2_csnp (struct thread *thread)
       send_csnp (circuit, 2);
     }
   /* set next timer thread */
-  THREAD_TIMER_ON (master, circuit->t_send_csnp[1], send_l2_csnp, circuit,
-                  isis_jitter (circuit->csnp_interval[1], CSNP_JITTER));
+  thread_add_timer(master, send_l2_csnp, circuit,
+                   isis_jitter(circuit->csnp_interval[1], CSNP_JITTER),
+                   &circuit->t_send_csnp[1]);
 
   return retval;
 }
@@ -2965,8 +2969,9 @@ send_l1_psnp (struct thread *thread)
 
   send_psnp (1, circuit);
   /* set next timer thread */
-  THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
-                  isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
+  thread_add_timer(master, send_l1_psnp, circuit,
+                   isis_jitter(circuit->psnp_interval[0], PSNP_JITTER),
+                   &circuit->t_send_psnp[0]);
 
   return retval;
 }
@@ -2989,8 +2994,9 @@ send_l2_psnp (struct thread *thread)
   send_psnp (2, circuit);
 
   /* set next timer thread */
-  THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
-                  isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
+  thread_add_timer(master, send_l2_psnp, circuit,
+                   isis_jitter(circuit->psnp_interval[1], PSNP_JITTER),
+                   &circuit->t_send_psnp[1]);
 
   return retval;
 }
index 43dffdc863117da3842f8cbfec5f97d1426e75ec..1eb25861471ebe0277e889a015c95e787dc95bb6 100644 (file)
@@ -1279,9 +1279,9 @@ isis_spf_schedule (struct isis_area *area, int level)
       if (area->spf_timer[level - 1])
         return ISIS_OK;
 
-      THREAD_TIMER_MSEC_ON(master, area->spf_timer[level-1],
-                           isis_run_spf_cb, isis_run_spf_arg(area, level),
-                           delay);
+      thread_add_timer_msec (master, isis_run_spf_cb,
+                             isis_run_spf_arg(area, level),
+                             delay, &area->spf_timer[level-1]);
       return ISIS_OK;
     }
 
@@ -1301,9 +1301,9 @@ isis_spf_schedule (struct isis_area *area, int level)
       return retval;
     }
 
-  THREAD_TIMER_ON (master, area->spf_timer[level-1],
-                   isis_run_spf_cb, isis_run_spf_arg(area, level),
-                   area->min_spf_interval[level-1] - diff);
+  thread_add_timer (master, isis_run_spf_cb, isis_run_spf_arg(area, level),
+                    area->min_spf_interval[level-1] - diff,
+                    &area->spf_timer[level-1]);
 
   if (isis->debugs & DEBUG_SPF_EVENTS)
     zlog_debug ("ISIS-Spf (%s) L%d SPF scheduled %d sec from now",
index d11044377f4d534c13cc10697ed2baea04db63c6..fedac084e34c36016e9dd7f9bf8dc791f5ed0cb2 100644 (file)
@@ -137,7 +137,7 @@ isis_area_create (const char *area_tag)
 
   area->circuit_list = list_new ();
   area->area_addrs = list_new ();
-  THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
+  thread_add_timer(master, lsp_tick, area, 1, &area->t_tick);
   flags_initialize (&area->flags);
 
   /*
index 4cb461b9088686bed4126b0f23f965132b74eb01..5b1dacc30830c7b691a80e08e6b0d823f4e22020 100644 (file)
@@ -58,7 +58,7 @@ 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);
+       av->ev = thread_add_read(master, accept_cb, av, av->fd, NULL);
 
        log_debug("%s: accepting on fd %d", __func__, fd);
 
@@ -85,7 +85,8 @@ accept_pause(void)
 {
        log_debug(__func__);
        accept_unarm();
-       accept_queue.evt = thread_add_timer(master, accept_timeout, NULL, 1);
+       accept_queue.evt = thread_add_timer(master, accept_timeout, NULL, 1,
+                                           NULL);
 }
 
 void
@@ -103,7 +104,7 @@ 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);
+               av->ev = thread_add_read(master, accept_cb, av, av->fd, NULL);
 }
 
 static void
@@ -118,7 +119,7 @@ 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);
+       av->ev = thread_add_read(master, accept_cb, av, av->fd, NULL);
        av->accept_cb(thread);
 
        return (0);
index 3ec57f158971385ed445ba788e89bbfa592bf109..e8bc58b7e85a44bd9dd0ec8c03c1e0153ff6a8e8 100644 (file)
@@ -207,7 +207,7 @@ adj_start_itimer(struct adj *adj)
 {
        THREAD_TIMER_OFF(adj->inactivity_timer);
        adj->inactivity_timer = thread_add_timer(master, adj_itimer, adj,
-           adj->holdtime);
+                                                adj->holdtime, NULL);
 }
 
 void
@@ -367,7 +367,8 @@ 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));
+                                            tnbr_get_hello_interval(tnbr),
+                                            NULL);
 }
 
 static void
index d40e0342c13a76011e0a112fec96145e2a783feb..40d8007d760ecdae0fad42e7973851936e5175ae 100644 (file)
@@ -133,8 +133,8 @@ 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);
+       c->iev.ev_read = thread_add_read(master, c->iev.handler_read, &c->iev,
+                                        c->iev.ibuf.fd, NULL);
        c->iev.handler_write = ldp_write_handler;
        c->iev.ev_write = NULL;
 
index 440bb2dca06244828fad0ceb4ff7811999143a8c..42f6ca5f381bb75818e725574bfeb5f28ce3e84f 100644 (file)
@@ -441,7 +441,7 @@ 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));
+                                          if_get_hello_interval(ia), NULL);
 }
 
 static void
index 859d47431b394c5855e72d234b9ef5c7e9fdb6db..2d87161ec2ef387c1172af69082f8edaa69fa177 100644 (file)
@@ -141,7 +141,7 @@ lde(void)
        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);
+                                           iev_main, iev_main->ibuf.fd, NULL);
        iev_main->handler_write = ldp_write_handler;
 
        if ((iev_main_sync = calloc(1, sizeof(struct imsgev))) == NULL)
@@ -527,7 +527,10 @@ lde_dispatch_parent(struct thread *thread)
                        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);
+                                                           iev_ldpe->handler_read,
+                                                           iev_ldpe,
+                                                           iev_ldpe->ibuf.fd,
+                                                           NULL);
                        iev_ldpe->handler_write = ldp_write_handler;
                        iev_ldpe->ev_write = NULL;
                        break;
index 37a670bc8ca58be4988cba4cfa7172df69b4bb5b..0585a776ade043bc0f6aa0f44637a11ff31a8f3d 100644 (file)
@@ -933,7 +933,7 @@ lde_gc_start_timer(void)
 {
        THREAD_TIMER_OFF(gc_timer);
        gc_timer = thread_add_timer(master, lde_gc_timer, NULL,
-           LDE_GC_INTERVAL);
+                                   LDE_GC_INTERVAL, NULL);
 }
 
 void
index bdf70973234559c47c333fd8c479e2d0c9219b4a..1fbb4d67f03ff428f8ed151550f553f525045052 100644 (file)
@@ -359,25 +359,29 @@ main(int argc, char *argv[])
        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);
+                                           iev_ldpe, iev_ldpe->ibuf.fd, NULL);
        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);
+                                                iev_ldpe_sync->handler_read,
+                                                iev_ldpe_sync,
+                                                iev_ldpe_sync->ibuf.fd, NULL);
        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);
+                                          iev_lde, iev_lde->ibuf.fd, NULL);
        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);
+                                               iev_lde_sync->handler_read,
+                                               iev_lde_sync,
+                                               iev_lde_sync->ibuf.fd, NULL);
        iev_lde_sync->handler_write = ldp_write_handler;
 
        if (main_imsg_send_ipc_sockets(&iev_ldpe->ibuf, &iev_lde->ibuf))
@@ -690,12 +694,12 @@ void
 imsg_event_add(struct imsgev *iev)
 {
        if (iev->handler_read)
-               THREAD_READ_ON(master, iev->ev_read, iev->handler_read, iev,
-                   iev->ibuf.fd);
+               thread_add_read(master, iev->handler_read, iev, iev->ibuf.fd,
+                               &iev->ev_read);
 
        if (iev->handler_write && iev->ibuf.w.queued)
-               THREAD_WRITE_ON(master, iev->ev_write, iev->handler_write, iev,
-                   iev->ibuf.fd);
+               thread_add_write(master, iev->handler_write, iev,
+                                iev->ibuf.fd, &iev->ev_write);
 }
 
 int
@@ -721,8 +725,8 @@ void
 evbuf_event_add(struct evbuf *eb)
 {
        if (eb->wbuf.queued)
-               THREAD_WRITE_ON(master, eb->ev, eb->handler, eb->arg,
-                   eb->wbuf.fd);
+               thread_add_write(master, eb->handler, eb->arg, eb->wbuf.fd,
+                                &eb->ev);
 }
 
 void
index 017eec2502c4145cf9bdfe5bc99d233d927e8bc9..9f87e58c40c90cb3ec5b754dc19788b6c0d94341 100644 (file)
@@ -120,7 +120,7 @@ ldpe(void)
        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);
+                                           iev_main, iev_main->ibuf.fd, NULL);
        iev_main->handler_write = ldp_write_handler;
 
        if ((iev_main_sync = calloc(1, sizeof(struct imsgev))) == NULL)
@@ -165,8 +165,8 @@ ldpe_init(struct ldpd_init *init)
 #ifdef __OpenBSD__
        global.pfkeysock = pfkey_init();
        if (sysdep.no_pfkey == 0)
-               pfkey_ev = thread_add_read(master, ldpe_dispatch_pfkey,
-                   NULL, global.pfkeysock);
+               pfkey_ev = thread_add_read(master, ldpe_dispatch_pfkey, NULL,
+                                          global.pfkeysock, NULL);
 #endif
 
        /* mark sockets as closed */
@@ -354,7 +354,10 @@ ldpe_dispatch_main(struct thread *thread)
                        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);
+                                                          iev_lde->handler_read,
+                                                          iev_lde,
+                                                          iev_lde->ibuf.fd,
+                                                          NULL);
                        iev_lde->handler_write = ldp_write_handler;
                        iev_lde->ev_write = NULL;
                        break;
@@ -694,8 +697,8 @@ ldpe_dispatch_pfkey(struct thread *thread)
 {
        int      fd = THREAD_FD(thread);
 
-       pfkey_ev = thread_add_read(master, ldpe_dispatch_pfkey,
-           NULL, global.pfkeysock);
+       pfkey_ev = thread_add_read(master, ldpe_dispatch_pfkey, NULL,
+                                  global.pfkeysock, NULL);
 
        if (pfkey_read(fd, NULL) == -1)
                fatal("pfkey_read failed, exiting...");
@@ -715,12 +718,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);
+                                            &af_global->disc_ev,
+                                            af_global->ldp_disc_socket, NULL);
 
        /* 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);
+                                             &af_global->edisc_ev,
+                                             af_global->ldp_edisc_socket,
+                                             NULL);
 
        /* session socket */
        af_global->ldp_session_socket = session_socket;
index 9a92a00d32327a811ae39888ee26ccac8b602e93..2eb46733ee42cebaf249b2db2030c1b45071eb51 100644 (file)
@@ -408,7 +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);
+       nbr->keepalive_timer = thread_add_timer(master, nbr_ktimer, nbr, secs,
+                                               NULL);
 }
 
 void
@@ -438,7 +439,7 @@ nbr_start_ktimeout(struct nbr *nbr)
 {
        THREAD_TIMER_OFF(nbr->keepalive_timeout);
        nbr->keepalive_timeout = thread_add_timer(master, nbr_ktimeout, nbr,
-           nbr->keepalive);
+                                                 nbr->keepalive, NULL);
 }
 
 void
@@ -468,7 +469,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);
+       nbr->init_timeout = thread_add_timer(master, nbr_itimeout, nbr, secs,
+                                            NULL);
 }
 
 void
@@ -516,7 +518,8 @@ nbr_start_idtimer(struct nbr *nbr)
        }
 
        THREAD_TIMER_OFF(nbr->initdelay_timer);
-       nbr->initdelay_timer = thread_add_timer(master, nbr_idtimer, nbr, secs);
+       nbr->initdelay_timer = thread_add_timer(master, nbr_idtimer, nbr,
+                                               secs, NULL);
 }
 
 void
@@ -633,8 +636,8 @@ nbr_establish_connection(struct nbr *nbr)
        if (connect(nbr->fd, (struct sockaddr *)&remote_sa,
            sockaddr_len((struct sockaddr *)&remote_sa)) == -1) {
                if (errno == EINPROGRESS) {
-                       THREAD_WRITE_ON(master, nbr->ev_connect, nbr_connect_cb,
-                           nbr, nbr->fd);
+                       thread_add_write(master, nbr_connect_cb, nbr, nbr->fd,
+                                        &nbr->ev_connect);
                        return (0);
                }
                log_warn("%s: error while connecting to %s", __func__,
index df6bd8e57a8849cc6b9654370bf624909680dd04..73703503f317c27dfea6a9c142d9a1064f6d8cf6 100644 (file)
@@ -143,7 +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);
+       *threadp = thread_add_read(master, disc_recv_packet, threadp, fd,
+                                  NULL);
 
        /* setup buffer */
        memset(&m, 0, sizeof(m));
@@ -427,7 +428,7 @@ 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);
+       tcp->rev = thread_add_read(master, session_read, nbr, fd, NULL);
 
        if ((n = read(fd, tcp->rbuf->buf + tcp->rbuf->wpos,
            sizeof(tcp->rbuf->buf) - tcp->rbuf->wpos)) == -1) {
@@ -731,7 +732,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);
+               tcp->rev = thread_add_read(master, session_read, nbr, tcp->fd,
+                                          NULL);
                tcp->nbr = nbr;
        }
 
@@ -778,7 +780,8 @@ pending_conn_new(int fd, int af, union ldpd_addr *addr)
        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);
+                                            pconn, PENDING_CONN_TIMEOUT,
+                                            NULL);
 
        return (pconn);
 }
index 11d5c9385d103f51f549ed6f2f9dc53293589376..f7b124f25b04d9952285c006a46ca456c316cf7e 100644 (file)
@@ -86,7 +86,8 @@ agentx_events_update(void)
   snmp_select_info (&maxfd, &fds, &timeout, &block);
 
   if (!block)
-    timeout_thr = thread_add_timer_tv (agentx_tm, agentx_timeout, NULL, &timeout);
+    timeout_thr = thread_add_timer_tv(agentx_tm, agentx_timeout, NULL,
+                                      &timeout, NULL);
 
   ln = listhead (events);
   thr = ln ? listgetdata (ln) : NULL;
@@ -114,7 +115,7 @@ agentx_events_update(void)
       else if (FD_ISSET (fd, &fds))
         {
           struct listnode *newln;
-          thr = thread_add_read (agentx_tm, agentx_read, NULL, fd);
+          thr = thread_add_read(agentx_tm, agentx_read, NULL, fd, NULL);
           newln = listnode_add_before (events, ln, thr);
           thr->arg = newln;
         }
index b2059a17bf6104de35a54a847fa1f04c41fbbac7..7eda2bcddecce920d72bbfb9263ea3b7d1f9e1d0 100644 (file)
@@ -132,8 +132,8 @@ 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);
+  sigm->t = thread_add_timer(sigm->t->master, quagga_signal_timer, &sigmaster,
+                             QUAGGA_SIGNAL_TIMER_INTERVAL, NULL);
   return quagga_sigevent_process ();
 }
 #endif /* SIGEVENT_SCHEDULE_THREAD */
@@ -379,7 +379,7 @@ signal_init (struct thread_master *m, int sigc,
 
 #ifdef SIGEVENT_SCHEDULE_THREAD  
   sigmaster.t = 
-    thread_add_timer (m, quagga_signal_timer, &sigmaster, 
-                      QUAGGA_SIGNAL_TIMER_INTERVAL);
+    thread_add_timer(m, quagga_signal_timer, &sigmaster,
+                     QUAGGA_SIGNAL_TIMER_INTERVAL, NULL);
 #endif /* SIGEVENT_SCHEDULE_THREAD */
 }
index 370b8f138e17ac5160dfd2e2cbecf4ee1a9767a8..e0db87e4b037c0df5f876a185b60131463b6e182 100644 (file)
@@ -1197,13 +1197,16 @@ 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);
+      smux_connect_thread = thread_add_event(smux_master, smux_connect, NULL,
+                                             0, NULL);
       break;
     case SMUX_CONNECT:
-      smux_connect_thread = thread_add_timer (smux_master, smux_connect, NULL, 10);
+      smux_connect_thread = thread_add_timer(smux_master, smux_connect, NULL,
+                                             10, NULL);
       break;
     case SMUX_READ:
-      smux_read_thread = thread_add_read (smux_master, smux_read, NULL, sock);
+      smux_read_thread = thread_add_read(smux_master, smux_read, NULL, sock,
+                                         NULL);
       break;
     default:
       break;
index e923f232b814f3b6bab97c3d6389dec9ed708ae8..9a9af8db209e9e37eaefd84eb3213d016708421c 100644 (file)
@@ -169,21 +169,19 @@ long spf_backoff_schedule(struct spf_backoff *backoff)
     {
     case SPF_BACKOFF_QUIET:
       backoff->state = SPF_BACKOFF_SHORT_WAIT;
-      THREAD_TIMER_MSEC_ON(backoff->m, backoff->t_timetolearn,
-                           spf_backoff_timetolearn_elapsed, backoff,
-                           backoff->timetolearn);
-      THREAD_TIMER_MSEC_ON(backoff->m, backoff->t_holddown,
-                           spf_backoff_holddown_elapsed, backoff,
-                           backoff->holddown);
+      thread_add_timer_msec(backoff->m, spf_backoff_timetolearn_elapsed,
+                            backoff, backoff->timetolearn,
+                            &backoff->t_timetolearn);
+      thread_add_timer_msec(backoff->m, spf_backoff_holddown_elapsed, backoff,
+                            backoff->holddown, &backoff->t_holddown);
       backoff->first_event_time = now;
       rv = backoff->init_delay;
       break;
     case SPF_BACKOFF_SHORT_WAIT:
     case SPF_BACKOFF_LONG_WAIT:
       THREAD_TIMER_OFF(backoff->t_holddown);
-      THREAD_TIMER_MSEC_ON(backoff->m, backoff->t_holddown,
-                           spf_backoff_holddown_elapsed, backoff,
-                           backoff->holddown);
+      thread_add_timer_msec(backoff->m, spf_backoff_holddown_elapsed, backoff,
+                            backoff->holddown, &backoff->t_holddown);
       if (backoff->state == SPF_BACKOFF_SHORT_WAIT)
         rv = backoff->short_delay;
       else
index 4c78cf328c40a35ef31c23a1161b2ff51b9f579e..e2329af93ad52552f53234a21de7ae35ba64a6d2 100644 (file)
@@ -104,7 +104,7 @@ systemd_send_watchdog (struct thread *t)
 {
   systemd_send_information ("WATCHDOG=1");
 
-  thread_add_timer (systemd_master, systemd_send_watchdog, NULL, wsecs);
+  thread_add_timer(systemd_master, systemd_send_watchdog, NULL, wsecs, NULL);
 
   return 1;
 }
@@ -119,5 +119,5 @@ systemd_send_started (struct thread_master *m, int the_process)
 
   systemd_send_information ("READY=1");
   if (wsecs != 0)
-    thread_add_timer (m, systemd_send_watchdog, m, wsecs);
+    thread_add_timer(m, systemd_send_watchdog, m, wsecs, NULL);
 }
index 3fb28bce26f0e0961a530f3025619d6c77eeed46..37a71824d7499b04adc1348730b146d90ce8f9b4 100644 (file)
@@ -725,6 +725,7 @@ fd_select (struct thread_master *m, int size, thread_fd_set *read, thread_fd_set
   num = poll (m->handler.pfds, m->handler.pfdcount + m->handler.pfdcountsnmp, timeout);
 #else
   struct timeval timeout;
+
   if (m->selectpoll_timeout > 0) // use the user's timeout
   {
     timeout.tv_sec = m->selectpoll_timeout / 1000;
@@ -776,13 +777,19 @@ fd_clear_read_write (struct thread *thread)
 /* Add new read thread. */
 struct thread *
 funcname_thread_add_read_write (int dir, struct thread_master *m,
-                               int (*func) (struct thread *), void *arg, int fd,
-                               debugargdef)
+        int (*func) (struct thread *), void *arg, int fd, struct thread **t_ptr,
+        debugargdef)
 {
   struct thread *thread = NULL;
 
   pthread_mutex_lock (&m->mtx);
   {
+    if (t_ptr && *t_ptr) // thread is already scheduled; don't reschedule
+      {
+        pthread_mutex_unlock (&m->mtx);
+        return NULL;
+      }
+
 #if defined (HAVE_POLL_CALL)
     thread = generic_thread_add(m, func, arg, fd, dir, debugargpass);
 #else
@@ -822,6 +829,9 @@ funcname_thread_add_read_write (int dir, struct thread_master *m,
         }
         pthread_mutex_unlock (&thread->mtx);
       }
+
+    if (t_ptr)
+      *t_ptr = thread;
   }
   pthread_mutex_unlock (&m->mtx);
 
@@ -830,11 +840,8 @@ funcname_thread_add_read_write (int dir, struct thread_master *m,
 
 static struct thread *
 funcname_thread_add_timer_timeval (struct thread_master *m,
-                                   int (*func) (struct thread *), 
-                                  int type,
-                                  void *arg, 
-                                  struct timeval *time_relative,
-                                 debugargdef)
+         int (*func) (struct thread *), int type, void *arg,
+         struct timeval *time_relative, struct thread **t_ptr, debugargdef)
 {
   struct thread *thread;
   struct pqueue *queue;
@@ -846,6 +853,12 @@ funcname_thread_add_timer_timeval (struct thread_master *m,
   
   pthread_mutex_lock (&m->mtx);
   {
+    if (t_ptr && *t_ptr) // thread is already scheduled; don't reschedule
+      {
+        pthread_mutex_unlock (&m->mtx);
+        return NULL;
+      }
+
     queue = ((type == THREAD_TIMER) ? m->timer : m->background);
     thread = thread_get (m, type, func, arg, debugargpass);
 
@@ -856,6 +869,9 @@ funcname_thread_add_timer_timeval (struct thread_master *m,
       pqueue_enqueue(thread, queue);
     }
     pthread_mutex_unlock (&thread->mtx);
+
+    if (t_ptr)
+      *t_ptr = thread;
   }
   pthread_mutex_unlock (&m->mtx);
 
@@ -866,9 +882,8 @@ funcname_thread_add_timer_timeval (struct thread_master *m,
 /* Add timer event thread. */
 struct thread *
 funcname_thread_add_timer (struct thread_master *m,
-                          int (*func) (struct thread *), 
-                          void *arg, long timer,
-                          debugargdef)
+        int (*func) (struct thread *), void *arg, long timer,
+        struct thread **t_ptr, debugargdef)
 {
   struct timeval trel;
 
@@ -877,16 +892,15 @@ funcname_thread_add_timer (struct thread_master *m,
   trel.tv_sec = timer;
   trel.tv_usec = 0;
 
-  return funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, arg, 
-                                            &trel, debugargpass);
+  return funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, arg, &trel,
+                                            t_ptr, debugargpass);
 }
 
 /* Add timer event thread with "millisecond" resolution */
 struct thread *
 funcname_thread_add_timer_msec (struct thread_master *m,
-                                int (*func) (struct thread *), 
-                                void *arg, long timer,
-                               debugargdef)
+        int (*func) (struct thread *), void *arg, long timer,
+        struct thread **t_ptr, debugargdef)
 {
   struct timeval trel;
 
@@ -895,27 +909,25 @@ funcname_thread_add_timer_msec (struct thread_master *m,
   trel.tv_sec = timer / 1000;
   trel.tv_usec = 1000*(timer % 1000);
 
-  return funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, 
-                                            arg, &trel, debugargpass);
+  return funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, arg, &trel,
+                                            t_ptr, debugargpass);
 }
 
 /* Add timer event thread with "millisecond" resolution */
 struct thread *
 funcname_thread_add_timer_tv (struct thread_master *m,
-                              int (*func) (struct thread *),
-                              void *arg, struct timeval *tv,
-                              debugargdef)
+        int (*func) (struct thread *), void *arg, struct timeval *tv,
+        struct thread **t_ptr, debugargdef)
 {
-  return funcname_thread_add_timer_timeval (m, func, THREAD_TIMER,
-                                            arg, tv, debugargpass);
+  return funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, arg, tv,
+                                            t_ptr, debugargpass);
 }
 
 /* Add a background thread, with an optional millisec delay */
 struct thread *
 funcname_thread_add_background (struct thread_master *m,
-                                int (*func) (struct thread *),
-                                void *arg, long delay,
-                               debugargdef)
+        int (*func) (struct thread *), void *arg, long delay,
+        struct thread **t_ptr, debugargdef)
 {
   struct timeval trel;
   
@@ -932,15 +944,15 @@ funcname_thread_add_background (struct thread_master *m,
       trel.tv_usec = 0;
     }
 
-  return funcname_thread_add_timer_timeval (m, func, THREAD_BACKGROUND,
-                                            arg, &trel, debugargpass);
+  return funcname_thread_add_timer_timeval (m, func, THREAD_BACKGROUND, arg,
+                                            &trel, t_ptr, debugargpass);
 }
 
 /* Add simple event thread. */
 struct thread *
 funcname_thread_add_event (struct thread_master *m,
-                 int (*func) (struct thread *), void *arg, int val,
-                 debugargdef)
+        int (*func) (struct thread *), void *arg, int val,
+        struct thread **t_ptr, debugargdef)
 {
   struct thread *thread;
 
@@ -948,6 +960,12 @@ funcname_thread_add_event (struct thread_master *m,
 
   pthread_mutex_lock (&m->mtx);
   {
+    if (t_ptr && *t_ptr) // thread is already scheduled; don't reschedule
+      {
+        pthread_mutex_unlock (&m->mtx);
+        return NULL;
+      }
+
     thread = thread_get (m, THREAD_EVENT, func, arg, debugargpass);
     pthread_mutex_lock (&thread->mtx);
     {
@@ -955,6 +973,9 @@ funcname_thread_add_event (struct thread_master *m,
       thread_list_add (&m->event, thread);
     }
     pthread_mutex_unlock (&thread->mtx);
+
+    if (t_ptr)
+      *t_ptr = thread;
   }
   pthread_mutex_unlock (&m->mtx);
 
index 6fb6ad7c9d9eae0e7df3b390f6f410c80cc3f423..fc345768f90a150d0c62d6b6e9ebf56991a859e7 100644 (file)
@@ -153,30 +153,6 @@ struct cpu_thread_history
 #define THREAD_FD(X)  ((X)->u.fd)
 #define THREAD_VAL(X) ((X)->u.val)
 
-#define THREAD_READ_ON(master,thread,func,arg,sock) \
-  do { \
-    if (! thread) \
-      thread = thread_add_read (master, func, arg, sock); \
-  } while (0)
-
-#define THREAD_WRITE_ON(master,thread,func,arg,sock) \
-  do { \
-    if (! thread) \
-      thread = thread_add_write (master, func, arg, sock); \
-  } while (0)
-
-#define THREAD_TIMER_ON(master,thread,func,arg,time) \
-  do { \
-    if (! thread) \
-      thread = thread_add_timer (master, func, arg, time); \
-  } while (0)
-
-#define THREAD_TIMER_MSEC_ON(master,thread,func,arg,time) \
-  do { \
-    if (! thread) \
-      thread = thread_add_timer_msec (master, func, arg, time); \
-  } while (0)
-
 #define THREAD_OFF(thread) \
   do { \
     if (thread) \
@@ -192,16 +168,16 @@ struct cpu_thread_history
 
 #define debugargdef  const char *funcname, const char *schedfrom, int fromln
 
-#define thread_add_read(m,f,a,v) funcname_thread_add_read_write(THREAD_READ,m,f,a,v,#f,__FILE__,__LINE__)
-#define thread_add_write(m,f,a,v) funcname_thread_add_read_write(THREAD_WRITE,m,f,a,v,#f,__FILE__,__LINE__)
-#define thread_add_timer(m,f,a,v) funcname_thread_add_timer(m,f,a,v,#f,__FILE__,__LINE__)
-#define thread_add_timer_msec(m,f,a,v) funcname_thread_add_timer_msec(m,f,a,v,#f,__FILE__,__LINE__)
-#define thread_add_timer_tv(m,f,a,v) funcname_thread_add_timer_tv(m,f,a,v,#f,__FILE__,__LINE__)
-#define thread_add_event(m,f,a,v) funcname_thread_add_event(m,f,a,v,#f,__FILE__,__LINE__)
+#define thread_add_read(m,f,a,v,t) funcname_thread_add_read_write(THREAD_READ,m,f,a,v,t,#f,__FILE__,__LINE__)
+#define thread_add_write(m,f,a,v,t) funcname_thread_add_read_write(THREAD_WRITE,m,f,a,v,t,#f,__FILE__,__LINE__)
+#define thread_add_timer(m,f,a,v,t) funcname_thread_add_timer(m,f,a,v,t,#f,__FILE__,__LINE__)
+#define thread_add_timer_msec(m,f,a,v,t) funcname_thread_add_timer_msec(m,f,a,v,t,#f,__FILE__,__LINE__)
+#define thread_add_timer_tv(m,f,a,v,t) funcname_thread_add_timer_tv(m,f,a,v,t,#f,__FILE__,__LINE__)
+#define thread_add_event(m,f,a,v,t) funcname_thread_add_event(m,f,a,v,t,#f,__FILE__,__LINE__)
 #define thread_execute(m,f,a,v) funcname_thread_execute(m,f,a,v,#f,__FILE__,__LINE__)
 
 /* The 4th arg to thread_add_background is the # of milliseconds to delay. */
-#define thread_add_background(m,f,a,v) funcname_thread_add_background(m,f,a,v,#f,__FILE__,__LINE__)
+#define thread_add_background(m,f,a,v,t) funcname_thread_add_background(m,f,a,v,t,#f,__FILE__,__LINE__)
 
 /* Prototypes. */
 extern struct thread_master *thread_master_create (void);
@@ -209,29 +185,26 @@ extern void thread_master_free (struct thread_master *);
 extern void thread_master_free_unused(struct thread_master *);
 
 extern struct thread *funcname_thread_add_read_write (int dir, struct thread_master *,
-                                               int (*)(struct thread *),
-                                               void *, int, debugargdef);
+    int (*)(struct thread *), void *, int, struct thread **, debugargdef);
+
 extern struct thread *funcname_thread_add_timer (struct thread_master *,
-                                                int (*)(struct thread *),
-                                                void *, long, debugargdef);
+    int (*)(struct thread *), void *, long, struct thread **, debugargdef);
+
 extern struct thread *funcname_thread_add_timer_msec (struct thread_master *,
-                                                     int (*)(struct thread *),
-                                                     void *, long, debugargdef);
+    int (*)(struct thread *), void *, long, struct thread **, debugargdef);
+
 extern struct thread *funcname_thread_add_timer_tv (struct thread_master *,
-                                                   int (*)(struct thread *),
-                                                   void *, struct timeval *,
-                                                   debugargdef);
+    int (*)(struct thread *), void *, struct timeval *, struct thread **, debugargdef);
+
 extern struct thread *funcname_thread_add_event (struct thread_master *,
-                                                int (*)(struct thread *),
-                                                void *, int, debugargdef);
+    int (*)(struct thread *), void *, int, struct thread **, debugargdef);
+
 extern struct thread *funcname_thread_add_background (struct thread_master *,
-                                               int (*func)(struct thread *),
-                                              void *arg,
-                                              long milliseconds_to_delay,
-                                              debugargdef);
+    int (*func)(struct thread *), void *arg, long milliseconds_to_delay,
+    struct thread **, debugargdef);
+
 extern struct thread *funcname_thread_execute (struct thread_master *,
-                                               int (*)(struct thread *),
-                                               void *, int, debugargdef);
+    int (*)(struct thread *), void *, int, debugargdef);
 #undef debugargdef
 
 extern void thread_cancel (struct thread *);
index 225a82c2dbf22a912fe482c9244d9ddfbfc81f7e..a68c5d0bc26d359874a66b2618eb99f23f5256c4 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2618,23 +2618,26 @@ 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);
+      vty_serv_thread = thread_add_read(vty_master, vty_accept, vty, sock,
+                                        NULL);
       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);
+      vty_serv_thread = thread_add_read(vty_master, vtysh_accept, vty, sock,
+                                        NULL);
       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);
+      vty->t_read = thread_add_read(vty_master, vtysh_read, vty, sock, NULL);
       break;
     case VTYSH_WRITE:
-      vty->t_write = thread_add_write (vty_master, vtysh_write, vty, sock);
+      vty->t_write = thread_add_write(vty_master, vtysh_write, vty, sock,
+                                      NULL);
       break;
 #endif /* VTYSH */
     case VTY_READ:
-      vty->t_read = thread_add_read (vty_master, vty_read, vty, sock);
+      vty->t_read = thread_add_read(vty_master, vty_read, vty, sock, NULL);
 
       /* Time out treatment. */
       if (vty->v_timeout)
@@ -2642,12 +2645,12 @@ vty_event (enum event event, int sock, struct vty *vty)
           if (vty->t_timeout)
             thread_cancel (vty->t_timeout);
           vty->t_timeout =
-            thread_add_timer (vty_master, vty_timeout, vty, vty->v_timeout);
+            thread_add_timer(vty_master, vty_timeout, vty, vty->v_timeout,
+                             NULL);
         }
       break;
     case VTY_WRITE:
-      if (! vty->t_write)
-        vty->t_write = thread_add_write (vty_master, vty_flush, vty, sock);
+      thread_add_write(vty_master, vty_flush, vty, sock, &vty->t_write);
       break;
     case VTY_TIMEOUT_RESET:
       if (vty->t_timeout)
@@ -2658,7 +2661,8 @@ 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);
+            thread_add_timer(vty_master, vty_timeout, vty, vty->v_timeout,
+                             NULL);
         }
       break;
     }
index fe53dea29999c1a6d424896eba1993ffff91d66d..9bcb1b8743be9135d2d50df238eaae2f4d159281 100644 (file)
@@ -60,9 +60,8 @@ wheel_timer_thread (struct thread *t)
     slots_to_skip++;
 
   wheel->slots_to_skip = slots_to_skip;
-  THREAD_TIMER_MSEC_ON (wheel->master, wheel->timer,
-                       wheel_timer_thread, wheel,
-                       wheel->nexttime * slots_to_skip);
+  thread_add_timer_msec(wheel->master, wheel_timer_thread, wheel,
+                        wheel->nexttime * slots_to_skip, &wheel->timer);
 
   return 0;
 }
@@ -91,9 +90,8 @@ wheel_init (struct thread_master *master, int period, size_t slots,
   for (i = 0; i < slots; i++)
     wheel->wheel_slot_lists[i] = list_new ();
 
-  THREAD_TIMER_MSEC_ON (wheel->master, wheel->timer,
-                       wheel_timer_thread, wheel,
-                       wheel->nexttime);
+  thread_add_timer_msec(wheel->master, wheel_timer_thread, wheel,
+                        wheel->nexttime, &wheel->timer);
 
   return wheel;
 }
@@ -124,9 +122,8 @@ int
 wheel_start (struct timer_wheel *wheel)
 {
   if (!wheel->timer)
-    THREAD_TIMER_MSEC_ON (wheel->master, wheel->timer,
-                         wheel_timer_thread, wheel,
-                         wheel->nexttime);
+    thread_add_timer_msec(wheel->master, wheel_timer_thread, wheel,
+                          wheel->nexttime, &wheel->timer);
 
   return 0;
 }
index 51017b34ea71186695c6b479368b079beb684c79..3d481aa89916d453e2b22fa74fc34fea29adf661 100644 (file)
@@ -126,8 +126,8 @@ 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);
+      wq->thread = thread_add_background(wq->master, work_queue_run, wq,
+                                         delay, NULL);
       /* 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);
index e3eadf22a47ffd2b6ef65854d257c999bd6677d8..60e35c66fab70545789427921ad97a4cccbea451 100644 (file)
@@ -311,7 +311,7 @@ zclient_flush_data(struct thread *thread)
       break;
     case BUFFER_PENDING:
       zclient->t_write = thread_add_write(zclient->master, zclient_flush_data,
-                                         zclient, zclient->sock);
+                                          zclient, zclient->sock, NULL);
       break;
     case BUFFER_EMPTY:
       break;
@@ -336,8 +336,8 @@ zclient_send_message(struct zclient *zclient)
       THREAD_OFF(zclient->t_write);
       break;
     case BUFFER_PENDING:
-      THREAD_WRITE_ON(zclient->master, zclient->t_write,
-                     zclient_flush_data, zclient, zclient->sock);
+      thread_add_write(zclient->master, zclient_flush_data, zclient,
+                       zclient->sock, &zclient->t_write);
       break;
     }
   return 0;
@@ -2012,22 +2012,20 @@ zclient_event (enum event event, struct zclient *zclient)
   switch (event)
     {
     case ZCLIENT_SCHEDULE:
-      if (! zclient->t_connect)
-       zclient->t_connect =
-         thread_add_event (zclient->master, zclient_connect, zclient, 0);
+      thread_add_event(zclient->master, zclient_connect, zclient, 0,
+                       &zclient->t_connect);
       break;
     case ZCLIENT_CONNECT:
       if (zclient_debug)
        zlog_debug ("zclient connect failures: %d schedule interval is now %d",
                    zclient->fail, zclient->fail < 3 ? 10 : 60);
-      if (! zclient->t_connect)
-       zclient->t_connect = 
-         thread_add_timer (zclient->master, zclient_connect, zclient,
-                           zclient->fail < 3 ? 10 : 60);
+      thread_add_timer(zclient->master, zclient_connect, 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);
+       thread_add_read(zclient->master, zclient_read, zclient, zclient->sock,
+                        NULL);
       break;
     }
 }
index 76419a7ff1e12094e7fcfcf04e0d49756cadf119..2b222e3c5c0cac81a0d409dd29bf008b1477fea9 100644 (file)
@@ -124,7 +124,7 @@ static int netlink_route_recv(struct thread *t)
                }
        }
 
-       thread_add_read(master, netlink_route_recv, 0, fd);
+       thread_add_read(master, netlink_route_recv, 0, fd, NULL);
 
        return 0;
 }
@@ -214,7 +214,8 @@ static int netlink_log_recv(struct thread *t)
                }
        }
 
-       THREAD_READ_ON(master, netlink_log_thread, netlink_log_recv, 0, netlink_log_fd);
+       thread_add_read(master, netlink_log_recv, 0, netlink_log_fd,
+                       &netlink_log_thread);
 
        return 0;
 }
@@ -230,7 +231,8 @@ void netlink_set_nflog_group(int nlgroup)
        if (nlgroup) {
                netlink_log_fd = znl_open(NETLINK_NETFILTER,  0);
                netlink_log_register(netlink_log_fd, nlgroup);
-               THREAD_READ_ON(master, netlink_log_thread, netlink_log_recv, 0, netlink_log_fd);
+               thread_add_read(master, netlink_log_recv, 0, netlink_log_fd,
+                               &netlink_log_thread);
        }
 }
 
@@ -238,7 +240,8 @@ int netlink_init(void)
 {
        netlink_req_fd = znl_open(NETLINK_ROUTE, 0);
        netlink_listen_fd = znl_open(NETLINK_ROUTE, RTMGRP_NEIGH);
-       thread_add_read(master, netlink_route_recv, 0, netlink_listen_fd);
+       thread_add_read(master, netlink_route_recv, 0, netlink_listen_fd,
+                       NULL);
 
        return 0;
 }
index d9094ec335dfc126f1b42211e98c8b2ff1acf57f..2d92842b5c2428260d9f935c7680be88e7cb4913 100644 (file)
@@ -181,11 +181,14 @@ static void nhrp_cache_update_timers(struct nhrp_cache *c)
        switch (c->cur.type) {
        case NHRP_CACHE_INVALID:
                if (!c->t_auth)
-                       THREAD_TIMER_MSEC_ON(master, c->t_timeout, nhrp_cache_do_free, c, 10);
+                       thread_add_timer_msec(master, nhrp_cache_do_free, c,
+                                             10, &c->t_timeout);
                break;
        default:
                if (c->cur.expires)
-                       THREAD_TIMER_ON(master, c->t_timeout, nhrp_cache_do_timeout, c, c->cur.expires - monotime(NULL));
+                       thread_add_timer(master, nhrp_cache_do_timeout, c,
+                                        c->cur.expires - monotime(NULL),
+                                        &c->t_timeout);
                break;
        }
 }
@@ -239,7 +242,8 @@ static void nhrp_cache_newpeer_notifier(struct notifier_block *n, unsigned long
        case NOTIFY_PEER_UP:
                if (nhrp_peer_check(c->new.peer, 1)) {
                        evmgr_notify("authorize-binding", c, nhrp_cache_authorize_binding);
-                       THREAD_TIMER_ON(master, c->t_auth, nhrp_cache_do_auth_timeout, c, 10);
+                       thread_add_timer(master, nhrp_cache_do_auth_timeout,
+                                        c, 10, &c->t_auth);
                }
                break;
        case NOTIFY_PEER_DOWN:
@@ -294,7 +298,8 @@ int nhrp_cache_update_binding(struct nhrp_cache *c, enum nhrp_cache_type type, i
                } else {
                        nhrp_peer_notify_add(c->new.peer, &c->newpeer_notifier, nhrp_cache_newpeer_notifier);
                        nhrp_cache_newpeer_notifier(&c->newpeer_notifier, NOTIFY_PEER_UP);
-                       THREAD_TIMER_ON(master, c->t_auth, nhrp_cache_do_auth_timeout, c, 60);
+                       thread_add_timer(master, nhrp_cache_do_auth_timeout,
+                                        c, 60, &c->t_auth);
                }
        }
        nhrp_cache_update_timers(c);
index aab9ec642f77e5dd7e5ef74685215151bd0bed4f..da86c585a4816c5a6302edc6595a95afe073a705 100644 (file)
@@ -40,8 +40,8 @@ static void evmgr_connection_error(struct event_manager *evmgr)
                close(evmgr->fd);
        evmgr->fd = -1;
        if (nhrp_event_socket_path)
-               THREAD_TIMER_MSEC_ON(master, evmgr->t_reconnect, evmgr_reconnect,
-                                    evmgr, 10);
+               thread_add_timer_msec(master, evmgr_reconnect, evmgr, 10,
+                                     &evmgr->t_reconnect);
 }
 
 static void evmgr_recv_message(struct event_manager *evmgr, struct zbuf *zb)
@@ -85,7 +85,7 @@ static int evmgr_read(struct thread *t)
        while (zbuf_may_pull_until(ibuf, "\n\n", &msg))
                evmgr_recv_message(evmgr, &msg);
 
-       THREAD_READ_ON(master, evmgr->t_read, evmgr_read, evmgr, evmgr->fd);
+       thread_add_read(master, evmgr_read, evmgr, evmgr->fd, &evmgr->t_read);
        return 0;
 }
 
@@ -97,7 +97,8 @@ static int evmgr_write(struct thread *t)
        evmgr->t_write = NULL;
        r = zbufq_write(&evmgr->obuf, evmgr->fd);
        if (r > 0) {
-               THREAD_WRITE_ON(master, evmgr->t_write, evmgr_write, evmgr, evmgr->fd);
+               thread_add_write(master, evmgr_write, evmgr, evmgr->fd,
+                                &evmgr->t_write);
        } else if (r < 0) {
                evmgr_connection_error(evmgr);
        }
@@ -170,7 +171,8 @@ static void evmgr_submit(struct event_manager *evmgr, struct zbuf *obuf)
        zbuf_put(obuf, "\n", 1);
        zbufq_queue(&evmgr->obuf, obuf);
        if (evmgr->fd >= 0)
-               THREAD_WRITE_ON(master, evmgr->t_write, evmgr_write, evmgr, evmgr->fd);
+               thread_add_write(master, evmgr_write, evmgr, evmgr->fd,
+                                &evmgr->t_write);
 }
 
 static int evmgr_reconnect(struct thread *t)
@@ -186,13 +188,14 @@ static int evmgr_reconnect(struct thread *t)
                zlog_warn("%s: failure connecting nhrp-event socket: %s",
                        __PRETTY_FUNCTION__, strerror(errno));
                zbufq_reset(&evmgr->obuf);
-               THREAD_TIMER_ON(master, evmgr->t_reconnect, evmgr_reconnect, evmgr, 10);
+               thread_add_timer(master, evmgr_reconnect, evmgr, 10,
+                                &evmgr->t_reconnect);
                return 0;
        }
 
        zlog_info("Connected to Event Manager");
        evmgr->fd = fd;
-       THREAD_READ_ON(master, evmgr->t_read, evmgr_read, evmgr, evmgr->fd);
+       thread_add_read(master, evmgr_read, evmgr, evmgr->fd, &evmgr->t_read);
 
        return 0;
 }
@@ -206,7 +209,8 @@ void evmgr_init(void)
        evmgr->fd = -1;
        zbuf_init(&evmgr->ibuf, evmgr->ibuf_data, sizeof(evmgr->ibuf_data), 0);
        zbufq_init(&evmgr->obuf);
-       THREAD_TIMER_MSEC_ON(master, evmgr->t_reconnect, evmgr_reconnect, evmgr, 10);
+       thread_add_timer_msec(master, evmgr_reconnect, evmgr, 10,
+                             &evmgr->t_reconnect);
 }
 
 void evmgr_set_socket(const char *socket)
index 555c0d1de1fdd8fe72e78aed3d0a4c5f4ddd8320..b926a8d7b25dd915a93ab74df1ce0e3697b5aa4d 100644 (file)
@@ -81,7 +81,8 @@ static void nhrp_reg_reply(struct nhrp_reqid *reqid, void *arg)
 
        /* RFC 2332 5.2.3 - Registration is recommend to be renewed
         * every one third of holdtime */
-       THREAD_TIMER_ON(master, r->t_register, nhrp_reg_send_req, r, holdtime / 3);
+       thread_add_timer(master, nhrp_reg_send_req, r, holdtime / 3,
+                        &r->t_register);
 
        r->proto_addr = p->dst_proto;
        c = nhrp_cache_get(ifp, &p->dst_proto, 1);
@@ -104,7 +105,8 @@ static int nhrp_reg_timeout(struct thread *t)
 
        r->timeout <<= 1;
        if (r->timeout > 64) r->timeout = 2;
-       THREAD_TIMER_MSEC_ON(master, r->t_register, nhrp_reg_send_req, r, 10);
+       thread_add_timer_msec(master, nhrp_reg_send_req, r, 10,
+                             &r->t_register);
 
        return 0;
 }
@@ -122,7 +124,8 @@ static void nhrp_reg_peer_notify(struct notifier_block *n, unsigned long cmd)
                debugf(NHRP_DEBUG_COMMON, "NHS: Flush timer for %s",
                        sockunion2str(&r->peer->vc->remote.nbma, buf, sizeof buf));
                THREAD_TIMER_OFF(r->t_register);
-               THREAD_TIMER_MSEC_ON(master, r->t_register, nhrp_reg_send_req, r, 10);
+               thread_add_timer_msec(master, nhrp_reg_send_req, r, 10,
+                                     &r->t_register);
                break;
        }
 }
@@ -145,11 +148,13 @@ static int nhrp_reg_send_req(struct thread *t)
        if (!nhrp_peer_check(r->peer, 2)) {
                debugf(NHRP_DEBUG_COMMON, "NHS: Waiting link for %s",
                        sockunion2str(&r->peer->vc->remote.nbma, buf1, sizeof buf1));
-               THREAD_TIMER_ON(master, r->t_register, nhrp_reg_send_req, r, 120);
+               thread_add_timer(master, nhrp_reg_send_req, r, 120,
+                                &r->t_register);
                return 0;
        }
 
-       THREAD_TIMER_ON(master, r->t_register, nhrp_reg_timeout, r, r->timeout);
+       thread_add_timer(master, nhrp_reg_timeout, r, r->timeout,
+                        &r->t_register);
 
        /* RFC2332 5.2.3 NHC uses it's own address as dst if NHS is unknown */
        dst_proto = &nhs->proto_addr;
@@ -223,11 +228,13 @@ static void nhrp_nhs_resolve_cb(struct resolver_query *q, int n, union sockunion
        nhs->t_resolve = NULL;
        if (n < 0) {
                /* Failed, retry in a moment */
-               THREAD_TIMER_ON(master, nhs->t_resolve, nhrp_nhs_resolve, nhs, 5);
+               thread_add_timer(master, nhrp_nhs_resolve, nhs, 5,
+                                &nhs->t_resolve);
                return;
        }
 
-       THREAD_TIMER_ON(master, nhs->t_resolve, nhrp_nhs_resolve, nhs, 2*60*60);
+       thread_add_timer(master, nhrp_nhs_resolve, nhs, 2 * 60 * 60,
+                        &nhs->t_resolve);
 
        list_for_each_entry(reg, &nhs->reglist_head, reglist_entry)
                reg->mark = 1;
@@ -252,7 +259,8 @@ static void nhrp_nhs_resolve_cb(struct resolver_query *q, int n, union sockunion
                list_init(&reg->reglist_entry);
                list_add_tail(&reg->reglist_entry, &nhs->reglist_head);
                nhrp_peer_notify_add(reg->peer, &reg->peer_notifier, nhrp_reg_peer_notify);
-               THREAD_TIMER_MSEC_ON(master, reg->t_register, nhrp_reg_send_req, reg, 50);
+               thread_add_timer_msec(master, nhrp_reg_send_req, reg, 50,
+                                     &reg->t_register);
        }
 
        list_for_each_entry_safe(reg, regn, &nhs->reglist_head, reglist_entry) {
@@ -300,7 +308,8 @@ int nhrp_nhs_add(struct interface *ifp, afi_t afi, union sockunion *proto_addr,
                .reglist_head = LIST_INITIALIZER(nhs->reglist_head),
        };
        list_add_tail(&nhs->nhslist_entry, &nifp->afi[afi].nhslist_head);
-       THREAD_TIMER_MSEC_ON(master, nhs->t_resolve, nhrp_nhs_resolve, nhs, 1000);
+       thread_add_timer_msec(master, nhrp_nhs_resolve, nhs, 1000,
+                             &nhs->t_resolve);
 
        return NHRP_OK;
 }
index 36dbdfd7772d1589dfa88884b22c3d1ed5b3b2e5..76c5f15170f00b403a1615df3dd584beed56bba4 100644 (file)
@@ -269,7 +269,7 @@ static int nhrp_packet_recvraw(struct thread *t)
        uint8_t addr[64];
        size_t len, addrlen;
 
-       thread_add_read(master, nhrp_packet_recvraw, 0, fd);
+       thread_add_read(master, nhrp_packet_recvraw, 0, fd, NULL);
 
        zb = zbuf_alloc(1500);
        if (!zb) return 0;
@@ -307,6 +307,6 @@ err:
 
 int nhrp_packet_init(void)
 {
-       thread_add_read(master, nhrp_packet_recvraw, 0, os_socket());
+       thread_add_read(master, nhrp_packet_recvraw, 0, os_socket(), NULL);
        return 0;
 }
index 3cc91a90832886483017a414b666482c502d081d..5f1e43a6084d7de6310b886aef5b1c7cff414064 100644 (file)
@@ -79,9 +79,8 @@ static void __nhrp_peer_check(struct nhrp_peer *p)
                         * the up notification a bit to allow things
                         * settle down. This allows IKE to install
                         * SPDs and SAs. */
-                       THREAD_TIMER_MSEC_ON(
-                               master, p->t_fallback,
-                               nhrp_peer_notify_up, p, 50);
+                       thread_add_timer_msec(master, nhrp_peer_notify_up, p,
+                                             50, &p->t_fallback);
                } else {
                        nhrp_peer_ref(p);
                        p->online = online;
@@ -230,7 +229,8 @@ static int nhrp_peer_request_timeout(struct thread *t)
                p->fallback_requested = 1;
                vici_request_vc(nifp->ipsec_fallback_profile,
                                &vc->local.nbma, &vc->remote.nbma, p->prio);
-               THREAD_TIMER_ON(master, p->t_fallback, nhrp_peer_request_timeout, p, 30);
+               thread_add_timer(master, nhrp_peer_request_timeout, p, 30,
+                                &p->t_fallback);
        } else {
                p->requested = p->fallback_requested = 0;
        }
@@ -258,8 +258,9 @@ int nhrp_peer_check(struct nhrp_peer *p, int establish)
        p->prio = establish > 1;
        p->requested = 1;
        vici_request_vc(nifp->ipsec_profile, &vc->local.nbma, &vc->remote.nbma, p->prio);
-       THREAD_TIMER_ON(master, p->t_fallback, nhrp_peer_request_timeout, p,
-                       (nifp->ipsec_fallback_profile && !p->prio) ? 15 : 30);
+       thread_add_timer(master, nhrp_peer_request_timeout, p,
+                        (nifp->ipsec_fallback_profile && !p->prio) ? 15 : 30,
+                        &p->t_fallback);
 
        return 0;
 }
index cd33ff0280f11fd5bbaf94d1f13963ac5cd120c5..4a6cbce31fda0b84eb28730e7d2e642db1cddb8c 100644 (file)
@@ -38,7 +38,8 @@ static int nhrp_shortcut_do_expire(struct thread *t)
        struct nhrp_shortcut *s = THREAD_ARG(t);
 
        s->t_timer = NULL;
-       THREAD_TIMER_ON(master, s->t_timer, nhrp_shortcut_do_purge, s, s->holding_time/3);
+       thread_add_timer(master, nhrp_shortcut_do_purge, s,
+                        s->holding_time / 3, &s->t_timer);
        s->expiring = 1;
        nhrp_shortcut_check_use(s);
 
@@ -103,7 +104,8 @@ static void nhrp_shortcut_update_binding(struct nhrp_shortcut *s, enum nhrp_cach
        if (holding_time) {
                s->expiring = 0;
                s->holding_time = holding_time;
-               THREAD_TIMER_ON(master, s->t_timer, nhrp_shortcut_do_expire, s, 2*holding_time/3);
+               thread_add_timer(master, nhrp_shortcut_do_expire, s,
+                                2 * holding_time / 3, &s->t_timer);
        }
 }
 
@@ -180,7 +182,7 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid, void *ar
 
        nhrp_reqid_free(&nhrp_packet_reqid, &s->reqid);
        THREAD_OFF(s->t_timer);
-       THREAD_TIMER_ON(master, s->t_timer, nhrp_shortcut_do_purge, s, 1);
+       thread_add_timer(master, nhrp_shortcut_do_purge, s, 1, &s->t_timer);
 
        if (pp->hdr->type != NHRP_PACKET_RESOLUTION_REPLY) {
                if (pp->hdr->type == NHRP_PACKET_ERROR_INDICATION &&
@@ -326,7 +328,8 @@ void nhrp_shortcut_initiate(union sockunion *addr)
        if (s && s->type != NHRP_CACHE_INCOMPLETE) {
                s->addr = *addr;
                THREAD_OFF(s->t_timer);
-               THREAD_TIMER_ON(master, s->t_timer, nhrp_shortcut_do_purge, s, 30);
+               thread_add_timer(master, nhrp_shortcut_do_purge, s, 30,
+                                &s->t_timer);
                nhrp_shortcut_send_resolution_req(s);
        }
 }
@@ -370,7 +373,8 @@ void nhrp_shortcut_purge(struct nhrp_shortcut *s, int force)
 
        if (force) {
                /* Immediate purge on route with draw or pending shortcut */
-               THREAD_TIMER_MSEC_ON(master, s->t_timer, nhrp_shortcut_do_purge, s, 5);
+               thread_add_timer_msec(master, nhrp_shortcut_do_purge, s, 5,
+                                     &s->t_timer);
        } else {
                /* Soft expire - force immediate renewal, but purge
                 * in few seconds to make sure stale route is not
@@ -379,7 +383,8 @@ void nhrp_shortcut_purge(struct nhrp_shortcut *s, int force)
                 * This allows to keep nhrp route up, and to not
                 * cause temporary rerouting via hubs causing latency
                 * jitter. */
-               THREAD_TIMER_MSEC_ON(master, s->t_timer, nhrp_shortcut_do_purge, s, 3000);
+               thread_add_timer_msec(master, nhrp_shortcut_do_purge, s, 3000,
+                                     &s->t_timer);
                s->expiring = 1;
                nhrp_shortcut_check_use(s);
        }
index 07bdb735a3f1aca6cc4b0c574b988329da41e12c..c29be3cbf987c34aa74cc8b0655199451be1568e 100644 (file)
@@ -47,7 +47,8 @@ static int resolver_cb_socket_readable(struct thread *t)
        ares_process_fd(r->channel, fd, ARES_SOCKET_BAD);
        if (vector_lookup(r->read_threads, fd) == THREAD_RUNNING) {
                t = NULL;
-               THREAD_READ_ON(master, t, resolver_cb_socket_readable, r, fd);
+               thread_add_read(master, resolver_cb_socket_readable, r, fd,
+                               &t);
                vector_set_index(r->read_threads, fd, t);
        }
        resolver_update_timeouts(r);
@@ -64,7 +65,8 @@ static int resolver_cb_socket_writable(struct thread *t)
        ares_process_fd(r->channel, ARES_SOCKET_BAD, fd);
        if (vector_lookup(r->write_threads, fd) == THREAD_RUNNING) {
                t = NULL;
-               THREAD_WRITE_ON(master, t, resolver_cb_socket_writable, r, fd);
+               thread_add_write(master, resolver_cb_socket_writable, r, fd,
+                                &t);
                vector_set_index(r->write_threads, fd, t);
        }
        resolver_update_timeouts(r);
@@ -82,7 +84,8 @@ static void resolver_update_timeouts(struct resolver_state *r)
        tv = ares_timeout(r->channel, NULL, &tvbuf);
        if (tv) {
                unsigned int timeoutms = tv->tv_sec * 1000 + tv->tv_usec / 1000;
-               THREAD_TIMER_MSEC_ON(master, r->timeout, resolver_cb_timeout, r, timeoutms);
+               thread_add_timer_msec(master, resolver_cb_timeout, r,
+                                     timeoutms, &r->timeout);
        }
 }
 
@@ -94,7 +97,8 @@ static void ares_socket_cb(void *data, ares_socket_t fd, int readable, int writa
        if (readable) {
                t = vector_lookup_ensure(r->read_threads, fd);
                if (!t) {
-                       THREAD_READ_ON(master, t, resolver_cb_socket_readable, r, fd);
+                       thread_add_read(master, resolver_cb_socket_readable,
+                                       r, fd, &t);
                        vector_set_index(r->read_threads, fd, t);
                }
        } else {
@@ -110,7 +114,8 @@ static void ares_socket_cb(void *data, ares_socket_t fd, int readable, int writa
        if (writable) {
                t = vector_lookup_ensure(r->write_threads, fd);
                if (!t) {
-                       THREAD_READ_ON(master, t, resolver_cb_socket_writable, r, fd);
+                       thread_add_read(master, resolver_cb_socket_writable,
+                                       r, fd, &t);
                        vector_set_index(r->write_threads, fd, t);
                }
        } else {
index 5491bacf7c329d7cf8f7f9cbbdbbdc9394c6e615..244562d547985385d1cac50be6a5f4f95076035b 100644 (file)
@@ -73,7 +73,7 @@ static void vici_connection_error(struct vici_conn *vici)
 
        close(vici->fd);
        vici->fd = -1;
-       THREAD_TIMER_ON(master, vici->t_reconnect, vici_reconnect, vici, 2);
+       thread_add_timer(master, vici_reconnect, vici, 2, &vici->t_reconnect);
 }
 
 static void vici_parse_message(
@@ -324,7 +324,7 @@ static int vici_read(struct thread *t)
                vici_recv_message(vici, &pktbuf);
        } while (1);
 
-       THREAD_READ_ON(master, vici->t_read, vici_read, vici, vici->fd);
+       thread_add_read(master, vici_read, vici, vici->fd, &vici->t_read);
        return 0;
 }
 
@@ -336,7 +336,8 @@ static int vici_write(struct thread *t)
        vici->t_write = NULL;
        r = zbufq_write(&vici->obuf, vici->fd);
        if (r > 0) {
-               THREAD_WRITE_ON(master, vici->t_write, vici_write, vici, vici->fd);
+               thread_add_write(master, vici_write, vici, vici->fd,
+                                &vici->t_write);
        } else if (r < 0) {
                vici_connection_error(vici);
        }
@@ -352,7 +353,7 @@ static void vici_submit(struct vici_conn *vici, struct zbuf *obuf)
        }
 
        zbufq_queue(&vici->obuf, obuf);
-       THREAD_WRITE_ON(master, vici->t_write, vici_write, vici, vici->fd);
+       thread_add_write(master, vici_write, vici, vici->fd, &vici->t_write);
 }
 
 static void vici_submit_request(struct vici_conn *vici, const char *name, ...)
@@ -422,13 +423,14 @@ static int vici_reconnect(struct thread *t)
        if (fd < 0) {
                zlog_warn("%s: failure connecting VICI socket: %s",
                        __PRETTY_FUNCTION__, strerror(errno));
-               THREAD_TIMER_ON(master, vici->t_reconnect, vici_reconnect, vici, 2);
+               thread_add_timer(master, vici_reconnect, vici, 2,
+                                &vici->t_reconnect);
                return 0;
        }
 
        debugf(NHRP_DEBUG_COMMON, "VICI: Connected");
        vici->fd = fd;
-       THREAD_READ_ON(master, vici->t_read, vici_read, vici, vici->fd);
+       thread_add_read(master, vici_read, vici, vici->fd, &vici->t_read);
 
        /* Send event subscribtions */
        //vici_register_event(vici, "child-updown");
@@ -451,7 +453,8 @@ void vici_init(void)
        vici->fd = -1;
        zbuf_init(&vici->ibuf, vici->ibuf_data, sizeof(vici->ibuf_data), 0);
        zbufq_init(&vici->obuf);
-       THREAD_TIMER_MSEC_ON(master, vici->t_reconnect, vici_reconnect, vici, 10);
+       thread_add_timer_msec(master, vici_reconnect, vici, 10,
+                             &vici->t_reconnect);
 }
 
 void vici_terminate(void)
index fed50212087f4c11bd968ffd625e7d0b0535baa6..3bc55441c8d8c8ccfe5941fafab1032ab3381e9d 100644 (file)
@@ -251,7 +251,7 @@ ospf6_bfd_interface_dest_update (int command, struct zclient *zclient,
       if ((status == BFD_STATUS_DOWN) && (old_status == BFD_STATUS_UP))
         {
           THREAD_OFF (on->inactivity_timer);
-          thread_add_event (master, inactivity_timer, on, 0);
+          thread_add_event(master, inactivity_timer, on, 0, NULL);
         }
     }
 
index 6ac93d8984a811ddfc2570daef4ed856189a28fa..3cbeb759d992f2b6a10ad3a57bec3d8dcba17ce4 100644 (file)
@@ -112,8 +112,8 @@ 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);
+  lsa->refresh = thread_add_timer(master, ospf6_lsa_refresh, lsa,
+                                  OSPF_LS_REFRESH_TIME, NULL);
 
   if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type) ||
       IS_OSPF6_DEBUG_ORIGINATE_TYPE (lsa->header->type))
@@ -226,8 +226,9 @@ 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);
+    lsa->expire = thread_add_timer(master, ospf6_lsa_expire, lsa,
+                                   OSPF_LSA_MAXAGE + lsa->birth.tv_sec - now.tv_sec,
+                                   NULL);
   else
     lsa->expire = NULL;
 
@@ -363,8 +364,8 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
       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);
+          thread_add_timer(master, ospf6_lsupdate_send_neighbor, on,
+                           on->ospf6_if->rxmt_interval, NULL);
       retrans_added++;
     }
 
@@ -408,7 +409,7 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
       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);
+          thread_add_event(master, ospf6_lsupdate_send_interface, oi, 0, NULL);
     }
   else
     {
@@ -417,7 +418,8 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
         {
           THREAD_OFF (on->thread_send_lsupdate);
           on->thread_send_lsupdate =
-            thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0);
+            thread_add_event(master, ospf6_lsupdate_send_neighbor, on, 0,
+                             NULL);
         }
     }
 }
@@ -579,7 +581,8 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
           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);
+              thread_add_timer(master, ospf6_lsack_send_interface, oi, 3,
+                               NULL);
         }
       else
         {
@@ -603,7 +606,8 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
           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);
+              thread_add_timer(master, ospf6_lsack_send_interface, oi, 3,
+                               NULL);
         }
       else
         {
@@ -623,7 +627,7 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
       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);
+          thread_add_event(master, ospf6_lsack_send_neighbor, from, 0, NULL);
       return;
     }
 
@@ -667,7 +671,7 @@ ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent,
       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);
+          thread_add_timer(master, ospf6_lsack_send_interface, oi, 3, NULL);
       return;
     }
 
@@ -691,7 +695,7 @@ ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent,
       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);
+          thread_add_event(master, ospf6_lsack_send_neighbor, from, 0, NULL);
       return;
     }
 
@@ -830,7 +834,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
       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);
+          thread_add_event(master, ospf6_lsack_send_neighbor, from, 0, NULL);
 
       /* b) Discard */
       ospf6_lsa_delete (new);
@@ -912,7 +916,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);
+          new->refresh = thread_add_event(master, ospf6_lsa_refresh, new, 0,
+                                          NULL);
         }
 
       return;
@@ -932,7 +937,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
         }
 
       /* BadLSReq */
-      thread_add_event (master, bad_lsreq, from, 0);
+      thread_add_event(master, bad_lsreq, from, 0, NULL);
 
       ospf6_lsa_delete (new);
       return;
@@ -1000,7 +1005,8 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
           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);
+              thread_add_event(master, ospf6_lsupdate_send_neighbor, from, 0,
+                               NULL);
          ospf6_lsa_delete (new);
          return;
         }
index 8cf7f4afaadb83a5e68e5ac55fbe618de9173e70..d75b1098fa4c48ef488b8b2789fea79a5aee4907 100644 (file)
@@ -392,9 +392,9 @@ ospf6_interface_state_update (struct interface *ifp)
   if (if_is_operative (ifp)
       && (ospf6_interface_get_linklocal_address(oi->interface)
           || if_is_loopback(oi->interface)))
-    thread_add_event (master, interface_up, oi, 0);
+    thread_add_event(master, interface_up, oi, 0, NULL);
   else
-    thread_add_event (master, interface_down, oi, 0);
+    thread_add_event(master, interface_down, oi, 0, NULL);
 
   return;
 }
@@ -671,7 +671,7 @@ dr_election (struct ospf6_interface *oi)
           if (on->state < OSPF6_NEIGHBOR_TWOWAY)
             continue;
           /* Schedule AdjOK. */
-          thread_add_event (master, adj_ok, on, 0);
+          thread_add_event(master, adj_ok, on, 0, NULL);
         }
     }
 
@@ -740,8 +740,8 @@ interface_up (struct thread *thread)
         {
           zlog_info("Scheduling %s for sso retry, trial count: %d",
                     oi->interface->name, oi->sso_try_cnt);
-          thread_add_timer (master, interface_up, oi,
-                            OSPF6_INTERFACE_SSO_RETRY_INT);
+          thread_add_timer(master, interface_up, oi,
+                           OSPF6_INTERFACE_SSO_RETRY_INT, NULL);
         }
       return 0;
     }
@@ -753,7 +753,8 @@ 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);
+    oi->thread_send_hello = thread_add_event(master, ospf6_hello_send, oi, 0,
+                                             NULL);
 
   /* decide next interface state */
   if ((if_is_pointopoint (oi->interface)) ||
@@ -765,7 +766,7 @@ interface_up (struct thread *thread)
   else
     {
       ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
-      thread_add_timer (master, wait_timer, oi, oi->dead_interval);
+      thread_add_timer(master, wait_timer, oi, oi->dead_interval, NULL);
     }
 
   return 0;
@@ -1140,7 +1141,7 @@ DEFUN (ipv6_ospf6_ifmtu,
   for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
     {
       THREAD_OFF (on->inactivity_timer);
-      thread_add_event (master, inactivity_timer, on, 0);
+      thread_add_event(master, inactivity_timer, on, 0, NULL);
     }
 
   return CMD_SUCCESS;
@@ -1187,7 +1188,7 @@ DEFUN (no_ipv6_ospf6_ifmtu,
   for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
     {
       THREAD_OFF (on->inactivity_timer);
-      thread_add_event (master, inactivity_timer, on, 0);
+      thread_add_event(master, inactivity_timer, on, 0, NULL);
     }
 
   return CMD_SUCCESS;
@@ -1490,7 +1491,7 @@ DEFUN (ipv6_ospf6_passive,
   for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
     {
       THREAD_OFF (on->inactivity_timer);
-      thread_add_event (master, inactivity_timer, on, 0);
+      thread_add_event(master, inactivity_timer, on, 0, NULL);
     }
 
   return CMD_SUCCESS;
@@ -1517,7 +1518,7 @@ 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);
+    thread_add_event(master, ospf6_hello_send, oi, 0, NULL);
 
   return CMD_SUCCESS;
 }
@@ -1685,8 +1686,8 @@ DEFUN (ipv6_ospf6_network,
       }
 
   /* Reset the interface */
-  thread_add_event (master, interface_down, oi, 0);
-  thread_add_event (master, interface_up, oi, 0);
+  thread_add_event(master, interface_down, oi, 0, NULL);
+  thread_add_event(master, interface_up, oi, 0, NULL);
 
   return CMD_SUCCESS;
 }
@@ -1720,8 +1721,8 @@ DEFUN (no_ipv6_ospf6_network,
   oi->type = type;
 
   /* Reset the interface */
-  thread_add_event (master, interface_down, oi, 0);
-  thread_add_event (master, interface_up, oi, 0);
+  thread_add_event(master, interface_down, oi, 0, NULL);
+  thread_add_event(master, interface_up, oi, 0, NULL);
 
   return CMD_SUCCESS;
 }
@@ -1864,8 +1865,8 @@ ospf6_interface_clear (struct vty *vty, struct interface *ifp)
     zlog_debug ("Interface %s: clear by reset", ifp->name);
 
   /* Reset the interface */
-  thread_add_event (master, interface_down, oi, 0);
-  thread_add_event (master, interface_up, oi, 0);
+  thread_add_event(master, interface_down, oi, 0, NULL);
+  thread_add_event(master, interface_up, oi, 0, NULL);
 }
 
 /* Clear interface */
index c9660b6a5c5551ed212894d5f2330e44899684d6..9975bbd6272e0607a36fa45b817af471407a8b8e 100644 (file)
@@ -156,40 +156,30 @@ struct ospf6_intra_prefix_lsa
 
 #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \
   do { \
-    if (! (oa)->thread_router_lsa \
-        && CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
-      (oa)->thread_router_lsa = \
-        thread_add_event (master, ospf6_router_lsa_originate, oa, 0); \
+    if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
+      thread_add_event (master, ospf6_router_lsa_originate, oa, 0, &(oa)->thread_router_lsa); \
   } while (0)
 #define OSPF6_NETWORK_LSA_SCHEDULE(oi) \
   do { \
-    if (! (oi)->thread_network_lsa \
-        && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
-      (oi)->thread_network_lsa = \
-        thread_add_event (master, ospf6_network_lsa_originate, oi, 0); \
+    if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
+      thread_add_event (master, ospf6_network_lsa_originate, oi, 0, &(oi)->thread_network_lsa); \
   } while (0)
 #define OSPF6_LINK_LSA_SCHEDULE(oi) \
   do { \
-    if (! (oi)->thread_link_lsa \
-        && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
-      (oi)->thread_link_lsa = \
-        thread_add_event (master, ospf6_link_lsa_originate, oi, 0); \
+    if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
+      thread_add_event (master, ospf6_link_lsa_originate, oi, 0, &(oi)->thread_link_lsa); \
   } while (0)
 #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \
   do { \
-    if (! (oa)->thread_intra_prefix_lsa \
-        && CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
-      (oa)->thread_intra_prefix_lsa = \
-        thread_add_event (master, ospf6_intra_prefix_lsa_originate_stub, \
-                          oa, 0); \
+    if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
+      thread_add_event (master, ospf6_intra_prefix_lsa_originate_stub, \
+                        oa, 0, &(oa)->thread_intra_prefix_lsa); \
   } while (0)
 #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \
   do { \
-    if (! (oi)->thread_intra_prefix_lsa \
-        && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
-      (oi)->thread_intra_prefix_lsa = \
-        thread_add_event (master, ospf6_intra_prefix_lsa_originate_transit, \
-                          oi, 0); \
+    if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
+      thread_add_event (master, ospf6_intra_prefix_lsa_originate_transit, \
+                        oi, 0, &(oi)->thread_intra_prefix_lsa); \
   } while (0)
 
 #define OSPF6_NETWORK_LSA_EXECUTE(oi) \
index bea153c9288cf03cfb0b9551dc02a9cfa87a52d4..3ae368f1d036e1bf737c7d6963ea6522bc87b864 100644 (file)
@@ -722,8 +722,8 @@ 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);
+  new->refresh = thread_add_timer(master, ospf6_lsa_refresh, new,
+                                  OSPF_LS_REFRESH_TIME, NULL);
 
   /* store it in the LSDB for self-originated LSAs */
   ospf6_lsdb_add (ospf6_lsa_copy (new), lsdb_self);
index 578b39a6418b3e672e54a5285b2a3e261aa2803a..7ad3736d2a07a7ad95a1eb9d28c890e3f34becbf 100644 (file)
@@ -352,9 +352,9 @@ ospf6_hello_recv (struct in6_addr *src, struct in6_addr *dst,
 
   /* Schedule interface events */
   if (backupseen)
-    thread_add_event (master, backup_seen, oi, 0);
+    thread_add_event (master, backup_seen, oi, 0, NULL);
   if (neighborchange)
-    thread_add_event (master, neighbor_change, oi, 0);
+    thread_add_event (master, neighbor_change, oi, 0, NULL);
 
   if (neighbor_ifindex_change && on->state == OSPF6_NEIGHBOR_FULL)
     OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
@@ -428,7 +428,7 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
         {
           if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
             zlog_debug ("Master/Slave bit mismatch");
-          thread_add_event (master, seqnumber_mismatch, on, 0);
+          thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
           return;
         }
 
@@ -436,7 +436,7 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
         {
           if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
             zlog_debug ("Initialize bit mismatch");
-          thread_add_event (master, seqnumber_mismatch, on, 0);
+          thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
           return;
         }
 
@@ -444,7 +444,7 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
         {
           if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
             zlog_debug ("Option field mismatch");
-          thread_add_event (master, seqnumber_mismatch, on, 0);
+          thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
           return;
         }
 
@@ -453,7 +453,7 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
           if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
             zlog_debug ("Sequence number mismatch (%#lx expected)",
                        (u_long) on->dbdesc_seqnum);
-          thread_add_event (master, seqnumber_mismatch, on, 0);
+          thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
           return;
         }
       break;
@@ -471,7 +471,7 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
       if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
         zlog_debug ("Not duplicate dbdesc in state %s",
                    ospf6_neighbor_state_str[on->state]);
-      thread_add_event (master, seqnumber_mismatch, on, 0);
+      thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
       return;
 
     default:
@@ -517,7 +517,7 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
           if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
             zlog_debug ("SeqNumMismatch (E-bit mismatch), discard");
           ospf6_lsa_delete (his);
-          thread_add_event (master, seqnumber_mismatch, on, 0);
+          thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
           return;
         }
 
@@ -549,19 +549,18 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
   on->dbdesc_seqnum ++;
 
   /* schedule send lsreq */
-  if (on->request_list->count && (on->thread_send_lsreq == NULL))
-    on->thread_send_lsreq =
-      thread_add_event (master, ospf6_lsreq_send, on, 0);
+  if (on->request_list->count)
+    thread_add_event (master, ospf6_lsreq_send, on, 0, &on->thread_send_lsreq);
 
   THREAD_OFF (on->thread_send_dbdesc);
 
   /* More bit check */
   if (! CHECK_FLAG (dbdesc->bits, OSPF6_DBDESC_MBIT) &&
       ! CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT))
-    thread_add_event (master, exchange_done, on, 0);
+    thread_add_event (master, exchange_done, on, 0, NULL);
   else
     on->thread_send_dbdesc =
-      thread_add_event (master, ospf6_dbdesc_send_newone, on, 0);
+      thread_add_event (master, ospf6_dbdesc_send_newone, on, 0, NULL);
 
   /* save last received dbdesc */
   memcpy (&on->dbdesc_last, dbdesc, sizeof (struct ospf6_dbdesc));
@@ -638,7 +637,7 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
             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);
+            thread_add_event (master, ospf6_dbdesc_send, on, 0, NULL);
           return;
         }
 
@@ -646,7 +645,7 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
         {
           if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
             zlog_debug ("Master/Slave bit mismatch");
-          thread_add_event (master, seqnumber_mismatch, on, 0);
+          thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
           return;
         }
 
@@ -654,7 +653,7 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
         {
           if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
             zlog_debug ("Initialize bit mismatch");
-          thread_add_event (master, seqnumber_mismatch, on, 0);
+          thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
           return;
         }
 
@@ -662,7 +661,7 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
         {
           if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
             zlog_debug ("Option field mismatch");
-          thread_add_event (master, seqnumber_mismatch, on, 0);
+          thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
           return;
         }
 
@@ -671,7 +670,7 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
           if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
             zlog_debug ("Sequence number mismatch (%#lx expected)",
                        (u_long) on->dbdesc_seqnum + 1);
-          thread_add_event (master, seqnumber_mismatch, on, 0);
+          thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
           return;
         }
       break;
@@ -684,15 +683,14 @@ 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);
+          thread_add_event (master, ospf6_dbdesc_send, on, 0, &on->thread_send_dbdesc);
           return;
         }
 
       if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
         zlog_debug ("Not duplicate dbdesc in state %s",
                    ospf6_neighbor_state_str[on->state]);
-      thread_add_event (master, seqnumber_mismatch, on, 0);
+      thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
       return;
 
     default:
@@ -735,7 +733,7 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
           if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
             zlog_debug ("E-bit mismatch with LSA Headers");
           ospf6_lsa_delete (his);
-          thread_add_event (master, seqnumber_mismatch, on, 0);
+          thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
           return;
         }
 
@@ -756,14 +754,11 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
   on->dbdesc_seqnum = ntohl (dbdesc->seqnum);
 
   /* schedule send lsreq */
-  if ((on->thread_send_lsreq == NULL) &&
-      (on->request_list->count))
-    on->thread_send_lsreq =
-      thread_add_event (master, ospf6_lsreq_send, on, 0);
+  if (on->request_list->count)
+    thread_add_event (master, ospf6_lsreq_send, on, 0, &on->thread_send_lsreq);
 
   THREAD_OFF (on->thread_send_dbdesc);
-  on->thread_send_dbdesc =
-    thread_add_event (master, ospf6_dbdesc_send_newone, on, 0);
+  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));
@@ -880,7 +875,7 @@ ospf6_lsreq_recv (struct in6_addr *src, struct in6_addr *dst,
               zlog_debug ("Can't find requested [%s Id:%s Adv:%s]",
                          ospf6_lstype_name (e->type), id, adv_router);
             }
-          thread_add_event (master, bad_lsreq, on, 0);
+          thread_add_event (master, bad_lsreq, on, 0, NULL);
           return;
         }
 
@@ -891,8 +886,7 @@ ospf6_lsreq_recv (struct in6_addr *src, struct in6_addr *dst,
 
   /* schedule send lsupdate */
   THREAD_OFF (on->thread_send_lsupdate);
-  on->thread_send_lsupdate =
-    thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0);
+  thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0, &on->thread_send_lsupdate);
 }
 
 /* Verify, that the specified memory area contains exactly N valid IPv6
@@ -1532,7 +1526,7 @@ ospf6_receive (struct thread *thread)
 
   /* add next read thread */
   sockfd = THREAD_FD (thread);
-  thread_add_read (master, ospf6_receive, NULL, sockfd);
+  thread_add_read (master, ospf6_receive, NULL, sockfd, NULL);
 
   /* initialize */
   memset (&src, 0, sizeof (src));
@@ -1739,8 +1733,7 @@ ospf6_hello_send (struct thread *thread)
     }
 
   /* set next thread */
-  oi->thread_send_hello = thread_add_timer (master, ospf6_hello_send,
-                                            oi, oi->hello_interval);
+  thread_add_timer (master, ospf6_hello_send, oi, oi->hello_interval, &oi->thread_send_hello);
 
   memset (sendbuf, 0, iobuflen);
   oh = (struct ospf6_header *) sendbuf;
@@ -1804,9 +1797,9 @@ ospf6_dbdesc_send (struct thread *thread)
 
   /* set next thread if master */
   if (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT))
-    on->thread_send_dbdesc =
-      thread_add_timer (master, ospf6_dbdesc_send, on,
-                        on->ospf6_if->rxmt_interval);
+    thread_add_timer (master, ospf6_dbdesc_send, on,
+                      on->ospf6_if->rxmt_interval,
+                      &on->thread_send_dbdesc);
 
   memset (sendbuf, 0, iobuflen);
   oh = (struct ospf6_header *) sendbuf;
@@ -1896,7 +1889,7 @@ ospf6_dbdesc_send_newone (struct thread *thread)
   if (! CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) && /* Slave */
       ! CHECK_FLAG (on->dbdesc_last.bits, OSPF6_DBDESC_MBIT) &&
       ! CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT))
-    thread_add_event (master, exchange_done, on, 0);
+    thread_add_event (master, exchange_done, on, 0, NULL);
 
   thread_execute (master, ospf6_dbdesc_send, on, 0);
   return 0;
@@ -1927,7 +1920,7 @@ ospf6_lsreq_send (struct thread *thread)
   /* schedule loading_done if request list is empty */
   if (on->request_list->count == 0)
     {
-      thread_add_event (master, loading_done, on, 0);
+      thread_add_event (master, loading_done, on, 0, NULL);
       return 0;
     }
 
@@ -1979,8 +1972,8 @@ ospf6_lsreq_send (struct thread *thread)
   if (on->request_list->count != 0)
     {
       on->thread_send_lsreq =
-       thread_add_timer (master, ospf6_lsreq_send, on,
-                         on->ospf6_if->rxmt_interval);
+         thread_add_timer (master, ospf6_lsreq_send, on,
+                           on->ospf6_if->rxmt_interval, NULL);
     }
 
   return 0;
@@ -2099,11 +2092,11 @@ ospf6_lsupdate_send_neighbor (struct thread *thread)
 
   if (on->lsupdate_list->count != 0)
     on->thread_send_lsupdate =
-      thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0);
+      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);
+                       on->ospf6_if->rxmt_interval, NULL);
   return 0;
 }
 
@@ -2179,7 +2172,7 @@ 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);
+        thread_add_event (master, ospf6_lsupdate_send_interface, oi, 0, NULL);
     }
 
   return 0;
@@ -2223,8 +2216,7 @@ ospf6_lsack_send_neighbor (struct thread *thread)
          /* if we run out of packet size/space here,
             better to try again soon. */
          THREAD_OFF (on->thread_send_lsack);
-         on->thread_send_lsack =
-           thread_add_event (master, ospf6_lsack_send_neighbor, on, 0);
+      thread_add_event (master, ospf6_lsack_send_neighbor, on, 0, &on->thread_send_lsack);
 
          ospf6_lsdb_lsa_unlock (lsa);
          break;
@@ -2248,11 +2240,8 @@ ospf6_lsack_send_neighbor (struct thread *thread)
                  on->ospf6_if, oh);
     }
 
-  if (on->thread_send_lsack == NULL && on->lsack_list->count > 0)
-    {
-      on->thread_send_lsack =
-        thread_add_event (master, ospf6_lsack_send_neighbor, on, 0);
-    }
+  if (on->lsack_list->count > 0)
+    thread_add_event (master, ospf6_lsack_send_neighbor, on, 0, &on->thread_send_lsack);
 
   return 0;
 }
@@ -2295,8 +2284,8 @@ ospf6_lsack_send_interface (struct thread *thread)
          /* if we run out of packet size/space here,
             better to try again soon. */
          THREAD_OFF (oi->thread_send_lsack);
-         oi->thread_send_lsack =
-           thread_add_event (master, ospf6_lsack_send_interface, oi, 0);
+      thread_add_event (master, ospf6_lsack_send_interface, oi, 0,
+                        &oi->thread_send_lsack);
 
          ospf6_lsdb_lsa_unlock (lsa);
          break;
@@ -2324,11 +2313,8 @@ ospf6_lsack_send_interface (struct thread *thread)
        ospf6_send (oi->linklocal_addr, &alldrouters6, oi, oh);
     }
 
-  if (oi->thread_send_lsack == NULL && oi->lsack_list->count > 0)
-    {
-      oi->thread_send_lsack =
-        thread_add_event (master, ospf6_lsack_send_interface, oi, 0);
-    }
+  if (oi->lsack_list->count > 0)
+    thread_add_event (master, ospf6_lsack_send_interface, oi, 0, &oi->thread_send_lsack);
 
   return 0;
 }
index 118210dfc7dc4ecfc927eac8abad7c3ca147ae49..35ac40fc852707f4401bf597e41cf5e5446cad39 100644 (file)
@@ -238,8 +238,8 @@ 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);
+  on->inactivity_timer = thread_add_timer(master, inactivity_timer, on,
+                                          on->ospf6_if->dead_interval, NULL);
 
   if (on->state <= OSPF6_NEIGHBOR_DOWN)
     ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on,
@@ -262,7 +262,7 @@ twoway_received (struct thread *thread)
   if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
     zlog_debug ("Neighbor Event %s: *2Way-Received*", on->name);
 
-  thread_add_event (master, neighbor_change, on->ospf6_if, 0);
+  thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
 
   if (! need_adjacency (on))
     {
@@ -279,7 +279,7 @@ twoway_received (struct thread *thread)
 
   THREAD_OFF (on->thread_send_dbdesc);
   on->thread_send_dbdesc =
-    thread_add_event (master, ospf6_dbdesc_send, on, 0);
+    thread_add_event(master, ospf6_dbdesc_send, on, 0, NULL);
 
   return 0;
 }
@@ -385,9 +385,8 @@ exchange_done (struct thread *thread)
       ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING, on,
                                   OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
 
-      if (on->thread_send_lsreq == NULL)
-       on->thread_send_lsreq =
-         thread_add_event (master, ospf6_lsreq_send, on, 0);
+      thread_add_event(master, ospf6_lsreq_send, on, 0,
+                       &on->thread_send_lsreq);
     }
 
   return 0;
@@ -406,13 +405,13 @@ ospf6_check_nbr_loading (struct ospf6_neighbor *on)
       (on->state == OSPF6_NEIGHBOR_EXCHANGE))
     {
       if (on->request_list->count == 0)
-       thread_add_event (master, loading_done, on, 0);
+       thread_add_event(master, loading_done, on, 0, NULL);
       else if (on->last_ls_req == NULL)
        {
          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);
+           thread_add_event(master, ospf6_lsreq_send, on, 0, NULL);
        }
     }
 }
@@ -461,7 +460,7 @@ adj_ok (struct thread *thread)
 
       THREAD_OFF (on->thread_send_dbdesc);
       on->thread_send_dbdesc =
-        thread_add_event (master, ospf6_dbdesc_send, on, 0);
+        thread_add_event(master, ospf6_dbdesc_send, on, 0, NULL);
 
     }
   else if (on->state >= OSPF6_NEIGHBOR_EXSTART &&
@@ -516,7 +515,7 @@ seqnumber_mismatch (struct thread *thread)
   on->dbdesc_seqnum++;         /* Incr seqnum as per RFC2328, sec 10.3 */
 
   on->thread_send_dbdesc =
-    thread_add_event (master, ospf6_dbdesc_send, on, 0);
+    thread_add_event(master, ospf6_dbdesc_send, on, 0, NULL);
 
   return 0;
 }
@@ -555,7 +554,7 @@ bad_lsreq (struct thread *thread)
   on->dbdesc_seqnum++;         /* Incr seqnum as per RFC2328, sec 10.3 */
 
   on->thread_send_dbdesc =
-    thread_add_event (master, ospf6_dbdesc_send, on, 0);
+    thread_add_event(master, ospf6_dbdesc_send, on, 0, NULL);
 
   return 0;
 }
@@ -577,7 +576,7 @@ oneway_received (struct thread *thread)
 
   ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on,
                               OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD);
-  thread_add_event (master, neighbor_change, on->ospf6_if, 0);
+  thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
 
   ospf6_lsdb_remove_all (on->summary_list);
   ospf6_lsdb_remove_all (on->request_list);
@@ -613,7 +612,7 @@ inactivity_timer (struct thread *thread)
 
   ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on,
                               OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER);
-  thread_add_event (master, neighbor_change, on->ospf6_if, 0);
+  thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
 
   listnode_delete (on->ospf6_if->neighbor_list, on);
   ospf6_neighbor_delete (on);
index 333ce5588e6a2b83526de4085fc99a509adee3e7..25a4226665b3708162fc089d0a2aa45cc2a8976a 100644 (file)
@@ -728,7 +728,8 @@ 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);
+    thread_add_timer_msec(master, ospf6_spf_calculation_thread, ospf6, delay,
+                          NULL);
 }
 
 void
index e592d3c4f9cde60e587cc7a4e069e007861a1d40..fbb3316ba3f23a3b1557dcfa1bb7f7e196416411 100644 (file)
@@ -287,8 +287,9 @@ 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);
+    o->maxage_remover = thread_add_timer(master, ospf6_maxage_remover, o,
+                                         OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT,
+                                         NULL);
 }
 
 /* start ospf6 */
index aa219c78071f78944089ecce7867c793a0cfcf41..7933975707d5f9e52e4e7d9ce0ff2ca32ed0e4d1 100644 (file)
@@ -1252,7 +1252,7 @@ ospf6_init (void)
 
   /* Make ospf protocol socket. */
   ospf6_serv_sock ();
-  thread_add_read (master, ospf6_receive, NULL, ospf6_sock);
+  thread_add_read(master, ospf6_receive, NULL, ospf6_sock, NULL);
 }
 
 void
index 43ffa1da8ee628f88c26a1cef41ed636b1edfcb3..1c2ec7d1cc6e57304af216742255f6f2a9de3cd4 100644 (file)
@@ -168,7 +168,7 @@ lsa_read (struct thread *thread)
   }
 
   /* Reschedule read thread */
-  thread_add_read (master, lsa_read, oclient, fd);
+  thread_add_read(master, lsa_read, oclient, fd, NULL);
 
   return 0;
 }
@@ -224,13 +224,13 @@ ready_callback (u_char lsa_type, u_char opaque_type, struct in_addr addr)
          lsa_type, opaque_type, inet_ntoa (addr));
 
   /* Schedule opaque LSA originate in 5 secs */
-  thread_add_timer (master, lsa_inject, oclient, 5);
+  thread_add_timer(master, lsa_inject, oclient, 5, NULL);
 
   /* Schedule opaque LSA update with new value */
-  thread_add_timer (master, lsa_inject, oclient, 10);
+  thread_add_timer(master, lsa_inject, oclient, 10, NULL);
 
   /* Schedule delete */
-  thread_add_timer (master, lsa_delete, oclient, 30);
+  thread_add_timer(master, lsa_delete, oclient, 30, NULL);
 }
 
 static void
@@ -340,7 +340,7 @@ main (int argc, char *argv[])
   ospf_apiclient_sync_lsdb (oclient);
 
   /* Schedule thread that handles asynchronous messages */
-  thread_add_read (master, lsa_read, oclient, oclient->fd_async);
+  thread_add_read(master, lsa_read, oclient, oclient->fd_async, NULL);
 
   /* Now connection is established, run loop */
   while (1)
index a54170e04800497b8ef846e9dbbd8c1397fedc47..ee90ceccf9ff0a4af247f2952729796edc6a7931 100644 (file)
@@ -1881,7 +1881,6 @@ ospf_schedule_abr_task (struct ospf *ospf)
   if (IS_DEBUG_OSPF_EVENT)
     zlog_debug ("Scheduling ABR task");
 
-  if (ospf->t_abr_task == NULL)
-    ospf->t_abr_task = thread_add_timer (master, ospf_abr_task_timer,
-                                        ospf, OSPF_ABR_TASK_DELAY);
+  thread_add_timer(master, ospf_abr_task_timer, ospf, OSPF_ABR_TASK_DELAY,
+                   &ospf->t_abr_task);
 }
index 620dacb1576d41feed7fe11baf7e24c63163946f..5c514e18f817de04e9b40099fbe07831d244231f 100644 (file)
@@ -301,30 +301,32 @@ ospf_apiserver_event (enum event event, int fd,
   switch (event)
     {
     case OSPF_APISERVER_ACCEPT:
-      (void)thread_add_read (master, ospf_apiserver_accept, apiserv, 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);
+       thread_add_read(master, ospf_apiserver_read, apiserv, fd, NULL);
       break;
 #ifdef USE_ASYNC_READ
     case OSPF_APISERVER_ASYNC_READ:
       apiserv->t_async_read =
-       thread_add_read (master, ospf_apiserver_read, apiserv, fd);
+       thread_add_read(master, ospf_apiserver_read, apiserv, fd, NULL);
       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);
+           thread_add_write(master, ospf_apiserver_sync_write, apiserv, fd,
+                             NULL);
        }
       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);
+           thread_add_write(master, ospf_apiserver_async_write, apiserv, fd,
+                             NULL);
        }
       break;
     }
index b063f317e2524ed188e2e0736a3476cba08bc65d..a30df199371945d397282df0cbdd9e83e6b3b74b 100644 (file)
@@ -705,9 +705,8 @@ ospf_ase_calculate_timer_add (struct ospf *ospf)
   if (ospf == NULL)
     return;
 
-  if (! ospf->t_ase_calc)
-    ospf->t_ase_calc = thread_add_timer (master, ospf_ase_calculate_timer,
-                                        ospf, OSPF_ASE_CALC_INTERVAL);
+  thread_add_timer(master, ospf_ase_calculate_timer, ospf,
+                   OSPF_ASE_CALC_INTERVAL, &ospf->t_ase_calc);
 }
 
 void
index fa8e6d70f67f8adf0110d4fe6e7646a928830816..180000ae972aa42556ac42cc22aea2592afa0651 100644 (file)
 #define ISM_InterfaceDown                 7
 #define OSPF_ISM_EVENT_MAX                8
 
-#define OSPF_ISM_WRITE_ON(O)                                                  \
-      do                                                                      \
-        {                                                                     \
-          if (oi->on_write_q == 0)                                            \
-           {                                                                 \
-              listnode_add ((O)->oi_write_q, oi);                             \
-             oi->on_write_q = 1;                                             \
-           }                                                                 \
-         if ((O)->t_write == NULL)                                           \
-           (O)->t_write =                                                    \
-             thread_add_write (master, ospf_write, (O), (O)->fd);            \
-        } while (0)
+#define OSPF_ISM_WRITE_ON(O) \
+  do \
+    { \
+      if (oi->on_write_q == 0) \
+        { \
+          listnode_add ((O)->oi_write_q, oi); \
+          oi->on_write_q = 1; \
+        } \
+      thread_add_write (master, ospf_write, (O), (O)->fd, &(O)->t_write); \
+    } while (0)
      
 /* Macro for OSPF ISM timer turn on. */
 #define OSPF_ISM_TIMER_ON(T,F,V) \
-  do { \
-    if (!(T)) \
-      (T) = thread_add_timer (master, (F), oi, (V)); \
-  } while (0)
+    thread_add_timer (master, (F), oi, (V), &(T))
+
 #define OSPF_ISM_TIMER_MSEC_ON(T,F,V) \
-  do { \
-    if (!(T)) \
-      (T) = thread_add_timer_msec (master, (F), oi, (V)); \
-  } while (0)
+    thread_add_timer_msec (master, (F), oi, (V), &(T))
 
 /* convenience macro to set hello timer correctly, according to
  * whether fast-hello is set or not
@@ -98,7 +91,7 @@
 
 /* Macro for OSPF schedule event. */
 #define OSPF_ISM_EVENT_SCHEDULE(I,E) \
-      thread_add_event (master, ospf_ism_event, (I), (E))
+      thread_add_event (master, ospf_ism_event, (I), (E), NULL)
 
 /* Macro for OSPF execute event. */
 #define OSPF_ISM_EVENT_EXECUTE(I,E) \
index cf9943893ad15782fba0b80d57bc490667e9ed6d..570e15176408f9ad5e191347284df61bf3d13589 100644 (file)
@@ -3553,7 +3553,7 @@ ospf_schedule_lsa_flood_area (struct ospf_area *area, struct ospf_lsa *lsa)
   data->area = area;
   data->lsa  = ospf_lsa_lock (lsa); /* Message / Flood area */
 
-  thread_add_event (master, ospf_lsa_action, data, 0);
+  thread_add_event(master, ospf_lsa_action, data, 0, NULL);
 }
 
 void
@@ -3566,7 +3566,7 @@ ospf_schedule_lsa_flush_area (struct ospf_area *area, struct ospf_lsa *lsa)
   data->area = area;
   data->lsa  = ospf_lsa_lock (lsa); /* Message / Flush area */
 
-  thread_add_event (master, ospf_lsa_action, data, 0);
+  thread_add_event(master, ospf_lsa_action, data, 0, NULL);
 }
 
 
@@ -3741,8 +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);
+  ospf->t_lsa_refresher = thread_add_timer(master, ospf_lsa_refresh_walker,
+                                           ospf, ospf->lsa_refresh_interval,
+                                           NULL);
   ospf->lsa_refresher_started = monotime(NULL);
 
   for (ALL_LIST_ELEMENTS (lsa_to_refresh, node, nnode, lsa))
index 4531f6ec7da0ed52e5593618c0f34ef5aee5f553..2bd8f065cf94c80cb752e304badadbd828b30f27 100644 (file)
 #define OSPF_NSM_EVENT_MAX     14
 
 /* Macro for OSPF NSM timer turn on. */
-#define OSPF_NSM_TIMER_ON(T,F,V)                                              \
-      do {                                                                    \
-        if (!(T))                                                             \
-          (T) = thread_add_timer (master, (F), nbr, (V));                     \
-      } while (0)
+#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)                                                 \
@@ -75,7 +71,7 @@
 
 /* Macro for OSPF NSM schedule event. */
 #define OSPF_NSM_EVENT_SCHEDULE(N,E)                                          \
-      thread_add_event (master, ospf_nsm_event, (N), (E))
+      thread_add_event (master, ospf_nsm_event, (N), (E), NULL)
 
 /* Macro for OSPF NSM execute event. */
 #define OSPF_NSM_EVENT_EXECUTE(N,E)                                           \
index 56efa2ebd68d9718df7d03e5e64b88f382fad660..0c1830166f024bad8648c0ccc0ad72010303b50c 100644 (file)
@@ -1343,7 +1343,8 @@ 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);
+       thread_add_timer_msec(master, ospf_opaque_type9_lsa_originate, oi,
+                              delay, NULL);
       delay += top->min_ls_interval;
     }
 
@@ -1359,8 +1360,8 @@ 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);
+        thread_add_timer_msec(master, ospf_opaque_type10_lsa_originate, area,
+                              delay, NULL);
       delay += top->min_ls_interval;
     }
 
@@ -1376,8 +1377,8 @@ 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);
+        thread_add_timer_msec(master, ospf_opaque_type11_lsa_originate, top,
+                              delay, NULL);
       delay += top->min_ls_interval;
     }
 
@@ -1654,9 +1655,7 @@ ospf_opaque_lsa_refresh (struct ospf_lsa *lsa)
  * triggered by external interventions (vty session, signaling, etc).
  *------------------------------------------------------------------------*/
 
-#define OSPF_OPAQUE_TIMER_ON(T,F,L,V) \
-      if (!(T)) \
-        (T) = thread_add_timer_msec (master, (F), (L), (V))
+#define OSPF_OPAQUE_TIMER_ON(T,F,L,V) thread_add_timer_msec (master, (F), (L), (V), &(T))
 
 static struct ospf_lsa *pseudo_lsa (struct ospf_interface *oi, struct ospf_area *area, u_char lsa_type, u_char opaque_type);
 static int ospf_opaque_type9_lsa_reoriginate_timer (struct thread *t);
index b7721adb3e53d8ff70ce7b21b3561c248c3a0c60..6b5b0e4edd96672e5b45e7a0d67f8d06284144d1 100644 (file)
@@ -487,7 +487,7 @@ 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);
+  nbr->t_ls_req = thread_add_event(master, ospf_ls_req_timer, nbr, 0, NULL);
 }
 
 /* Cyclic timer function.  Fist registered in ospf_nbr_new () in
@@ -852,7 +852,7 @@ 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);
+      thread_add_write(master, ospf_write, ospf, ospf->fd, NULL);
 
   return 0;
 }
@@ -2772,7 +2772,7 @@ 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);
+  ospf->t_read = thread_add_read(master, ospf_read, ospf, ospf->fd, NULL);
 
   stream_reset(ospf->ibuf);
   if (!(ibuf = ospf_recv_packet (ospf->fd, &ifp, ospf->ibuf)))
@@ -3803,7 +3803,7 @@ ospf_ls_upd_send_queue_event (struct thread *thread)
         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);
+        thread_add_event(master, ospf_ls_upd_send_queue_event, oi, 0, NULL);
     }
 
   if (IS_DEBUG_OSPF_EVENT)
@@ -3858,9 +3858,8 @@ ospf_ls_upd_send (struct ospf_neighbor *nbr, struct list *update, int flag)
   for (ALL_LIST_ELEMENTS_RO (update, node, lsa))
     listnode_add (rn->info, ospf_lsa_lock (lsa)); /* oi->ls_upd_queue */
 
-  if (oi->t_ls_upd_event == NULL)
-    oi->t_ls_upd_event =
-      thread_add_event (master, ospf_ls_upd_send_queue_event, oi, 0);
+  thread_add_event(master, ospf_ls_upd_send_queue_event, oi, 0,
+                   &oi->t_ls_upd_event);
 }
 
 static void
@@ -3921,9 +3920,8 @@ ospf_ls_ack_send (struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
   
   listnode_add (oi->ls_ack_direct.ls_ack, ospf_lsa_lock (lsa));
   
-  if (oi->t_ls_ack_direct == NULL)
-    oi->t_ls_ack_direct =
-      thread_add_event (master, ospf_ls_ack_send_event, oi, 0);
+  thread_add_event(master, ospf_ls_ack_send_event, oi, 0,
+                   &oi->t_ls_ack_direct);
 }
 
 /* Send Link State Acknowledgment delayed. */
index 31f0d9d286f5620c2d005bb2a28a3aa861954c9a..d54ebc8b43f268d89047e9d1ad7f668ac46c923c 100644 (file)
@@ -1465,5 +1465,5 @@ 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);
+    thread_add_timer_msec(master, ospf_spf_calculate_timer, ospf, delay, NULL);
 }
index abb6db0347862bda899ee7c2e98b4ce5fc1f7ff1..314c9e72b437025a319a353ece6aedbee7162600 100644 (file)
@@ -883,7 +883,7 @@ ospf_redistribute_default_set (struct ospf *ospf, int originate,
   if (ospf->router_id.s_addr == 0)
     ospf->external_origin |= (1 << DEFAULT_ROUTE);
   else
-    thread_add_timer (master, ospf_default_originate_timer, ospf, 1);
+    thread_add_timer(master, ospf_default_originate_timer, ospf, 1, NULL);
 
   ospf_asbr_status_update (ospf, ++ospf->redistribute);
 
@@ -1279,8 +1279,8 @@ ospf_distribute_list_update (struct ospf *ospf, uintptr_t type,
 
   /* Set timer. */
   ospf->t_distribute_update =
-    thread_add_timer_msec (master, ospf_distribute_list_update_timer,
-                           (void *) type, ospf->min_ls_interval);
+    thread_add_timer_msec(master, ospf_distribute_list_update_timer,
+                          (void *)type, ospf->min_ls_interval, NULL);
 }
 
 /* If access-list is updated, apply some check. */
index 30b1e9622f1c1480015ac268f0ac00be704ca34a..40f35c6d33bb63fb844c5bbdd10f892998747541 100644 (file)
@@ -135,11 +135,12 @@ ospf_router_id_update (struct ospf *ospf)
          /* Originate each redistributed external route. */
          for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
            if (ospf->external_origin & (1 << type))
-             thread_add_event (master, ospf_external_lsa_originate_timer,
-                               ospf, type);
+             thread_add_event(master, ospf_external_lsa_originate_timer,
+                               ospf, type, NULL);
          /* Originate Deafult. */
          if (ospf->external_origin & (1 << ZEBRA_ROUTE_MAX))
-           thread_add_event (master, ospf_default_originate_timer, ospf, 0);
+           thread_add_event(master, ospf_default_originate_timer, ospf, 0,
+                             NULL);
 
          ospf->external_origin = 0;
        }
@@ -184,9 +185,9 @@ ospf_router_id_update (struct ospf *ospf)
 
       /* Originate each redistributed external route. */
       for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
-        thread_add_event (master, ospf_external_lsa_originate_timer,
-                          ospf, type);
-      thread_add_event (master, ospf_default_originate_timer, ospf, 0);
+        thread_add_event(master, ospf_external_lsa_originate_timer, ospf,
+                         type, NULL);
+      thread_add_event(master, ospf_default_originate_timer, ospf, 0, NULL);
 
       /* update router-lsa's for each area */
       ospf_router_lsa_update (ospf);
@@ -264,16 +265,17 @@ ospf_new (u_short instance)
   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);
+    thread_add_timer(master, ospf_lsa_maxage_walker, new,
+                     OSPF_LSA_MAXAGE_CHECK_INTERVAL, NULL);
 
   /* 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);
+  new->t_lsa_refresher = thread_add_timer(master, ospf_lsa_refresh_walker,
+                                          new, new->lsa_refresh_interval,
+                                          NULL);
   new->lsa_refresher_started = monotime(NULL);
 
   if ((new->fd = ospf_sock_init()) < 0)
@@ -288,7 +290,7 @@ ospf_new (u_short instance)
               OSPF_MAX_PACKET_SIZE+1);
       exit(1);
     }
-  new->t_read = thread_add_read (master, ospf_read, new, new->fd);
+  new->t_read = thread_add_read(master, ospf_read, new, new->fd, NULL);
   new->oi_write_q = list_new ();
   new->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
   
@@ -1593,7 +1595,8 @@ ospf_timers_refresh_set (struct ospf *ospf, int interval)
     {
       OSPF_TIMER_OFF (ospf->t_lsa_refresher);
       ospf->t_lsa_refresher =
-       thread_add_timer (master, ospf_lsa_refresh_walker, ospf, interval);
+       thread_add_timer(master, ospf_lsa_refresh_walker, ospf, interval,
+                         NULL);
     }
   ospf->lsa_refresh_interval = interval;
 
@@ -1612,8 +1615,8 @@ ospf_timers_refresh_unset (struct ospf *ospf)
     {
       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);
+       thread_add_timer(master, ospf_lsa_refresh_walker, ospf,
+                         OSPF_LSA_REFRESH_INTERVAL_DEFAULT, NULL);
     }
 
   ospf->lsa_refresh_interval = OSPF_LSA_REFRESH_INTERVAL_DEFAULT;
index 9198d5c6203918a15cdae46af54ad3d8b69ba3ba..c5b0324b86b54c7b4f8fbbda7e05d6660f97217d 100644 (file)
@@ -480,26 +480,10 @@ struct ospf_nbr_nbma
 #define LSA_OPTIONS_NSSA_GET(area) \
         (((area)->external_routing == OSPF_AREA_NSSA)  ? OSPF_OPTION_NP : 0)
 
-#define OSPF_TIMER_ON(T,F,V)                                                  \
-    do {                                                                      \
-      if (!(T))                                                               \
-       (T) = thread_add_timer (master, (F), ospf, (V));                      \
-    } while (0)
-
-#define OSPF_AREA_TIMER_ON(T,F,V)                                             \
-    do {                                                                      \
-      if (!(T))                                                               \
-        (T) = thread_add_timer (master, (F), area, (V));                      \
-    } while (0)
-
-#define OSPF_POLL_TIMER_ON(T,F,V)                                             \
-    do {                                                                      \
-      if (!(T))                                                               \
-        (T) = thread_add_timer (master, (F), nbr_nbma, (V));                  \
-    } while (0)
-
-#define OSPF_POLL_TIMER_OFF(X)         OSPF_TIMER_OFF((X))
-
+#define OSPF_TIMER_ON(T,F,V) thread_add_timer (master,(F),ospf,(V),&(T))
+#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)                                                                  \
index 17f5fcfe0f9a321b872ea3940e1abf970b9d4611..a11cce94331f8f889c448933758434630cddae97 100644 (file)
@@ -576,9 +576,8 @@ static void pim_assert_timer_set(struct pim_ifchannel *ch,
               ch->sg_str, interval, ch->interface->name);
   }
 
-  THREAD_TIMER_ON(master, ch->t_ifassert_timer,
-                 on_assert_timer,
-                 ch, interval);
+  thread_add_timer(master, on_assert_timer, ch, interval,
+                   &ch->t_ifassert_timer);
 }
 
 static void pim_assert_timer_reset(struct pim_ifchannel *ch)
index f4fe609605bcd2dbedfe2baf0e1ab2bc7804054d..9f986313350414ddf7ecb43f887ddddcb60c799a 100644 (file)
@@ -855,9 +855,8 @@ void pim_ifchannel_join_add(struct interface *ifp,
   }
 
   if (holdtime != 0xFFFF) {
-    THREAD_TIMER_ON(master, ch->t_ifjoin_expiry_timer,
-                   on_ifjoin_expiry_timer,
-                   ch, holdtime);
+    thread_add_timer(master, on_ifjoin_expiry_timer, ch, holdtime,
+                     &ch->t_ifjoin_expiry_timer);
   }
 }
 
@@ -907,12 +906,11 @@ void pim_ifchannel_prune(struct interface *ifp,
 
        THREAD_OFF(ch->t_ifjoin_prune_pending_timer);
        THREAD_OFF(ch->t_ifjoin_expiry_timer);
-       THREAD_TIMER_MSEC_ON(master, ch->t_ifjoin_prune_pending_timer,
-                            on_ifjoin_prune_pending_timer,
-                            ch, jp_override_interval_msec);
-       THREAD_TIMER_ON(master, ch->t_ifjoin_expiry_timer,
-                       on_ifjoin_expiry_timer,
-                       ch, holdtime);
+       thread_add_timer_msec(master, on_ifjoin_prune_pending_timer, ch,
+                              jp_override_interval_msec,
+                              &ch->t_ifjoin_prune_pending_timer);
+       thread_add_timer(master, on_ifjoin_expiry_timer, ch, holdtime,
+                         &ch->t_ifjoin_expiry_timer);
         pim_upstream_update_join_desired(ch->upstream);
       }
     break;
@@ -932,17 +930,16 @@ void pim_ifchannel_prune(struct interface *ifp,
         be taken not to use "ch" afterwards since it would be
         deleted. */
     THREAD_OFF(ch->t_ifjoin_prune_pending_timer);
-    THREAD_TIMER_MSEC_ON(master, ch->t_ifjoin_prune_pending_timer,
-                        on_ifjoin_prune_pending_timer,
-                        ch, jp_override_interval_msec);
+    thread_add_timer_msec(master, on_ifjoin_prune_pending_timer, ch,
+                          jp_override_interval_msec,
+                          &ch->t_ifjoin_prune_pending_timer);
     break;
   case PIM_IFJOIN_PRUNE:
     if (source_flags & PIM_ENCODE_RPT_BIT)
       {
        THREAD_OFF(ch->t_ifjoin_prune_pending_timer);
-       THREAD_TIMER_ON(master, ch->t_ifjoin_expiry_timer,
-                       on_ifjoin_expiry_timer,
-                       ch, holdtime);
+       thread_add_timer(master, on_ifjoin_expiry_timer, ch, holdtime,
+                         &ch->t_ifjoin_expiry_timer);
       }
     break;
   case PIM_IFJOIN_PRUNE_TMP:
@@ -950,9 +947,8 @@ void pim_ifchannel_prune(struct interface *ifp,
       {
        ch->ifjoin_state = PIM_IFJOIN_PRUNE;
        THREAD_OFF(ch->t_ifjoin_expiry_timer);
-       THREAD_TIMER_ON(master, ch->t_ifjoin_expiry_timer,
-                       on_ifjoin_expiry_timer,
-                       ch, holdtime);
+       thread_add_timer(master, on_ifjoin_expiry_timer, ch, holdtime,
+                         &ch->t_ifjoin_expiry_timer);
       }
     break;
   case PIM_IFJOIN_PRUNE_PENDING_TMP:
@@ -960,9 +956,8 @@ void pim_ifchannel_prune(struct interface *ifp,
       {
        ch->ifjoin_state = PIM_IFJOIN_PRUNE_PENDING;
        THREAD_OFF(ch->t_ifjoin_expiry_timer);
-       THREAD_TIMER_ON(master, ch->t_ifjoin_expiry_timer,
-                       on_ifjoin_expiry_timer,
-                       ch, holdtime);
+       thread_add_timer(master, on_ifjoin_expiry_timer, ch, holdtime,
+                         &ch->t_ifjoin_expiry_timer);
       }
     break;
   }
index ee88e7d8eada2ff6f60b92fb7b109220bdc83893..af0ddef232f28940ae2ca0cdb70fbf397ab5040e 100644 (file)
@@ -247,9 +247,9 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp)
               other_querier_present_interval_msec % 1000);
   }
   
-  THREAD_TIMER_MSEC_ON(master, igmp->t_other_querier_timer,
-                      pim_igmp_other_querier_expire,
-                      igmp, other_querier_present_interval_msec);
+  thread_add_timer_msec(master, pim_igmp_other_querier_expire, igmp,
+                        other_querier_present_interval_msec,
+                        &igmp->t_other_querier_timer);
 }
 
 void pim_igmp_other_querier_timer_off(struct igmp_sock *igmp)
@@ -551,9 +551,8 @@ void pim_igmp_general_query_on(struct igmp_sock *igmp)
               igmp->fd);
   }
   igmp->t_igmp_query_timer = NULL;
-  THREAD_TIMER_ON(master, igmp->t_igmp_query_timer,
-                 pim_igmp_general_query,
-                 igmp, query_interval);
+  thread_add_timer(master, pim_igmp_general_query, igmp, query_interval,
+                   &igmp->t_igmp_query_timer);
 }
 
 void pim_igmp_general_query_off(struct igmp_sock *igmp)
@@ -896,7 +895,7 @@ igmp_read_on (struct igmp_sock *igmp)
               igmp->fd);
   }
   igmp->t_igmp_read = NULL;
-  THREAD_READ_ON(master, igmp->t_igmp_read, pim_igmp_read, igmp, igmp->fd);
+  thread_add_read(master, pim_igmp_read, igmp, igmp->fd, &igmp->t_igmp_read);
 
 }
 
@@ -1029,9 +1028,8 @@ void igmp_group_timer_on(struct igmp_group *group,
   */
   zassert(group->group_filtermode_isexcl);
 
-  THREAD_TIMER_MSEC_ON(master, group->t_group_timer,
-                      igmp_group_timer,
-                      group, interval_msec);
+  thread_add_timer_msec(master, igmp_group_timer, group, interval_msec,
+                        &group->t_group_timer);
 }
 
 struct igmp_group *
index 86509a20c4898b754b503abb0c5682cfb6f6cd2e..e0b1d3fc2a3d7ee663c925a6d9df16b2459bda56 100644 (file)
@@ -215,9 +215,8 @@ static void igmp_source_timer_on(struct igmp_group *group,
               group->group_igmp_sock->interface->name);
   }
 
-  THREAD_TIMER_MSEC_ON(master, source->t_source_timer,
-                      igmp_source_timer,
-                      source, interval_msec);
+  thread_add_timer_msec(master, igmp_source_timer, source, interval_msec,
+                        &source->t_source_timer);
   zassert(source->t_source_timer);
 
   /*
@@ -1328,9 +1327,8 @@ static void group_retransmit_timer_on(struct igmp_group *group)
               igmp->interface->name);
   }
 
-  THREAD_TIMER_MSEC_ON(master, group->t_group_query_retransmit_timer,
-                      igmp_group_retransmit,
-                      group, lmqi_msec);
+  thread_add_timer_msec(master, igmp_group_retransmit, group, lmqi_msec,
+                        &group->t_group_query_retransmit_timer);
 }
 
 static long igmp_group_timer_remain_msec(struct igmp_group *group)
index ce2f98f318bcf6d58bcd9cb15586bd4c1f5a6ded..76851fa81058141d07965b57ae142468185d57ca 100644 (file)
@@ -636,8 +636,8 @@ static void mroute_read_on()
 {
   zassert(!qpim_mroute_socket_reader);
 
-  THREAD_READ_ON(master, qpim_mroute_socket_reader,
-                mroute_read, 0, qpim_mroute_socket_fd);
+  thread_add_read(master, mroute_read, 0, qpim_mroute_socket_fd,
+                  &qpim_mroute_socket_reader);
 }
 
 static void mroute_read_off()
index 93141f39dedb4521b74f7da186d81de337fdcc9d..06cc24ddba02925c483ceb3e385e24fd5c2f82ae 100644 (file)
@@ -82,8 +82,8 @@ pim_msdp_sa_adv_timer_setup(bool start)
 {
   THREAD_OFF(msdp->sa_adv_timer);
   if (start) {
-    THREAD_TIMER_ON(msdp->master, msdp->sa_adv_timer,
-        pim_msdp_sa_adv_timer_cb, NULL, PIM_MSDP_SA_ADVERTISMENT_TIME);
+    thread_add_timer(msdp->master, pim_msdp_sa_adv_timer_cb, NULL,
+                     PIM_MSDP_SA_ADVERTISMENT_TIME, &msdp->sa_adv_timer);
   }
 }
 
@@ -108,8 +108,8 @@ pim_msdp_sa_state_timer_setup(struct pim_msdp_sa *sa, bool start)
 {
   THREAD_OFF(sa->sa_state_timer);
   if (start) {
-    THREAD_TIMER_ON(msdp->master, sa->sa_state_timer,
-        pim_msdp_sa_state_timer_cb, sa, PIM_MSDP_SA_HOLD_TIME);
+    thread_add_timer(msdp->master, pim_msdp_sa_state_timer_cb, sa,
+                     PIM_MSDP_SA_HOLD_TIME, &sa->sa_state_timer);
   }
 }
 
@@ -920,8 +920,8 @@ pim_msdp_peer_hold_timer_setup(struct pim_msdp_peer *mp, bool start)
 {
   THREAD_OFF(mp->hold_timer);
   if (start) {
-    THREAD_TIMER_ON(msdp->master, mp->hold_timer,
-        pim_msdp_peer_hold_timer_cb, mp, PIM_MSDP_PEER_HOLD_TIME);
+    thread_add_timer(msdp->master, pim_msdp_peer_hold_timer_cb, mp,
+                     PIM_MSDP_PEER_HOLD_TIME, &mp->hold_timer);
   }
 }
 
@@ -948,8 +948,8 @@ pim_msdp_peer_ka_timer_setup(struct pim_msdp_peer *mp, bool start)
 {
   THREAD_OFF(mp->ka_timer);
   if (start) {
-    THREAD_TIMER_ON(msdp->master, mp->ka_timer,
-        pim_msdp_peer_ka_timer_cb, mp, PIM_MSDP_PEER_KA_TIME);
+    thread_add_timer(msdp->master, pim_msdp_peer_ka_timer_cb, mp,
+                     PIM_MSDP_PEER_KA_TIME, &mp->ka_timer);
   }
 }
 
@@ -1013,8 +1013,8 @@ pim_msdp_peer_cr_timer_setup(struct pim_msdp_peer *mp, bool start)
 {
   THREAD_OFF(mp->cr_timer);
   if (start) {
-    THREAD_TIMER_ON(msdp->master, mp->cr_timer,
-        pim_msdp_peer_cr_timer_cb, mp, PIM_MSDP_PEER_CONNECT_RETRY_TIME);
+    thread_add_timer(msdp->master, pim_msdp_peer_cr_timer_cb, mp,
+                     PIM_MSDP_PEER_CONNECT_RETRY_TIME, &mp->cr_timer);
   }
 }
 
index 33c1d88a45592e343d1ba832cc71e4df3928593d..57a7c224402186855755c615c7643a1cda374ca6 100644 (file)
@@ -197,8 +197,11 @@ struct pim_msdp {
   struct pim_msdp_mg *mg;
 };
 
-#define PIM_MSDP_PEER_READ_ON(mp) THREAD_READ_ON(msdp->master, mp->t_read, pim_msdp_read, mp, mp->fd);
-#define PIM_MSDP_PEER_WRITE_ON(mp) THREAD_WRITE_ON(msdp->master, mp->t_write, pim_msdp_write, mp, mp->fd);
+#define PIM_MSDP_PEER_READ_ON(mp) \
+  thread_add_read (msdp->master, pim_msdp_read, mp, mp->fd, &mp->t_read)
+
+#define PIM_MSDP_PEER_WRITE_ON(mp) \
+  thread_add_write (msdp->master, pim_msdp_write, mp, mp->fd, &mp->t_write)
 
 #define PIM_MSDP_PEER_READ_OFF(mp) THREAD_READ_OFF(mp->t_read)
 #define PIM_MSDP_PEER_WRITE_OFF(mp) THREAD_WRITE_OFF(mp->t_write)
index 805e812caed5f27d62ae511c8452fcd4997a1bff..b09dd635a06823cc8374e5f9fbfffe82a55ad622 100644 (file)
@@ -70,8 +70,8 @@ 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);
+  listener->thread = thread_add_read(master, pim_msdp_sock_accept, listener,
+                                     accept_sock, NULL);
 
   /* accept client connection. */
   msdp_sock = sockunion_accept(accept_sock, &su);
@@ -173,7 +173,8 @@ 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);
+  listener->thread = thread_add_read(msdp->master, pim_msdp_sock_accept,
+                                     listener, sock, NULL);
 
   msdp->flags |= PIM_MSDPF_LISTENER;
   return 0;
index de0f75e38072f96057a32d5f68def74cc06eab99..5dccc3cfb77a5189f7e180964fed9d91101ca1da 100644 (file)
@@ -262,9 +262,8 @@ void pim_neighbor_timer_reset(struct pim_neighbor *neigh, uint16_t holdtime)
               neigh->holdtime, src_str, neigh->interface->name);
   }
 
-  THREAD_TIMER_ON(master, neigh->t_expire_timer,
-                 on_neighbor_timer,
-                 neigh, neigh->holdtime);
+  thread_add_timer(master, on_neighbor_timer, neigh, neigh->holdtime,
+                   &neigh->t_expire_timer);
 }
 
 static int
@@ -286,9 +285,8 @@ on_neighbor_jp_timer (struct thread *t)
   rpf.rpf_addr.u.prefix4 = neigh->source_addr;
   pim_joinprune_send(&rpf, neigh->upstream_jp_agg);
 
-  THREAD_TIMER_ON(master, neigh->jp_timer,
-                  on_neighbor_jp_timer,
-                  neigh, qpim_t_periodic);
+  thread_add_timer(master, on_neighbor_jp_timer, neigh, qpim_t_periodic,
+                   &neigh->jp_timer);
 
   return 0;
 }
@@ -297,9 +295,8 @@ static void
 pim_neighbor_start_jp_timer (struct pim_neighbor *neigh)
 {
   THREAD_TIMER_OFF(neigh->jp_timer);
-  THREAD_TIMER_ON(master, neigh->jp_timer,
-                  on_neighbor_jp_timer,
-                  neigh, qpim_t_periodic);
+  thread_add_timer(master, on_neighbor_jp_timer, neigh, qpim_t_periodic,
+                   &neigh->jp_timer);
 }
 
 static struct pim_neighbor *pim_neighbor_new(struct interface *ifp,
index 9886cd6ad29ab23fc59f986b0f59047efa0b217b..57b9e6c793b9eda2b8e92ddbb2bf18b61eb98797 100644 (file)
@@ -383,8 +383,8 @@ static void pim_sock_read_on(struct interface *ifp)
               pim_ifp->pim_sock_fd);
   }
   pim_ifp->t_pim_sock_read = NULL;
-  THREAD_READ_ON(master, pim_ifp->t_pim_sock_read, pim_sock_read, ifp,
-                pim_ifp->pim_sock_fd);
+  thread_add_read(master, pim_sock_read, ifp, pim_ifp->pim_sock_fd,
+                  &pim_ifp->t_pim_sock_read);
 }
 
 static int pim_sock_open(struct interface *ifp)
@@ -703,9 +703,8 @@ static void hello_resched(struct interface *ifp)
               pim_ifp->pim_hello_period, ifp->name);
   }
   THREAD_OFF(pim_ifp->t_pim_hello_timer);
-  THREAD_TIMER_ON(master, pim_ifp->t_pim_hello_timer,
-                 on_pim_hello_send,
-                 ifp, pim_ifp->pim_hello_period);
+  thread_add_timer(master, on_pim_hello_send, ifp, pim_ifp->pim_hello_period,
+                   &pim_ifp->t_pim_hello_timer);
 }
 
 /*
@@ -814,9 +813,8 @@ void pim_hello_restart_triggered(struct interface *ifp)
               random_msec, ifp->name);
   }
 
-  THREAD_TIMER_MSEC_ON(master, pim_ifp->t_pim_hello_timer,
-                      on_pim_hello_send,
-                      ifp, random_msec);
+  thread_add_timer_msec(master, on_pim_hello_send, ifp, random_msec,
+                        &pim_ifp->t_pim_hello_timer);
 }
 
 int pim_sock_add(struct interface *ifp)
index 76b327ab071210a9714107581400af0867a8adfc..eda044f184515cc70ccb6c279a5ae6d0828bb6cf 100644 (file)
@@ -331,8 +331,8 @@ static int ssmpingd_sock_read(struct thread *t)
 static void ssmpingd_read_on(struct ssmpingd_sock *ss)
 {
   zassert(!ss->t_sock_read);
-  THREAD_READ_ON(master, ss->t_sock_read,
-                ssmpingd_sock_read, ss, ss->sock_fd);
+  thread_add_read(master, ssmpingd_sock_read, ss, ss->sock_fd,
+                  &ss->t_sock_read);
 }
 
 static struct ssmpingd_sock *ssmpingd_new(struct in_addr source_addr)
index dd6eab9cfe8766bce4ce75d7ae4b8ae203d760f4..88b6694147d52b57612a4096a8eb2cb7a0f5e4de 100644 (file)
@@ -340,9 +340,8 @@ join_timer_start(struct pim_upstream *up)
   else
     {
       THREAD_OFF (up->t_join_timer);
-      THREAD_TIMER_ON(master, up->t_join_timer,
-                      on_join_timer,
-                      up, qpim_t_periodic);
+      thread_add_timer(master, on_join_timer, up, qpim_t_periodic,
+                       &up->t_join_timer);
     }
   pim_jp_agg_upstream_verification (up, true);
 }
@@ -371,9 +370,8 @@ static void pim_upstream_join_timer_restart_msec(struct pim_upstream *up,
   }
 
   THREAD_OFF(up->t_join_timer);
-  THREAD_TIMER_MSEC_ON(master, up->t_join_timer,
-                      on_join_timer,
-                      up, interval_msec);
+  thread_add_timer_msec(master, on_join_timer, up, interval_msec,
+                        &up->t_join_timer);
 }
 
 void pim_upstream_join_suppress(struct pim_upstream *up,
@@ -1119,10 +1117,8 @@ pim_upstream_keep_alive_timer_start (struct pim_upstream *up,
       zlog_debug ("kat start on %s with no stream reference", up->sg_str);
   }
   THREAD_OFF (up->t_ka_timer);
-  THREAD_TIMER_ON (master,
-                  up->t_ka_timer,
-                  pim_upstream_keep_alive_timer,
-                  up, time);
+  thread_add_timer(master, pim_upstream_keep_alive_timer, up, time,
+                   &up->t_ka_timer);
 
   /* any time keepalive is started against a SG we will have to
    * re-evaluate our active source database */
@@ -1146,8 +1142,8 @@ void
 pim_upstream_msdp_reg_timer_start(struct pim_upstream *up)
 {
   THREAD_OFF(up->t_msdp_reg_timer);
-  THREAD_TIMER_ON(master, up->t_msdp_reg_timer,
-      pim_upstream_msdp_reg_timer, up, PIM_MSDP_REG_RXED_PERIOD);
+  thread_add_timer(master, pim_upstream_msdp_reg_timer, up,
+                   PIM_MSDP_REG_RXED_PERIOD, &up->t_msdp_reg_timer);
 
   pim_msdp_sa_local_update(up);
 }
@@ -1408,9 +1404,8 @@ pim_upstream_start_register_stop_timer (struct pim_upstream *up, int null_regist
       zlog_debug ("%s: (S,G)=%s Starting upstream register stop timer %d",
                  __PRETTY_FUNCTION__, up->sg_str, time);
     }
-  THREAD_TIMER_ON (master, up->t_rs_timer,
-                  pim_upstream_register_stop_timer,
-                  up, time);
+  thread_add_timer(master, pim_upstream_register_stop_timer, up, time,
+                   &up->t_rs_timer);
 }
 
 int
index b2a7319bf1740bc856ecd99d307f7d7be3db2965..62be3a69ddabc41674430aea777b4ede7e239311 100644 (file)
@@ -617,9 +617,9 @@ void sched_rpf_cache_refresh(void)
                qpim_rpf_cache_refresh_delay_msec);
   }
 
-  THREAD_TIMER_MSEC_ON(master, qpim_rpf_cache_refresher,
-                       on_rpf_cache_refresh,
-                       0, qpim_rpf_cache_refresh_delay_msec);
+  thread_add_timer_msec(master, on_rpf_cache_refresh, 0,
+                        qpim_rpf_cache_refresh_delay_msec,
+                        &qpim_rpf_cache_refresher);
 }
 
 static void
index 27bd1370438a5593ca67cb36d67f1cea2fd93749..01632182df916eac51118b19904fc7c83e617a39 100644 (file)
@@ -77,9 +77,8 @@ static void zclient_lookup_sched(struct zclient *zlookup, int delay)
 {
   zassert(!zlookup->t_connect);
 
-  THREAD_TIMER_ON(master, zlookup->t_connect,
-                 zclient_lookup_connect,
-                 zlookup, delay);
+  thread_add_timer(master, zclient_lookup_connect, zlookup, delay,
+                   &zlookup->t_connect);
 
   zlog_notice("%s: zclient lookup connection scheduled for %d seconds",
              __PRETTY_FUNCTION__, delay);
@@ -91,7 +90,7 @@ 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);
+                                        zlookup, 0, NULL);
 
   zlog_notice("%s: zclient lookup immediate connection scheduled",
              __PRETTY_FUNCTION__);
index a4ee2ba57053ed2acd966850ecd022003be83c89..57c49c631316e14057bd91af1b31b18251f85cd5 100644 (file)
@@ -1011,9 +1011,8 @@ rip_enable_apply (struct interface *ifp)
            zlog_debug ("turn on %s", ifp->name);
 
          /* Add interface wake up thread. */
-         if (! ri->t_wakeup)
-           ri->t_wakeup = thread_add_timer (master, rip_interface_wakeup,
-                                            ifp, 1);
+         thread_add_timer(master, rip_interface_wakeup, ifp, 1,
+                           &ri->t_wakeup);
           rip_connect_set (ifp, 1);
        }
     }
index 6a3add640ad8ec61dc25f60513011bbdbd864b57..f907f43f4b1787792e7b29f229a42b0deb353c1f 100644 (file)
@@ -107,8 +107,8 @@ 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);
+  peer->t_timeout = thread_add_timer(master, rip_peer_timeout, peer,
+                                     RIP_PEER_TIMER_DEFAULT, NULL);
 
   /* Last update time set. */
   time (&peer->uptime);
index b668b0a0b41b942e91c6edaf76fd01c63a98d26f..24bb48381e41923b2f860d691c5ce5d2a1f37e88 100644 (file)
@@ -2626,7 +2626,7 @@ rip_triggered_update (struct thread *t)
   interval = (random () % 5) + 1;
 
   rip->t_triggered_interval = 
-    thread_add_timer (master, rip_triggered_interval, NULL, interval);
+    thread_add_timer(master, rip_triggered_interval, NULL, interval, NULL);
 
   return 0;
 }
@@ -2781,21 +2781,20 @@ rip_event (enum rip_event event, int sock)
   switch (event)
     {
     case RIP_READ:
-      rip->t_read = thread_add_read (master, rip_read, NULL, sock);
+      rip->t_read = thread_add_read(master, rip_read, NULL, sock, NULL);
       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);
+       thread_add_timer(master, rip_update, NULL,
+                         sock ? 2 : rip->update_time + jitter, NULL);
       break;
     case RIP_TRIGGERED_UPDATE:
       if (rip->t_triggered_interval)
        rip->trigger = 1;
-      else if (! rip->t_triggered_update)
-       rip->t_triggered_update = 
-         thread_add_event (master, rip_triggered_update, NULL, 0);
+      else thread_add_event(master, rip_triggered_update, NULL, 0,
+                            &rip->t_triggered_update);
       break;
     default:
       break;
index eeb008e3d5c35432e6a671aecd4217c1dddea1cc..aad0c2f112588e4c66c57befcd109a87275b5f41 100644 (file)
@@ -371,11 +371,7 @@ enum rip_event
 };
 
 /* Macro for timer turn on. */
-#define RIP_TIMER_ON(T,F,V) \
-  do { \
-    if (!(T)) \
-      (T) = thread_add_timer (master, (F), rinfo, (V)); \
-  } while (0)
+#define RIP_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
 
 /* Macro for timer turn off. */
 #define RIP_TIMER_OFF(X) THREAD_TIMER_OFF(X)
index 1ac9e40f6744aed5c31acfcf43353527a8d0cf48..dbffa1a88a6b878c8e46b0ce8962048309c2798a 100644 (file)
@@ -761,9 +761,8 @@ ripng_enable_apply (struct interface *ifp)
            zlog_debug ("RIPng turn on %s", ifp->name);
 
          /* Add interface wake up thread. */
-         if (! ri->t_wakeup)
-           ri->t_wakeup = thread_add_timer (master, ripng_interface_wakeup,
-                                            ifp, 1);
+         thread_add_timer(master, ripng_interface_wakeup, ifp, 1,
+                           &ri->t_wakeup);
 
          ripng_connect_set (ifp, 1);
        }
index b12e1460412430c3adba346bae0eb2fba28f64f6..61f7b7b9df0bc63a734f48b619cc4604a1bb3a7f 100644 (file)
@@ -115,8 +115,8 @@ 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);
+  peer->t_timeout = thread_add_timer(master, ripng_peer_timeout, peer,
+                                     RIPNG_PEER_TIMER_DEFAULT, NULL);
 
   /* Last update time set. */
   time (&peer->uptime);
index a883bec3c43f491f9fa468b87c7e8e1405678e31..11334339abcb66e1ec90caf2451553f0dbdc6388 100644 (file)
@@ -1540,7 +1540,7 @@ ripng_triggered_update (struct thread *t)
   interval = (random () % 5) + 1;
 
   ripng->t_triggered_interval = 
-    thread_add_timer (master, ripng_triggered_interval, NULL, interval);
+    thread_add_timer(master, ripng_triggered_interval, NULL, interval, NULL);
 
   return 0;
 }
@@ -1898,8 +1898,7 @@ ripng_event (enum ripng_event event, int sock)
   switch (event)
     {
     case RIPNG_READ:
-      if (!ripng->t_read)
-       ripng->t_read = thread_add_read (master, ripng_read, NULL, sock);
+      thread_add_read(master, ripng_read, NULL, sock, &ripng->t_read);
       break;
     case RIPNG_UPDATE_EVENT:
       if (ripng->t_update)
@@ -1911,15 +1910,14 @@ ripng_event (enum ripng_event event, int sock)
       jitter = ripng_update_jitter (ripng->update_time);
 
       ripng->t_update = 
-       thread_add_timer (master, ripng_update, NULL, 
-                         sock ? 2 : ripng->update_time + jitter);
+       thread_add_timer(master, ripng_update, NULL,
+                         sock ? 2 : ripng->update_time + jitter, NULL);
       break;
     case RIPNG_TRIGGERED_UPDATE:
       if (ripng->t_triggered_interval)
        ripng->trigger = 1;
-      else if (! ripng->t_triggered_update)
-       ripng->t_triggered_update = 
-         thread_add_event (master, ripng_triggered_update, NULL, 0);
+      else thread_add_event(master, ripng_triggered_update, NULL, 0,
+                            &ripng->t_triggered_update);
       break;
     default:
       break;
index 70cba3c6804d2bf1e2f362952aee15330c356d02..e40fd17b5694e88e09753957f007283599ed754c 100644 (file)
@@ -324,11 +324,7 @@ enum ripng_event
 };
 
 /* RIPng timer on/off macro. */
-#define RIPNG_TIMER_ON(T,F,V) \
-do { \
-   if (!(T)) \
-      (T) = thread_add_timer (master, (F), rinfo, (V)); \
-} while (0)
+#define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
 
 #define RIPNG_TIMER_OFF(T) \
 do { \
index b3e6e706ff6560bd26b7af31b4407cd3e44398e0..e422c7e6211673a51630534ffd0c180bbc424086 100644 (file)
@@ -59,14 +59,14 @@ test_timer (struct thread *thread)
   int *count = THREAD_ARG(thread);
   
   printf ("run %d of timer\n", (*count)++);
-  thread_add_timer (master, test_timer, count, 5);
+  thread_add_timer(master, test_timer, count, 5, NULL);
   return 0;
 }
 
 static void
 test_timer_init()
 {
-  thread_add_timer (master, test_timer, &timer_count, 10);
+  thread_add_timer(master, test_timer, &timer_count, 10, NULL);
 }
 
 static void
index c43fa76c0ec0a22f879de0cdc7d1626afe97a58b..57f0a6070add911cb749df1ec5b0c1f61c3c0728 100644 (file)
@@ -91,7 +91,7 @@ clear_something (struct thread *thread)
       ws->i++;
       if (thread_should_yield(thread))
         {
-         thread_add_background(master, clear_something, ws, 0);
+         thread_add_background(master, clear_something, ws, 0, NULL);
          return 0;
         }
     }
@@ -135,7 +135,7 @@ DEFUN (clear_foo,
   ws->vty = vty;
   ws->i = ITERS_FIRST;
 
-  thread_add_background(master, clear_something, ws, 0);
+  thread_add_background(master, clear_something, ws, 0, NULL);
 
   return CMD_SUCCESS;
 }
index e523929be11d3c5559beb9b3d5c99d841ced5c28..600aef6f4629ce0f7de764bc08cdd98fcc5ba5fa 100644 (file)
@@ -139,7 +139,8 @@ 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);
+      timers[i] = thread_add_timer_msec(master, timer_func, arg,
+                                        interval_msec, NULL);
       ret = snprintf(arg, TIMESTR_LEN + 1, "%lld.%06lld",
                      (long long)timers[i]->u.sands.tv_sec,
                      (long long)timers[i]->u.sands.tv_usec);
index a7d09beecc9b1b54a91890fd9cceeab533b6494c..d1db4fd1bf8214967d79b39aaa03e176138c4b28 100644 (file)
@@ -57,7 +57,7 @@ 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);
+    timers[i] = thread_add_timer_msec(master, dummy_func, NULL, 0, NULL);
   for (i = 0; i < SCHEDULE_TIMERS; i++)
     thread_cancel(timers[i]);
 
@@ -68,8 +68,8 @@ 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);
+      timers[i] = thread_add_timer_msec(master, dummy_func, NULL,
+                                        interval_msec, NULL);
     }
 
   monotime(&tv_lap);
index 6edce242b3d0af8ebd305badd1bb7c47863f3b16..967678633390fcd313b6eaf126c110e94fa2d015 100644 (file)
@@ -374,7 +374,7 @@ static int restart_kill(struct thread *t_kill)
        kill(-restart->pid, (restart->kills ? SIGKILL : SIGTERM));
        restart->kills++;
        restart->t_kill = thread_add_timer(master, restart_kill, restart,
-                                          gs.restart_timeout);
+                                          gs.restart_timeout, NULL);
        return 0;
 }
 
@@ -489,7 +489,7 @@ run_job(struct restart_info *restart, const char *cmdtype, const char *command,
                if ((restart->pid = run_background(cmd)) > 0) {
                        restart->t_kill =
                            thread_add_timer(master, restart_kill, restart,
-                                            gs.restart_timeout);
+                                            gs.restart_timeout, NULL);
                        restart->what = cmdtype;
                        gs.numpids++;
                } else
@@ -510,19 +510,19 @@ 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)
+  (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))
+                                         FUZZY(gs.period), NULL)
 
 #define SET_WAKEUP_UNRESPONSIVE(DMN)   \
   (DMN)->t_wakeup = thread_add_timer_msec(master,wakeup_unresponsive,(DMN), \
-                                         FUZZY(gs.period))
+                                         FUZZY(gs.period), NULL)
 
 #define SET_WAKEUP_ECHO(DMN) \
   (DMN)->t_wakeup = thread_add_timer_msec(master,wakeup_send_echo,(DMN), \
-                                         FUZZY(gs.period))
+                                         FUZZY(gs.period), NULL)
 
 static int wakeup_down(struct thread *t_wakeup)
 {
@@ -776,10 +776,11 @@ static int try_connect(struct daemon *dmn)
                dmn->state = DAEMON_CONNECTING;
                dmn->fd = sock;
                dmn->t_write =
-                   thread_add_write(master, check_connect, dmn, dmn->fd);
+                   thread_add_write(master, check_connect, dmn, dmn->fd,
+                                    NULL);
                dmn->t_wakeup =
                    thread_add_timer(master, wakeup_connect_hanging, dmn,
-                                    gs.timeout);
+                                    gs.timeout, NULL);
                SET_READ_HANDLER(dmn);
                return 0;
        }
@@ -805,7 +806,7 @@ static void set_phase(restart_phase_t 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);
+                                             PHASE_TIMEOUT, NULL);
 }
 
 static void phase_check(void)
@@ -963,7 +964,8 @@ static int wakeup_send_echo(struct thread *t_wakeup)
        } else {
                gettimeofday(&dmn->echo_sent, NULL);
                dmn->t_wakeup =
-                   thread_add_timer(master, wakeup_no_answer, dmn, gs.timeout);
+                   thread_add_timer(master, wakeup_no_answer, dmn,
+                                    gs.timeout, NULL);
        }
        return 0;
 }
@@ -1312,7 +1314,8 @@ int main(int argc, char **argv)
                        dmn->fd = -1;
                        dmn->t_wakeup =
                            thread_add_timer_msec(master, wakeup_init, dmn,
-                                                 100 + (random() % 900));
+                                                 100 + (random() % 900),
+                                                 NULL);
                        dmn->restart.interval = gs.min_restart_interval;
                        if (tail)
                                tail->next = dmn;
index 5cabe7e62f7339e427cdef0d806708df992ca4b7..cb0cb349deab08c773a092e47d6c605586a7cb73 100644 (file)
@@ -259,10 +259,8 @@ 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);
+  irdp->t_advertise = thread_add_timer(zebrad.master, irdp_send_thread, ifp,
+                                       timer, NULL);
 }
 
 static void
index 7fa4ad4cbe8b5716aecc7070405e7d6d5936bfd9..963c330af41f4f2d65010071a7c6ccb995a3b554 100644 (file)
@@ -114,7 +114,7 @@ irdp_sock_init (void)
     return ret;
   };
 
-  t_irdp_raw = thread_add_read (zebrad.master, irdp_read_raw, NULL, sock); 
+  t_irdp_raw = thread_add_read(zebrad.master, irdp_read_raw, NULL, sock, NULL);
 
   return sock;
 }
@@ -244,7 +244,8 @@ 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);
+  irdp->t_advertise = thread_add_timer(zebrad.master, irdp_send_thread, ifp,
+                                       timer, NULL);
   return 0;
 }
 
@@ -296,10 +297,8 @@ 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);
+  irdp->t_advertise = thread_add_timer(zebrad.master, irdp_send_thread, ifp,
+                                       timer, NULL);
 }
 
 void irdp_finish()
index 4c58b6b35d26e28bef530138af7f9edbfc36030b..ecca40393f50354b875ba05a82a910dfa697b992 100644 (file)
@@ -232,7 +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);
+  t_irdp_raw = thread_add_read(zebrad.master, irdp_read_raw, NULL, irdp_sock,
+                               NULL);
   
   ret = irdp_recvmsg (irdp_sock, (u_char *) buf, IRDP_RX_BUF,  &ifindex);
  
index e97420321990e62f0733f254db2c33feda824cef..59a280f826a98a031bdb68122f48adc03ce885b1 100644 (file)
@@ -283,8 +283,8 @@ 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);
+  zns->t_netlink = thread_add_read(zebrad.master, kernel_read, zns,
+                                   zns->netlink.sock, NULL);
 
   return 0;
 }
@@ -813,8 +813,8 @@ 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);
+      zns->t_netlink = thread_add_read(zebrad.master, kernel_read, zns,
+                                       zns->netlink.sock, NULL);
     }
 }
 
index 7212ed6f26b60895e12ba124a4020917c6d90a3a..0e15153e1dad905ef6683e80150bb50012a15ea7 100644 (file)
@@ -1282,7 +1282,7 @@ kernel_read (struct thread *thread)
       return 0;
     }
 
-  thread_add_read (zebrad.master, kernel_read, NULL, sock);
+  thread_add_read(zebrad.master, kernel_read, NULL, sock, NULL);
 
   if (IS_ZEBRA_DEBUG_KERNEL)
     rtmsg_debug (&buf.r.rtm);
@@ -1355,7 +1355,7 @@ routing_socket (struct zebra_ns *zns)
     zlog_err ("routing_socket: Can't lower privileges");
 
   /* kernel_read needs rewrite. */
-  thread_add_read (zebrad.master, kernel_read, NULL, routing_sock);
+  thread_add_read(zebrad.master, kernel_read, NULL, routing_sock, NULL);
 }
 
 /* Exported interface function.  This function simply calls
index bf67141cd49ff9763561eaa1d9ee749f2e35e584..f7d2dce8f36277ef02c70c405a42b7ac7d4f7c9e 100644 (file)
@@ -141,9 +141,8 @@ static int zclient_connect(struct thread *t)
 
        if (zclient_socket_connect(zclient) < 0) {
                zlog_err("Error connecting synchronous zclient!");
-               THREAD_TIMER_ON(zebrad.master, zclient->t_connect,
-                                               zclient_connect,
-                                               zclient, CONNECTION_DELAY);
+               thread_add_timer(zebrad.master, zclient_connect, zclient,
+                                CONNECTION_DELAY, &zclient->t_connect);
                return -1;
        }
 
index 12e4873adf17d7b73c9a7e17b6c0ee10fcc8b798..03b7ace9b3d500f708aeca1bb17ca6a06864fc84 100644 (file)
@@ -1574,11 +1574,8 @@ rtadv_event (struct zebra_ns *zns, enum rtadv_event event, int val)
   switch (event)
     {
     case RTADV_START:
-      if (! rtadv->ra_read)
-       rtadv->ra_read = thread_add_read (zebrad.master, rtadv_read, zns, val);
-      if (! rtadv->ra_timer)
-       rtadv->ra_timer = thread_add_event (zebrad.master, rtadv_timer,
-                                           zns, 0);
+      thread_add_read(zebrad.master, rtadv_read, zns, val, &rtadv->ra_read);
+      thread_add_event(zebrad.master, rtadv_timer, zns, 0, &rtadv->ra_timer);
       break;
     case RTADV_STOP:
       if (rtadv->ra_timer)
@@ -1593,18 +1590,14 @@ rtadv_event (struct zebra_ns *zns, enum rtadv_event event, int val)
        }
       break;
     case RTADV_TIMER:
-      if (! rtadv->ra_timer)
-       rtadv->ra_timer = thread_add_timer (zebrad.master, rtadv_timer, zns,
-                                           val);
+      thread_add_timer(zebrad.master, rtadv_timer, zns, val, &rtadv->ra_timer);
       break;
     case RTADV_TIMER_MSEC:
-      if (! rtadv->ra_timer)
-       rtadv->ra_timer = thread_add_timer_msec (zebrad.master, rtadv_timer, 
-                                           zns, val);
+      thread_add_timer_msec(zebrad.master, rtadv_timer, zns, val,
+                            &rtadv->ra_timer);
       break;
     case RTADV_READ:
-      if (! rtadv->ra_read)
-       rtadv->ra_read = thread_add_read (zebrad.master, rtadv_read, zns, val);
+      thread_add_read(zebrad.master, rtadv_read, zns, val, &rtadv->ra_read);
       break;
     default:
       break;
index 405b2e9f7976c58a2263374e99124e7321775a2e..281672c9ad77abb235612e5700034acd91bba862 100644 (file)
@@ -487,8 +487,8 @@ zfpm_read_on (void)
   assert (!zfpm_g->t_read);
   assert (zfpm_g->sock >= 0);
 
-  THREAD_READ_ON (zfpm_g->master, zfpm_g->t_read, zfpm_read_cb, 0,
-                 zfpm_g->sock);
+  thread_add_read(zfpm_g->master, zfpm_read_cb, 0, zfpm_g->sock,
+                  &zfpm_g->t_read);
 }
 
 /*
@@ -500,8 +500,8 @@ zfpm_write_on (void)
   assert (!zfpm_g->t_write);
   assert (zfpm_g->sock >= 0);
 
-  THREAD_WRITE_ON (zfpm_g->master, zfpm_g->t_write, zfpm_write_cb, 0,
-                  zfpm_g->sock);
+  thread_add_write(zfpm_g->master, zfpm_write_cb, 0, zfpm_g->sock,
+                   &zfpm_g->t_write);
 }
 
 /*
@@ -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);
+      zfpm_g->t_conn_up = thread_add_background(zfpm_g->master,
+                                                zfpm_conn_up_thread_cb, 0, 0,
+                                                NULL);
       return 0;
     }
 
@@ -599,8 +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);
+  zfpm_g->t_conn_up = thread_add_background(zfpm_g->master,
+                                            zfpm_conn_up_thread_cb, 0, 0,
+                                            NULL);
   zfpm_g->stats.t_conn_up_starts++;
 }
 
@@ -689,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);
+      zfpm_g->t_conn_down = thread_add_background(zfpm_g->master,
+                                                  zfpm_conn_down_thread_cb, 0,
+                                                  0, NULL);
       return 0;
     }
 
@@ -737,8 +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);
+  zfpm_g->t_conn_down = thread_add_background(zfpm_g->master,
+                                              zfpm_conn_down_thread_cb, 0, 0,
+                                              NULL);
   zfpm_g->stats.t_conn_down_starts++;
 
   zfpm_set_state (ZFPM_STATE_IDLE, detail);
@@ -1294,8 +1296,8 @@ zfpm_start_connect_timer (const char *reason)
   delay_secs = zfpm_calc_connect_delay();
   zfpm_debug ("scheduling connect in %ld seconds", delay_secs);
 
-  THREAD_TIMER_ON (zfpm_g->master, zfpm_g->t_connect, zfpm_connect_cb, 0,
-                  delay_secs);
+  thread_add_timer(zfpm_g->master, zfpm_connect_cb, 0, delay_secs,
+                   &zfpm_g->t_connect);
   zfpm_set_state (ZFPM_STATE_ACTIVE, reason);
 }
 
@@ -1434,8 +1436,8 @@ zfpm_start_stats_timer (void)
 {
   assert (!zfpm_g->t_stats);
 
-  THREAD_TIMER_ON (zfpm_g->master, zfpm_g->t_stats, zfpm_stats_timer_cb, 0,
-                  ZFPM_STATS_IVL_SECS);
+  thread_add_timer(zfpm_g->master, zfpm_stats_timer_cb, 0,
+                   ZFPM_STATS_IVL_SECS, &zfpm_g->t_stats);
 }
 
 /*
index bc924842d44de3982c5c76461920555020f273e6..85f3efae8ec77b2fb1b204e533686ab583d9d49b 100644 (file)
@@ -182,12 +182,13 @@ 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);
+      ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect,
+                                        NULL, ptm_cb.reconnect_time, NULL);
       return (-1);
     case BUFFER_PENDING:
-      ptm_cb.t_write = thread_add_write(zebrad.master, zebra_ptm_flush_messages,
-                                        NULL, ptm_cb.ptm_sock);
+      ptm_cb.t_write = thread_add_write(zebrad.master,
+                                        zebra_ptm_flush_messages, NULL,
+                                        ptm_cb.ptm_sock, NULL);
       break;
     case BUFFER_EMPTY:
       break;
@@ -207,15 +208,15 @@ 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);
+      ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect,
+                                        NULL, ptm_cb.reconnect_time, NULL);
       return -1;
     case BUFFER_EMPTY:
       THREAD_OFF(ptm_cb.t_write);
       break;
     case BUFFER_PENDING:
-      THREAD_WRITE_ON(zebrad.master, ptm_cb.t_write,
-                     zebra_ptm_flush_messages, NULL, ptm_cb.ptm_sock);
+      thread_add_write(zebrad.master, zebra_ptm_flush_messages, NULL,
+                       ptm_cb.ptm_sock, &ptm_cb.t_write);
       break;
     }
 
@@ -234,8 +235,8 @@ 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);
+      ptm_cb.t_read = thread_add_read(zebrad.master, zebra_ptm_sock_read,
+                                      NULL, ptm_cb.ptm_sock, NULL);
       zebra_bfd_peer_replay_req();
     }
     zebra_ptm_send_status_req();
@@ -245,8 +246,8 @@ 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);
+    ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect, NULL,
+                                      ptm_cb.reconnect_time, NULL);
   } else if (ptm_cb.reconnect_time >= ZEBRA_PTM_RECONNECT_TIME_MAX){
     ptm_cb.reconnect_time = ZEBRA_PTM_RECONNECT_TIME_INITIAL;
   }
@@ -653,14 +654,14 @@ 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);
+      ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect,
+                                        NULL, ptm_cb.reconnect_time, NULL);
       return (-1);
     }
   }
 
-  ptm_cb.t_read = thread_add_read (zebrad.master, zebra_ptm_sock_read,
-                                  NULL, ptm_cb.ptm_sock);
+  ptm_cb.t_read = thread_add_read(zebrad.master, zebra_ptm_sock_read, NULL,
+                                  ptm_cb.ptm_sock, NULL);
 
   return 0;
 }
@@ -697,8 +698,8 @@ 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);
+      ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect,
+                                        NULL, ptm_cb.reconnect_time, NULL);
       return -1;
     }
 
@@ -854,8 +855,8 @@ 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);
+      ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect,
+                                        NULL, ptm_cb.reconnect_time, NULL);
       return -1;
     }
 
@@ -976,8 +977,8 @@ 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);
+      ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect,
+                                        NULL, ptm_cb.reconnect_time, NULL);
       return -1;
     }
 
@@ -1026,8 +1027,8 @@ 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);
+      ptm_cb.t_timer = thread_add_timer(zebrad.master, zebra_ptm_connect,
+                                        NULL, ptm_cb.reconnect_time, NULL);
       return;
     }
 
index 847da529523d671314f34c70f55ee51792c3969f..0b69475dae55758851653eae0579e39382936bfa 100644 (file)
@@ -1406,7 +1406,7 @@ zebra_route_map_mark_update (const char *rmap_name)
   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);
+                       zebra_rmap_update_timer, NULL);
 }
 
 static void
index 416e5444ea5b912d3085f6e9ca4fe3b3db44b795..86fea32621fb61a2fdcfaf199a63675c22d4c487 100644 (file)
@@ -96,7 +96,7 @@ zserv_flush_data(struct thread *thread)
       break;
     case BUFFER_PENDING:
       client->t_write = thread_add_write(zebrad.master, zserv_flush_data,
-                                        client, client->sock);
+                                         client, client->sock, NULL);
       break;
     case BUFFER_EMPTY:
       break;
@@ -129,14 +129,14 @@ zebra_server_send_message(struct zserv *client)
         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);
+                                           client, 0, NULL);
       return -1;
     case BUFFER_EMPTY:
       THREAD_OFF(client->t_write);
       break;
     case BUFFER_PENDING:
-      THREAD_WRITE_ON(zebrad.master, client->t_write,
-                     zserv_flush_data, client, client->sock);
+      thread_add_write(zebrad.master, zserv_flush_data, client, client->sock,
+                       &client->t_write);
       break;
     }
 
@@ -2588,11 +2588,11 @@ zebra_event (enum event event, int sock, struct zserv *client)
   switch (event)
     {
     case ZEBRA_SERV:
-      thread_add_read (zebrad.master, zebra_accept, client, sock);
+      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);
+       thread_add_read(zebrad.master, zebra_client_read, client, sock, NULL);
       break;
     case ZEBRA_WRITE:
       /**/