Skip to content

Commit

Permalink
80c and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Nov 28, 2012
1 parent 0474a45 commit 6f52e83
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/dalli/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,18 @@ def get_multi(*keys)
servers_in_use.delete_if{ |s| s.sock.nil? }
break if servers_in_use.empty?

# calculate remaining timeout
elapsed = Time.now - start
timeout = servers_in_use.first.options[:socket_timeout]
if elapsed > timeout
readable = nil
else
readable, _ = IO.select(servers_in_use.map(&:sock), nil, nil, timeout - elapsed)
sockets = servers_in_use.map(&:sock)
readable, _ = IO.select(sockets, nil, nil, timeout - elapsed)
end

if readable.nil?
# no response within timeout
# abort pending connections and return known values
# no response within timeout; abort pending connections
servers_in_use.each do |server|
server.multi_response_abort
end
Expand Down

0 comments on commit 6f52e83

Please sign in to comment.