lib/em-hiredis/base_client.rb in gilmour-em-hiredis-0.3.1 vs lib/em-hiredis/base_client.rb in gilmour-em-hiredis-0.3.2
- old
+ new
@@ -209,16 +209,15 @@
# Shortcut for defining the callback case with just a block
deferred.callback { |result| yield(result) } if block_given?
if @connected
res = @connection.send_command(sym, args)
+ @defs.push(deferred)
# @connected can be in a stale state. send_command will fail and return
# 0 (if EM pure_ruby implmentation is not used). In that case, queue up
# the command once to be retried on reconnection
- if res && res.kind_of?(Numeric) && res == 0
+ if @connection.error? && res && res.kind_of?(Numeric) && res == 0
@command_queue << [deferred, sym, args]
- else
- @defs.push(deferred)
end
elsif @failed
deferred.fail(Error.new("Redis connection in failed state"))
else
@command_queue << [deferred, sym, args]