Stop the ticker when exiting
This commit is contained in:
parent
04404441a4
commit
d7929ef8f3
@ -275,6 +275,7 @@ func (r *router) publishAdvert(advType AdvertType, events []*Event) {
|
|||||||
func (r *router) advertiseTable() error {
|
func (r *router) advertiseTable() error {
|
||||||
// create table advertisement ticker
|
// create table advertisement ticker
|
||||||
ticker := time.NewTicker(AdvertiseTableTick)
|
ticker := time.NewTicker(AdvertiseTableTick)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -324,6 +325,8 @@ type routeAdvert struct {
|
|||||||
func (r *router) advertiseEvents() error {
|
func (r *router) advertiseEvents() error {
|
||||||
// ticker to periodically scan event for advertising
|
// ticker to periodically scan event for advertising
|
||||||
ticker := time.NewTicker(AdvertiseEventsTick)
|
ticker := time.NewTicker(AdvertiseEventsTick)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
// advertMap is a map of advert events
|
// advertMap is a map of advert events
|
||||||
advertMap := make(map[uint64]*routeAdvert)
|
advertMap := make(map[uint64]*routeAdvert)
|
||||||
|
|
||||||
@ -426,7 +429,6 @@ func (r *router) advertiseEvents() error {
|
|||||||
// update event penalty and recorded timestamp
|
// update event penalty and recorded timestamp
|
||||||
advert.lastUpdate = time.Now()
|
advert.lastUpdate = time.Now()
|
||||||
advert.penalty += penalty
|
advert.penalty += penalty
|
||||||
|
|
||||||
case <-r.exit:
|
case <-r.exit:
|
||||||
// first wait for the advertiser to finish
|
// first wait for the advertiser to finish
|
||||||
r.advertWg.Wait()
|
r.advertWg.Wait()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user