Use a RWMutex so we don't block simultaneous reads
This commit is contained in:
parent
e91dd84279
commit
28214ef0ea
|
@ -31,7 +31,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
sync.Mutex
|
sync.RWMutex
|
||||||
Connection *websocket.Conn
|
Connection *websocket.Conn
|
||||||
jwt *tokens.WebsocketPayload `json:"-"`
|
jwt *tokens.WebsocketPayload `json:"-"`
|
||||||
server *server.Server
|
server *server.Server
|
||||||
|
@ -185,8 +185,8 @@ func (h *Handler) setJwt(token *tokens.WebsocketPayload) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) GetJwt() *tokens.WebsocketPayload {
|
func (h *Handler) GetJwt() *tokens.WebsocketPayload {
|
||||||
h.Lock()
|
h.RLock()
|
||||||
defer h.Unlock()
|
defer h.RUnlock()
|
||||||
|
|
||||||
return h.jwt
|
return h.jwt
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user