From bcce4321a97adfbfa17719fe60248328cf17c447 Mon Sep 17 00:00:00 2001 From: idy Date: Sat, 14 Oct 2017 09:55:23 +0800 Subject: [PATCH] do not lock while writing to a socket --- socket.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/socket.go b/socket.go index 72fab9cf7..f6158189c 100644 --- a/socket.go +++ b/socket.go @@ -549,16 +549,15 @@ func (socket *mongoSocket) Query(ops ...interface{}) (err error) { socket.replyFuncs[requestId] = request.replyFunc requestId++ } - + socket.Unlock() debugf("Socket %p to %s: sending %d op(s) (%d bytes)", socket, socket.addr, len(ops), len(buf)) - stats.sentOps(len(ops)) + stats.sentOps(len(ops)) socket.updateDeadline(writeDeadline) _, err = socket.conn.Write(buf) if !wasWaiting && requestCount > 0 { socket.updateDeadline(readDeadline) } - socket.Unlock() return err }