From 9f427b3fd44dfbc039c3798ebf6717257dd619ca Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Fri, 23 Jul 2021 16:13:04 -0400 Subject: [PATCH] ircevent: allow send calls before first connect --- ircevent/irc.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ircevent/irc.go b/ircevent/irc.go index 6bcc6a4..81de533 100644 --- a/ircevent/irc.go +++ b/ircevent/irc.go @@ -336,10 +336,15 @@ func (irc *Connection) sendInternal(b []byte) (err error) { // `end` is closed), but invocations from outside do (even though the race window // is very small). irc.stateMutex.Lock() + running := irc.running end := irc.end pwrite := irc.pwrite irc.stateMutex.Unlock() + if !running { + return ClientDisconnected + } + select { case pwrite <- b: return nil