Skip to content

Commit

Permalink
Fix duration log for AS requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Aug 3, 2022
1 parent ddbfb1b commit 46e905f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions appservice/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,16 @@ func (as *AppService) consumeWebsocket(stopFunc func(error), ws *websocket.Conn)
as.websocketRequestsLock.RUnlock()
} else {
as.Log.Debugfln("Received command request %s %d", msg.Command, msg.ReqID)
startTime := time.Now()
as.websocketHandlersLock.RLock()
handler, ok := as.websocketHandlers[msg.Command]
as.websocketHandlersLock.RUnlock()
duration := time.Now().Sub(startTime)
if !ok {
handler = as.unknownCommandHandler
}
go func() {
startTime := time.Now()
okResp, data := handler(msg.WebsocketCommand)
duration := time.Now().Sub(startTime)
err = as.SendWebsocket(msg.MakeResponse(okResp, data))
if err != nil {
as.Log.Warnfln("Failed to send response to %s %d: %v", msg.Command, msg.ReqID, err)
Expand Down

0 comments on commit 46e905f

Please sign in to comment.