make sure non-label batches expire as well

This commit is contained in:
Shivaram Lingamneni 2021-03-10 12:43:23 -05:00
parent 6d11cde149
commit b2a42a4234
2 changed files with 6 additions and 4 deletions

@ -134,8 +134,8 @@ func (irc *Connection) readLoop() {
return
}
if irc.labelNegotiated && time.Since(lastExpireCheck) > irc.Timeout {
irc.expireLabels(false)
if irc.batchNegotiated && time.Since(lastExpireCheck) > irc.Timeout {
irc.expireBatches(false)
lastExpireCheck = time.Now()
}
}
@ -307,7 +307,7 @@ func (irc *Connection) waitForStop() {
irc.socket.Close()
}
irc.expireLabels(true)
irc.expireBatches(true)
}
// Quit the current connection and disconnect from the server

@ -627,7 +627,9 @@ func (irc *Connection) unregisterLabel(labelStr string) {
delete(irc.labelCallbacks, label)
}
func (irc *Connection) expireLabels(force bool) {
// expire open batches from the server that weren't closed in a
// timely fashion
func (irc *Connection) expireBatches(force bool) {
var failedCallbacks []LabelCallback
defer func() {
for _, bcb := range failedCallbacks {