From b4a95ac116800c93470fea71028a82199d0894dc Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Thu, 4 Feb 2010 18:07:45 -0500 Subject: [PATCH] fixed autoreconnect (oops) RUBY-92 --- Rakefile | 5 +++++ lib/mongo/connection.rb | 2 ++ 2 files changed, 7 insertions(+) diff --git a/Rakefile b/Rakefile index 198c9e9..9182837 100644 --- a/Rakefile +++ b/Rakefile @@ -76,6 +76,11 @@ namespace :test do t.verbose = true end + Rake::TestTask.new(:auto_reconnect) do |t| + t.test_files = FileList['test/auxillary/autoreconnect_test.rb'] + t.verbose = true + end + task :drop_databases do |t| puts "Dropping test database..." require File.join(File.dirname(__FILE__), 'lib', 'mongo') diff --git a/lib/mongo/connection.rb b/lib/mongo/connection.rb index 07130cc..a28eff8 100644 --- a/lib/mongo/connection.rb +++ b/lib/mongo/connection.rb @@ -321,6 +321,7 @@ module Mongo break if is_master || @slave_ok rescue SocketError, SystemCallError, IOError => ex socket.close if socket + close false end end @@ -513,6 +514,7 @@ module Mongo message += chunk end rescue => ex + close raise ConnectionFailure, "Operation failed with the following exception: #{ex}" end message