mirror of
https://github.com/bbernhard/signal-cli-rest-api.git
synced 2026-05-19 13:34:19 +00:00
fixed deadlock in Websocket write
* properly unlock mutex to avoid deadlock see #572
This commit is contained in:
parent
a6624c5dee
commit
f3289395ae
@ -475,14 +475,15 @@ func (a *Api) handleSignalReceive(ws *websocket.Conn, number string, stop chan s
|
||||
|
||||
if response.Account == number {
|
||||
a.wsMutex.Lock()
|
||||
defer a.wsMutex.Unlock()
|
||||
err = ws.WriteMessage(websocket.TextMessage, []byte(data))
|
||||
if err != nil {
|
||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
|
||||
log.Error("Couldn't write message: " + err.Error())
|
||||
}
|
||||
a.wsMutex.Unlock()
|
||||
return
|
||||
}
|
||||
a.wsMutex.Unlock()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -493,12 +494,13 @@ func (a *Api) handleSignalReceive(ws *websocket.Conn, number string, stop chan s
|
||||
return
|
||||
}
|
||||
a.wsMutex.Lock()
|
||||
defer a.wsMutex.Unlock()
|
||||
err = ws.WriteMessage(websocket.TextMessage, errorMsgBytes)
|
||||
if err != nil {
|
||||
log.Error("Couldn't write message: " + err.Error())
|
||||
a.wsMutex.Unlock()
|
||||
return
|
||||
}
|
||||
a.wsMutex.Unlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user