From 28214ef0eab1510f7cabafb40ced07c952dfb068 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Fri, 10 Apr 2020 17:21:55 -0700 Subject: [PATCH] Use a RWMutex so we don't block simultaneous reads --- router/websocket/websocket.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/router/websocket/websocket.go b/router/websocket/websocket.go index 5e7d4f6..1b41f98 100644 --- a/router/websocket/websocket.go +++ b/router/websocket/websocket.go @@ -31,7 +31,7 @@ const ( ) type Handler struct { - sync.Mutex + sync.RWMutex Connection *websocket.Conn jwt *tokens.WebsocketPayload `json:"-"` server *server.Server @@ -185,8 +185,8 @@ func (h *Handler) setJwt(token *tokens.WebsocketPayload) { } func (h *Handler) GetJwt() *tokens.WebsocketPayload { - h.Lock() - defer h.Unlock() + h.RLock() + defer h.RUnlock() return h.jwt }