Skip to content

Commit

Permalink
check length when call announcements.put
Browse files Browse the repository at this point in the history
  • Loading branch information
fanpei91 committed Jan 27, 2019
1 parent cf4b494 commit 51e915a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ func (a *announcements) get() *announcement {

func (a *announcements) put(ac *announcement) {
a.mu.Lock()
defer a.mu.Unlock()

if a.ll.Len() >= a.limit {
return
}

a.ll.PushBack(ac)
a.mu.Unlock()

select {
case a.input <- struct{}{}:
Expand Down

0 comments on commit 51e915a

Please # to comment.