From ccde7b309cd75dde2cf40d9bf38a3003ddef8d6d Mon Sep 17 00:00:00 2001 From: Gennadii Kovalev Date: Tue, 5 Jul 2016 20:18:06 +0200 Subject: [PATCH] event loop. overflooded counter cleanup on connection close. --- loop.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/loop.go b/loop.go index ba3691d..19c3772 100644 --- a/loop.go +++ b/loop.go @@ -97,6 +97,11 @@ func CloseChannel(c *Channel, m *methods, args ...interface{}) error { c.out <- protocol.CloseMessage m.callLoopEvent(c, OnDisconnection) + + overfloodedLock.Lock() + delete(overflooded, c) + overfloodedLock.Unlock() + return nil } @@ -145,7 +150,7 @@ outgoing messages loop, sends messages from channel to socket func outLoop(c *Channel, m *methods) error { for { outBufferLen := len(c.out) - if outBufferLen == queueBufferSize { + if outBufferLen >= queueBufferSize - 1 { return CloseChannel(c, m, ErrorSocketOverflood) } else if outBufferLen > int(queueBufferSize/2) { overfloodedLock.Lock()