Ensure that we close connection if receive raises any errors.

This commit is contained in:
Kyle Banker 2010-12-14 15:53:59 -05:00
parent 6db5bb2f51
commit 7629cf30f0
1 changed files with 5 additions and 0 deletions

View File

@ -750,9 +750,14 @@ module Mongo
end end
def receive(sock, expected_response) def receive(sock, expected_response)
begin
receive_header(sock, expected_response) receive_header(sock, expected_response)
number_received, cursor_id = receive_response_header(sock) number_received, cursor_id = receive_response_header(sock)
read_documents(number_received, cursor_id, sock) read_documents(number_received, cursor_id, sock)
rescue Mongo::ConnectionFailure => ex
close
raise ex
end
end end
def receive_header(sock, expected_response) def receive_header(sock, expected_response)