Skip to content

Commit

Permalink
Use goto in favor of recursion to prevent stack overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fjordan committed Apr 1, 2016
1 parent ced63f2 commit 94693c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ stop:
}

func (l *Listener) addMessage(msg *Message) {
retry:
l.messageMu.Lock()

l.msgBuffer++
Expand All @@ -183,8 +184,7 @@ func (l *Listener) addMessage(msg *Message) {

<-time.After(1 * time.Millisecond)

l.addMessage(msg)
return
goto retry
}

l.messages <- msg
Expand Down

0 comments on commit 94693c8

Please sign in to comment.