diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | lib/vendor/redis/lib/redis/connection/ruby.rb | 41 | ||||
-rw-r--r-- | lib/vendor/redis/lib/redis/version.rb | 2 |
3 files changed, 40 insertions, 5 deletions
@@ -1,4 +1,4 @@ -REDIS_RB_VERSION=v3.3.0 +REDIS_RB_VERSION=v3.3.1 REDIS_RB_VENDOR_DIR=lib/vendor/redis PWD=`pwd` diff --git a/lib/vendor/redis/lib/redis/connection/ruby.rb b/lib/vendor/redis/lib/redis/connection/ruby.rb index e3cf002..f6610e1 100644 --- a/lib/vendor/redis/lib/redis/connection/ruby.rb +++ b/lib/vendor/redis/lib/redis/connection/ruby.rb @@ -10,6 +10,16 @@ rescue LoadError # Not all systems have OpenSSL support end +if RUBY_VERSION < "1.9.3" + class String + # Ruby 1.8.7 does not have byteslice, but it handles encodings differently anyway. + # We can simply slice the string, which is a byte array there. + def byteslice(*args) + slice(*args) + end + end +end + class Redis module Connection module SocketMixin @@ -80,9 +90,34 @@ class Redis raise Errno::ECONNRESET end - # UNIXSocket and TCPSocket don't support write timeouts - def write(*args) - Timeout.timeout(@write_timeout, TimeoutError) { super } + def _write_to_socket(data) + begin + write_nonblock(data) + + rescue *NBIO_EXCEPTIONS + if IO.select(nil, [self], nil, @write_timeout) + retry + else + raise Redis::TimeoutError + end + end + + rescue EOFError + raise Errno::ECONNRESET + end + + def write(data) + return super(data) unless @write_timeout + + length = data.bytesize + total_count = 0 + loop do + count = _write_to_socket(data) + + total_count += count + return total_count if total_count >= length + data = data.byteslice(count..-1) + end end end diff --git a/lib/vendor/redis/lib/redis/version.rb b/lib/vendor/redis/lib/redis/version.rb index 3f1fbc0..56f9989 100644 --- a/lib/vendor/redis/lib/redis/version.rb +++ b/lib/vendor/redis/lib/redis/version.rb @@ -1,3 +1,3 @@ class Redis - VERSION = "3.3.0" + VERSION = "3.3.1" end |