Merge pull request #65 from slingamn/initialization
ircevent: allow send calls before first connect
This commit is contained in:
commit
0eddd4ae17
@ -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
|
// `end` is closed), but invocations from outside do (even though the race window
|
||||||
// is very small).
|
// is very small).
|
||||||
irc.stateMutex.Lock()
|
irc.stateMutex.Lock()
|
||||||
|
running := irc.running
|
||||||
end := irc.end
|
end := irc.end
|
||||||
pwrite := irc.pwrite
|
pwrite := irc.pwrite
|
||||||
irc.stateMutex.Unlock()
|
irc.stateMutex.Unlock()
|
||||||
|
|
||||||
|
if !running {
|
||||||
|
return ClientDisconnected
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case pwrite <- b:
|
case pwrite <- b:
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user