redic 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84d7eceeb333b9b35cc90c4f547e2b3fdab09a020e9d35757b157e35ba492313
4
- data.tar.gz: 93f784db08ad406d3c51b38eb6bb1d4531958ccb2f52a3349e7064eb05b82fb4
3
+ metadata.gz: f6e40f39f9e3b3856efa6b485e4d6b15f11756e1f4b21d5871ad17325ec3725d
4
+ data.tar.gz: 444278b49a7af254e319102a82b7dedfb232056aae792fb929ac4f159e2d534d
5
5
  SHA512:
6
- metadata.gz: 7a7654679f3f606629d19805e497c8f61e10c9b8ad22431ea9140c7a178438490921b32c4f1906c90a88efc5889adf23997b893309ad8d4f356a2a8be767d1d3
7
- data.tar.gz: 6452cf23dc723e16c28b3b699e65d2ad4f29c3ac76af406aa20a2585d2cb124f36d27e7102c07041a7e8a999bc60464ec57d97c77d590db466114229d863c5a2
6
+ metadata.gz: 79fb3629f83e0fe1d5a0dd27a4d95bf2949a691898b35e10b5e74bcfaeb7039cb3a18e05251c1e2bdf27346e537cb0040d254c4531247db34f3ce96f13ba54dd
7
+ data.tar.gz: 0065a647b04d3575cf3715829d558ee772f663998f972e8bf55af7e1d58cbf97ac60b02d59c9658939318724835aa3f65fc24384a124fbdc69acec156892c5b2
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 1.5.2
2
+
3
+ - Prevent concurrent when connecting.
4
+
1
5
  1.5.1
2
6
 
3
7
  - Allow timeout to be changed.
data/lib/redic/client.rb CHANGED
@@ -31,14 +31,13 @@ class Redic
31
31
  end
32
32
 
33
33
  def connect
34
- establish_connection unless connected?
35
-
36
34
  @semaphore.synchronize do
35
+ establish_connection unless connected?
37
36
  yield
37
+ rescue Errno::ECONNRESET
38
+ @connection = false
39
+ retry
38
40
  end
39
- rescue Errno::ECONNRESET
40
- @connection = false
41
- retry
42
41
  end
43
42
 
44
43
  def connected?
@@ -54,7 +53,7 @@ class Redic
54
53
 
55
54
  def quit
56
55
  if connected?
57
- assert_ok(call("QUIT"))
56
+ assert_ok(@semaphore.synchronize { call("QUIT") })
58
57
  disconnect!
59
58
 
60
59
  true
@@ -83,10 +82,8 @@ class Redic
83
82
  end
84
83
 
85
84
  def call(*args)
86
- @semaphore.synchronize do
87
- write(args)
88
- read
89
- end
85
+ write(args)
86
+ read
90
87
  end
91
88
 
92
89
  def assert(value, error)
data/redic.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "redic"
5
- s.version = "1.5.1"
5
+ s.version = "1.5.2"
6
6
  s.summary = "Lightweight Redis Client"
7
7
  s.description = "Lightweight Redis Client"
8
8
  s.authors = ["Michel Martens", "Cyril David"]
data/tests/redic_test.rb CHANGED
@@ -159,6 +159,20 @@ test "thread safety" do |c|
159
159
  assert_equal ["2"], bars.uniq
160
160
  end
161
161
 
162
+ test "uses thread safe establishing connecting to avoid sending data to" \
163
+ "client disconnected by concurrent thread" do |c|
164
+ c.client.define_singleton_method(:read) do |*otps|
165
+ sleep 0.1 # make sure that second thread is already waiting on sending data
166
+ c.client.instance_variable_get(:@connection).disconnect
167
+ end
168
+
169
+ t1 = Thread.new { c.call("GET", "foo") }
170
+ t2 = Thread.new { c.call("GET", "bar") }
171
+
172
+ t1.join
173
+ t2.join
174
+ end
175
+
162
176
  test "blocking commands" do |c1|
163
177
  c2 = Redic.new
164
178
  r = nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-02 00:00:00.000000000 Z
12
+ date: 2019-08-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hiredis
@@ -66,8 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
- rubyforge_project:
70
- rubygems_version: 2.7.6
69
+ rubygems_version: 3.0.2
71
70
  signing_key:
72
71
  specification_version: 4
73
72
  summary: Lightweight Redis Client