RUBY-206 handle wtimeout behavior on 1.7.3

This commit is contained in:
Kyle Banker 2010-12-15 14:15:20 -05:00
parent a825500784
commit 6196c8728a
2 changed files with 7 additions and 2 deletions

View File

@ -387,6 +387,7 @@ module Mongo
if num_received == 1 && (error = docs[0]['err'] || docs[0]['errmsg']) if num_received == 1 && (error = docs[0]['err'] || docs[0]['errmsg'])
close if error == "not master" close if error == "not master"
error = "wtimeout" if error == "timeout"
raise Mongo::OperationFailure, docs[0]['code'].to_s + ': ' + error raise Mongo::OperationFailure, docs[0]['code'].to_s + ': ' + error
end end

View File

@ -468,8 +468,12 @@ module Mongo
raise MongoArgumentError, "DB#command requires an OrderedHash when hash contains multiple keys" raise MongoArgumentError, "DB#command requires an OrderedHash when hash contains multiple keys"
end end
result = Cursor.new(system_command_collection, begin
:limit => -1, :selector => selector, :socket => sock).next_document result = Cursor.new(system_command_collection,
:limit => -1, :selector => selector, :socket => sock).next_document
rescue OperationFailure => ex
raise OperationFailure, "Database command '#{selector.keys.first}' failed: #{ex.message}"
end
if result.nil? if result.nil?
raise OperationFailure, "Database command '#{selector.keys.first}' failed: returned null." raise OperationFailure, "Database command '#{selector.keys.first}' failed: returned null."