From 94693c865ecc25f5e890b93a729660efcccb2980 Mon Sep 17 00:00:00 2001 From: Forrest Jordan Date: Fri, 1 Apr 2016 09:30:41 -0500 Subject: [PATCH] Use goto in favor of recursion to prevent stack overflow --- listener.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/listener.go b/listener.go index 64cf996..8d79254 100644 --- a/listener.go +++ b/listener.go @@ -172,6 +172,7 @@ stop: } func (l *Listener) addMessage(msg *Message) { +retry: l.messageMu.Lock() l.msgBuffer++ @@ -183,8 +184,7 @@ func (l *Listener) addMessage(msg *Message) { <-time.After(1 * time.Millisecond) - l.addMessage(msg) - return + goto retry } l.messages <- msg