diff --git a/lib/mongo/connection.rb b/lib/mongo/connection.rb index ee48648..fbc2451 100644 --- a/lib/mongo/connection.rb +++ b/lib/mongo/connection.rb @@ -629,7 +629,9 @@ module Mongo rescue OperationFailure, SocketError, SystemCallError, IOError close ensure - socket.close if socket + if socket + socket.close unless socket.closed? + end end config