From e2b1424d8982f08dbbaee29fc3c38dac230dd719 Mon Sep 17 00:00:00 2001 From: Igor Mihalik Date: Thu, 11 Nov 2021 21:08:37 +0100 Subject: [PATCH] reduced scope of lock to prevent possible deadlocks (#105) --- v3/sockjs/jsonp.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/v3/sockjs/jsonp.go b/v3/sockjs/jsonp.go index 18f3e91..e92d1eb 100644 --- a/v3/sockjs/jsonp.go +++ b/v3/sockjs/jsonp.go @@ -75,8 +75,9 @@ func (h *Handler) jsonpSend(rw http.ResponseWriter, req *http.Request) { } sessionID, _ := h.parseSessionID(req.URL) h.sessionsMux.Lock() - defer h.sessionsMux.Unlock() - if sess, ok := h.sessions[sessionID]; !ok { + sess, ok := h.sessions[sessionID] + h.sessionsMux.Unlock() + if !ok { http.NotFound(rw, req) } else { if err := sess.accept(messages...); err != nil {