redis 4.2.2 → 4.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28eb23d20152436fc47f334f517c6fa62855e8e4711b44979cb05d86f8dcdd34
4
- data.tar.gz: 46d01b3f5539800142582aeb7ebeabe4327bce970e31ce2048dcba027dfe6eb1
3
+ metadata.gz: 61aa8081d2ac045b1198082e263c54afc544dd70f4d53e6699465cebb9c7fbc5
4
+ data.tar.gz: cbcaf862e67025ea2fcefc6736b6cd7e9c5b5b81c2434871f7a01a70a94f618d
5
5
  SHA512:
6
- metadata.gz: f2f11269c6a3a030231eeb93dfa6bee54b340ff5ad244df6d79074c95f111e3d2081f49f77756576cb8225640e8b8cad144884c8519bcf1b0e7bedea3ca1b00f
7
- data.tar.gz: 44ec06531632060b497cf1d02e6678c3d087ec3371cba86f53f9687848f73bb4e02c166b11d4db9e6b531b62ba2ca830649d71114063560f6dd764ca2ef10f07
6
+ metadata.gz: 72fd55828b8ded96f92a2d4826b1351a2ffd86272d5d3bba204fe68559373b06b55386e78b83cdab74c32ca7f3c4392001e1c3c0a9fa53ef4c1a55ad1c027551
7
+ data.tar.gz: 10b17148f6bcfd9f4862c8fae33a9cd83d0b1849562dbb991f5a2a2047bb658d50c6bc4c9e794041d7cc8ef22b3c1ccf89586c37be9dcdd6d4170237e31fc110
@@ -1,5 +1,11 @@
1
1
  # Unreleased
2
2
 
3
+ # 4.2.3
4
+
5
+ * Use io/wait instead of IO.select in the ruby connector. See #960.
6
+ * Use exception free non blocking IOs in the ruby connector. See #926.
7
+ * Prevent corruption of the client when an interrupt happen during inside a pipeline block. See #945.
8
+
3
9
  # 4.2.2
4
10
 
5
11
  * Fix `WATCH` support for `Redis::Distributed`. See #941.
data/README.md CHANGED
@@ -265,6 +265,7 @@ All timeout values are specified in seconds.
265
265
  When using pub/sub, you can subscribe to a channel using a timeout as well:
266
266
 
267
267
  ```ruby
268
+ redis = Redis.new(reconnect_attempts: 0)
268
269
  redis.subscribe_with_timeout(5, "news") do |on|
269
270
  on.message do |channel, message|
270
271
  # ...
@@ -2438,14 +2438,13 @@ class Redis
2438
2438
  end
2439
2439
 
2440
2440
  def pipelined
2441
- synchronize do |_client|
2441
+ synchronize do |prior_client|
2442
2442
  begin
2443
- pipeline = Pipeline.new(@client)
2444
- original, @client = @client, pipeline
2443
+ @client = Pipeline.new(prior_client)
2445
2444
  yield(self)
2446
- original.call_pipeline(@client)
2445
+ prior_client.call_pipeline(@client)
2447
2446
  ensure
2448
- @client = original
2447
+ @client = prior_client
2449
2448
  end
2450
2449
  end
2451
2450
  end
@@ -2481,17 +2480,16 @@ class Redis
2481
2480
  # @see #watch
2482
2481
  # @see #unwatch
2483
2482
  def multi
2484
- synchronize do |client|
2483
+ synchronize do |prior_client|
2485
2484
  if !block_given?
2486
- client.call([:multi])
2485
+ prior_client.call([:multi])
2487
2486
  else
2488
2487
  begin
2489
- pipeline = Pipeline::Multi.new(@client)
2490
- original, @client = @client, pipeline
2488
+ @client = Pipeline::Multi.new(prior_client)
2491
2489
  yield(self)
2492
- original.call_pipeline(pipeline)
2490
+ prior_client.call_pipeline(@client)
2493
2491
  ensure
2494
- @client = original
2492
+ @client = prior_client
2495
2493
  end
2496
2494
  end
2497
2495
  end
@@ -49,43 +49,47 @@ class Redis
49
49
  end
50
50
 
51
51
  def _read_from_socket(nbytes)
52
- begin
53
- read_nonblock(nbytes)
54
- rescue IO::WaitReadable
55
- if IO.select([self], nil, nil, @timeout)
56
- retry
57
- else
58
- raise Redis::TimeoutError
59
- end
60
- rescue IO::WaitWritable
61
- if IO.select(nil, [self], nil, @timeout)
62
- retry
63
- else
64
- raise Redis::TimeoutError
52
+ loop do
53
+ case chunk = read_nonblock(nbytes, exception: false)
54
+ when :wait_readable
55
+ unless wait_readable(@timeout)
56
+ raise Redis::TimeoutError
57
+ end
58
+ when :wait_writable
59
+ unless wait_writable(@timeout)
60
+ raise Redis::TimeoutError
61
+ end
62
+ when nil
63
+ raise Errno::ECONNRESET
64
+ when String
65
+ return chunk
65
66
  end
66
67
  end
67
- rescue EOFError
68
- raise Errno::ECONNRESET
69
68
  end
70
69
 
71
70
  def _write_to_socket(data)
72
- begin
73
- write_nonblock(data)
74
- rescue IO::WaitWritable
75
- if IO.select(nil, [self], nil, @write_timeout)
76
- retry
77
- else
78
- raise Redis::TimeoutError
79
- end
80
- rescue IO::WaitReadable
81
- if IO.select([self], nil, nil, @write_timeout)
82
- retry
83
- else
84
- raise Redis::TimeoutError
71
+ total_bytes_written = 0
72
+ loop do
73
+ case bytes_written = write_nonblock(data, exception: false)
74
+ when :wait_readable
75
+ unless wait_readable(@write_timeout)
76
+ raise Redis::TimeoutError
77
+ end
78
+ when :wait_writable
79
+ unless wait_writable(@write_timeout)
80
+ raise Redis::TimeoutError
81
+ end
82
+ when nil
83
+ raise Errno::ECONNRESET
84
+ when Integer
85
+ total_bytes_written += bytes_written
86
+ if bytes_written < data.bytesize
87
+ data.slice!(0, bytes_written)
88
+ else
89
+ return total_bytes_written
90
+ end
85
91
  end
86
92
  end
87
- rescue EOFError
88
- raise Errno::ECONNRESET
89
93
  end
90
94
 
91
95
  def write(data)
@@ -135,7 +139,7 @@ class Redis
135
139
  raise TimeoutError
136
140
  end
137
141
 
138
- # JRuby raises Errno::EAGAIN on #read_nonblock even when IO.select
142
+ # JRuby raises Errno::EAGAIN on #read_nonblock even when it
139
143
  # says it is readable (1.6.6, in both 1.8 and 1.9 mode).
140
144
  # Use the blocking #readpartial method instead.
141
145
 
@@ -160,7 +164,7 @@ class Redis
160
164
  begin
161
165
  sock.connect_nonblock(sockaddr)
162
166
  rescue Errno::EINPROGRESS
163
- raise TimeoutError if IO.select(nil, [sock], nil, timeout).nil?
167
+ raise TimeoutError unless sock.wait_writable(timeout)
164
168
 
165
169
  begin
166
170
  sock.connect_nonblock(sockaddr)
@@ -215,7 +219,7 @@ class Redis
215
219
  begin
216
220
  sock.connect_nonblock(sockaddr)
217
221
  rescue Errno::EINPROGRESS
218
- raise TimeoutError if IO.select(nil, [sock], nil, timeout).nil?
222
+ raise TimeoutError unless sock.wait_writable(timeout)
219
223
 
220
224
  begin
221
225
  sock.connect_nonblock(sockaddr)
@@ -233,6 +237,18 @@ class Redis
233
237
  class SSLSocket < ::OpenSSL::SSL::SSLSocket
234
238
  include SocketMixin
235
239
 
240
+ unless method_defined?(:wait_readable)
241
+ def wait_readable(timeout = nil)
242
+ to_io.wait_readable(timeout)
243
+ end
244
+ end
245
+
246
+ unless method_defined?(:wait_writable)
247
+ def wait_writable(timeout = nil)
248
+ to_io.wait_writable(timeout)
249
+ end
250
+ end
251
+
236
252
  def self.connect(host, port, timeout, ssl_params)
237
253
  # Note: this is using Redis::Connection::TCPSocket
238
254
  tcp_sock = TCPSocket.connect(host, port, timeout)
@@ -254,13 +270,13 @@ class Redis
254
270
  # Instead, you have to retry.
255
271
  ssl_sock.connect_nonblock
256
272
  rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable
257
- if IO.select([ssl_sock], nil, nil, timeout)
273
+ if ssl_sock.wait_readable(timeout)
258
274
  retry
259
275
  else
260
276
  raise TimeoutError
261
277
  end
262
278
  rescue IO::WaitWritable
263
- if IO.select(nil, [ssl_sock], nil, timeout)
279
+ if ssl_sock.wait_writable(timeout)
264
280
  retry
265
281
  else
266
282
  raise TimeoutError
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Redis
4
- VERSION = '4.2.2'
4
+ VERSION = '4.2.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.2
4
+ version: 4.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezra Zygmuntowicz
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2020-09-07 00:00:00.000000000 Z
19
+ date: 2020-11-17 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: em-synchrony
@@ -102,9 +102,9 @@ licenses:
102
102
  metadata:
103
103
  bug_tracker_uri: https://github.com/redis/redis-rb/issues
104
104
  changelog_uri: https://github.com/redis/redis-rb/blob/master/CHANGELOG.md
105
- documentation_uri: https://www.rubydoc.info/gems/redis/4.2.2
105
+ documentation_uri: https://www.rubydoc.info/gems/redis/4.2.3
106
106
  homepage_uri: https://github.com/redis/redis-rb
107
- source_code_uri: https://github.com/redis/redis-rb/tree/v4.2.2
107
+ source_code_uri: https://github.com/redis/redis-rb/tree/v4.2.3
108
108
  post_install_message:
109
109
  rdoc_options: []
110
110
  require_paths: