From 4b59efd6e77f6bf876f78364fcc65669e42c2024 Mon Sep 17 00:00:00 2001 From: Lev Brouk Date: Thu, 28 Sep 2023 11:10:53 -0700 Subject: [PATCH] [FIXED] Flapping TestMQTTLockedSession --- server/mqtt_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/mqtt_test.go b/server/mqtt_test.go index f8a28fea..51629bc9 100644 --- a/server/mqtt_test.go +++ b/server/mqtt_test.go @@ -4667,6 +4667,19 @@ func TestMQTTLockedSession(t *testing.T) { t.Fatalf("account session manager not found") } + // It is possible, however unlikely, to have received CONNACK while + // mqttProcessConnect is still running, and the session remains locked. Wait + // for it to finish. + stillLocked := true + for stillLocked { + asm.mu.RLock() + _, stillLocked = asm.sessLocked["sub"] + asm.mu.RUnlock() + if stillLocked { + time.Sleep(1 * time.Millisecond) + } + } + // Get the session for "sub" cli := testMQTTGetClient(t, s, "sub") sess := cli.mqtt.sess