Skip to content

Commit a43f51e

Browse files
committed
Don't close socket if auth fails.
Also, check if the socket exists first...
1 parent 463ebae commit a43f51e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pymongo/mongo_replica_set_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,12 +1122,15 @@ def __send_and_receive(self, member, msg, **kwargs):
11221122
member.pool.maybe_return_socket(sock_info)
11231123

11241124
return response
1125+
except OperationFailure:
1126+
raise
11251127
except (ConnectionFailure, socket.error), why:
11261128
host, port = member.pool.pair
11271129
member.pool.discard_socket(sock_info)
11281130
raise AutoReconnect("%s:%d: %s" % (host, port, str(why)))
11291131
except:
1130-
sock_info.close()
1132+
if sock_info:
1133+
sock_info.close()
11311134
raise
11321135

11331136
def __try_read(self, member, msg, **kwargs):

0 commit comments

Comments
 (0)