From 8b6d3cb35f71cfec91da37e08cd49d2bc45d9f6c Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Thu, 24 Feb 2022 13:17:06 +0100 Subject: [PATCH] Try to drain the channel, if possible --- clientapi/routing/register.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index 18b64a6df..10cfa4325 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -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) } }