diff --git a/irc/socket.go b/irc/socket.go index 0e99f622..1da4a1b3 100644 --- a/irc/socket.go +++ b/irc/socket.go @@ -133,10 +133,12 @@ func (socket *Socket) Write(data string) error { // timedFillLineToSendExists either sends the note or times out. func (socket *Socket) timedFillLineToSendExists(duration time.Duration) { + lineToSendTimeout := time.NewTimer(duration) + defer lineToSendTimeout.Stop() select { case socket.lineToSendExists <- true: // passed data successfully - case <-time.After(duration): + case <-lineToSendTimeout.C: // timed out send } }