Skip to content

Commit 7253b2b

Browse files
authored
MGO-156 Avoid iter.Next deadlock on dead sockets (globalsign#182)
1 parent 0d9d58e commit 7253b2b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

session.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -4536,7 +4536,13 @@ func (iter *Iter) getMore() {
45364536
} else {
45374537
op = &iter.op
45384538
}
4539-
if err := socket.Query(op); err != nil {
4539+
// We unlock the iterator around socket.Query because it will call the
4540+
// replyFunc if the socket is dead, which would deadlock if the iterator
4541+
// were still locked.
4542+
iter.m.Unlock()
4543+
err = socket.Query(op)
4544+
iter.m.Lock()
4545+
if err != nil {
45404546
iter.docsToReceive--
45414547
iter.err = err
45424548
}

0 commit comments

Comments
 (0)