From c2ba7e49b2095019f9a7df2d71bb4b42b31a357e Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 16 Jul 2023 14:43:29 +0200 Subject: do not remove active connections when removing stale ones If the connection is renewed by the client removing the old connection and adding the new one is racy. Fix this by remembering a connection generation number and only to prevent removing the new connection. --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.go') diff --git a/main.go b/main.go index e4f7bad..ec0b20a 100644 --- a/main.go +++ b/main.go @@ -232,7 +232,7 @@ func eventsEndpoint(w http.ResponseWriter, r *http.Request) { ctx, cancel := context.WithCancel(r.Context()) - conn := newConnection(connId, w, ctx, cancel) + conn := wrms.newConnection(connId, w, ctx, cancel) defer func() { llog.Info("cancel context of connection %v", connId) -- cgit v1.2.3