Permalink
Browse files

ensure select() calls do not overrun socket_timeout

  • Loading branch information...
1 parent 1e135fd commit 670b550e985c27d15de9c498a0646a7b55503e6c @tmm1 committed Nov 28, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/dalli/client.rb
View
@@ -91,11 +91,12 @@ def get_multi(*keys)
servers_in_use.delete_if{ |s| s.sock.nil? }
break if servers_in_use.empty?
+ elapsed = Time.now - start
timeout = servers_in_use.first.options[:socket_timeout]
- if (Time.now - start) > timeout
+ if elapsed > timeout
readable = nil
else
- readable, _ = IO.select(servers_in_use.map(&:sock), nil, nil, timeout)
+ readable, _ = IO.select(servers_in_use.map(&:sock), nil, nil, timeout - elapsed)
end
if readable.nil?

0 comments on commit 670b550

Please sign in to comment.