Try to drain the channel, if possible

This commit is contained in:
Till Faelligen 2022-02-24 13:17:06 +01:00
parent 55951e2d72
commit 8b6d3cb35f

View file

@ -117,8 +117,12 @@ func (d *sessionsDict) deleteSession(sessionID string) {
delete(d.sessions, sessionID)
// stop the timer, e.g. because the registration was completed
if t, ok := d.timer[sessionID]; ok {
// trying to drain the channel results in a deadlock?
t.Stop()
if !t.Stop() {
select {
case <-t.C:
default:
}
}
delete(d.timer, sessionID)
}
}