Skip to content

Commit

Permalink
Do unlock in defer
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>
  • Loading branch information
jnmoyne committed Aug 10, 2023
1 parent e85ecbd commit 922ce67
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions server/server.go
Expand Up @@ -4271,16 +4271,15 @@ func (s *Server) LDMClientByID(id uint64) error {
c := s.clients[id]
if c != nil {
c.mu.Lock()
defer c.mu.Unlock()
if c.opts.Protocol >= ClientProtoInfo &&
c.flags.isSet(firstPongSent) {
// sendInfo takes care of checking if the connection is still
// valid or not, so don't duplicate tests here.
c.Debugf("sending Lame Duck Mode info to client")
c.enqueueProto(c.generateClientInfoJSON(info))
c.mu.Unlock()
return nil
} else {
c.mu.Unlock()
return errors.New("ClientProtoInfo < ClientOps.Protocol or first pong not sent")
}
}
Expand Down

0 comments on commit 922ce67

Please sign in to comment.