diff options
| author | Russ White <russ@riw.us> | 2019-09-03 11:12:35 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-03 11:12:35 -0400 |
| commit | a3aea4ebaf9edd9aa44ca3a85153c3c82109213c (patch) | |
| tree | 61434ff6a35b68f7270f71f5b5b907ada60dafb6 /ospfd/ospf_interface.c | |
| parent | 0137aeb03006b7f0eb2df575783f8ac8bcbae166 (diff) | |
| parent | 36a106e0e4e4fd787df2277c35df448131fb6b77 (diff) | |
Merge pull request #4907 from donaldsharp/ospf_write_q
ospfd: Do not turn on write thread unless we have something in it
Diffstat (limited to 'ospfd/ospf_interface.c')
| -rw-r--r-- | ospfd/ospf_interface.c | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index ce1604a5b1..3877708708 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -225,12 +225,14 @@ struct ospf_interface *ospf_if_new(struct ospf *ospf, struct interface *ifp, { struct ospf_interface *oi; - if ((oi = ospf_if_table_lookup(ifp, p)) == NULL) { - oi = XCALLOC(MTYPE_OSPF_IF, sizeof(struct ospf_interface)); - memset(oi, 0, sizeof(struct ospf_interface)); - } else + oi = ospf_if_table_lookup(ifp, p); + if (oi) return oi; + oi = XCALLOC(MTYPE_OSPF_IF, sizeof(struct ospf_interface)); + + oi->obuf = ospf_fifo_new(); + /* Set zebra interface pointer. */ oi->ifp = ifp; oi->address = p; @@ -264,8 +266,6 @@ struct ospf_interface *ospf_if_new(struct ospf *ospf, struct interface *ifp, oi->ospf = ospf; - ospf_if_stream_set(oi); - QOBJ_REG(oi, ospf_interface); if (IS_DEBUG_OSPF_EVENT) @@ -325,8 +325,7 @@ void ospf_if_free(struct ospf_interface *oi) { ospf_if_down(oi); - if (oi->obuf) - ospf_fifo_free(oi->obuf); + ospf_fifo_free(oi->obuf); assert(oi->state == ISM_Down); @@ -490,29 +489,20 @@ static void ospf_if_reset_stats(struct ospf_interface *oi) oi->ls_ack_in = oi->ls_ack_out = 0; } -void ospf_if_stream_set(struct ospf_interface *oi) -{ - /* set output fifo queue. */ - if (oi->obuf == NULL) - oi->obuf = ospf_fifo_new(); -} - void ospf_if_stream_unset(struct ospf_interface *oi) { struct ospf *ospf = oi->ospf; - if (oi->obuf) { - /* flush the interface packet queue */ - ospf_fifo_flush(oi->obuf); - /*reset protocol stats */ - ospf_if_reset_stats(oi); - - if (oi->on_write_q) { - listnode_delete(ospf->oi_write_q, oi); - if (list_isempty(ospf->oi_write_q)) - OSPF_TIMER_OFF(ospf->t_write); - oi->on_write_q = 0; - } + /* flush the interface packet queue */ + ospf_fifo_flush(oi->obuf); + /*reset protocol stats */ + ospf_if_reset_stats(oi); + + if (oi->on_write_q) { + listnode_delete(ospf->oi_write_q, oi); + if (list_isempty(ospf->oi_write_q)) + OSPF_TIMER_OFF(ospf->t_write); + oi->on_write_q = 0; } } @@ -903,8 +893,6 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf, ospf_area_add_if(voi->area, voi); - ospf_if_stream_set(voi); - if (IS_DEBUG_OSPF_EVENT) zlog_debug("ospf_vl_new(): Stop"); return voi; |
