Skip to content

Commit

Permalink
Heavily influenced by another sce pull request.
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed May 11, 2012
1 parent dfbe714 commit 40c96fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Edge:
- Use a local array of servers - don't clear the main set (S. Christoffer Eliesen).
- Fixing VersionError reference for Sphinx 0.9.9 or better (S. Christoffer Eliesen).
- Consistent documentation for default port: 9312 (Aleksey Morozov).
- Sphinx 2.0.4 support (Ilia Lobsanov).
Expand Down
6 changes: 4 additions & 2 deletions lib/riddle/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -495,15 +495,17 @@ def close
def open_socket
raise "Already Connected" unless @socket.nil?

available_servers = servers.dup

if @timeout == 0
@socket = initialise_connection
else
begin
Timeout.timeout(@timeout) { @socket = initialise_connection }
rescue Timeout::Error, Riddle::ConnectionError => e
failed_servers ||= []
failed_servers << servers.shift
retry if !servers.empty?
failed_servers << available_servers.shift
retry if !available_servers.empty?

case e
when Timeout::Error
Expand Down

1 comment on commit 40c96fd

@ngan
Copy link
Contributor

@ngan ngan commented on 40c96fd Sep 12, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes failover to stop working. initialise_socket uses server which pulls from @servers.first which will not change because servers.dup is happening.

Please sign in to comment.