Skip to content

Commit

Permalink
RUBY-386 restoring timeout issue on ismaster check
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Black committed Dec 15, 2012
1 parent 3da72c5 commit 405a868
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ group :deploy do
end

group :testing do
gem 'test-unit'
gem 'mocha', ">=0.13.0", :require => 'mocha/setup'
gem 'shoulda', ">=3.3.2"
gem 'test-unit'

gem 'growl'
gem 'guard-rspec'
Expand Down
10 changes: 8 additions & 2 deletions lib/mongo/mongo_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,14 @@ def check_is_master(node)
socket = nil
config = nil

socket = @socket_class.new(host, port, @op_timeout, @connect_timeout)
config = self['admin'].command({:ismaster => 1}, :socket => socket)
socket = @socket_class.new(host, port, @op_timeout, @connect_timeout)
if(@connect_timeout)
Timeout::timeout(@connect_timeout, OperationTimeout) do
config = self['admin'].command({:ismaster => 1}, :socket => socket)
end
else
config = self['admin'].command({:ismaster => 1}, :socket => socket)
end
rescue OperationFailure, SocketError, SystemCallError, IOError
close
ensure
Expand Down

0 comments on commit 405a868

Please sign in to comment.