Skip to content

Commit

Permalink
server: fix freeze caused by race condition
Browse files Browse the repository at this point in the history
it happened when the server tried to send a request to a session that
is being closed.
  • Loading branch information
aler9 committed Aug 4, 2022
1 parent ab19ae5 commit 8883050
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion server.go
Expand Up @@ -394,7 +394,16 @@ func (s *Server) run() {
continue
}

ss.request <- req
select {
case ss.request <- req:
case <-ss.ctx.Done():
req.res <- sessionRequestRes{
res: &base.Response{
StatusCode: base.StatusBadRequest,
},
err: liberrors.ErrServerTerminated{},
}
}
} else {
if !req.create {
req.res <- sessionRequestRes{
Expand Down

0 comments on commit 8883050

Please sign in to comment.