summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-07-18 13:46:21 -0700
committerStan Hu <stanhu@gmail.com>2016-07-18 13:46:21 -0700
commit47aead18adf8f0cf0814e46b59674aabfdf5f3bf (patch)
treef2b03b424cdc16c7b552ae77b351df5a46a75fd9
parente8a4dc7018bba7f0321ce8d5d7758629c6503075 (diff)
downloadgitlab-shell-update-redis-rb-3.3.1.tar.gz
Bump redis-rb to 3.3.1update-redis-rb-3.3.1
-rw-r--r--Makefile2
-rw-r--r--lib/vendor/redis/lib/redis/connection/ruby.rb41
-rw-r--r--lib/vendor/redis/lib/redis/version.rb2
3 files changed, 40 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 2a78178..431e041 100644
--- a/Makefile
+++ b/Makefile
@@ -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