Skip to content

Commit

Permalink
MGO-156 Avoid iter.Next deadlock on dead sockets (globalsign#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
domodwyer authored Jun 4, 2018
1 parent 0d9d58e commit 7253b2b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4536,7 +4536,13 @@ func (iter *Iter) getMore() {
} else {
op = &iter.op
}
if err := socket.Query(op); err != nil {
// We unlock the iterator around socket.Query because it will call the
// replyFunc if the socket is dead, which would deadlock if the iterator
// were still locked.
iter.m.Unlock()
err = socket.Query(op)
iter.m.Lock()
if err != nil {
iter.docsToReceive--
iter.err = err
}
Expand Down

0 comments on commit 7253b2b

Please sign in to comment.