Use a RWMutex so we don't block simultaneous reads

This commit is contained in:
Dane Everitt 2020-04-10 17:21:55 -07:00
parent e91dd84279
commit 28214ef0ea
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -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
}