redis-em-mutex 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.rdoc +4 -0
- data/README.md +1 -1
- data/lib/redis/em-mutex.rb +1 -1
- data/lib/redis/em-mutex/version.rb +1 -1
- data/spec/redis-em-mutex-semaphores.rb +25 -0
- metadata +2 -2
data/HISTORY.rdoc
CHANGED
data/README.md
CHANGED
data/lib/redis/em-mutex.rb
CHANGED
@@ -215,6 +215,7 @@ class Redis
|
|
215
215
|
def unlock!
|
216
216
|
sem_left = @ns_names.length
|
217
217
|
if @locked_id && owner_ident(@locked_id) == (lock_full_ident = @locked_owner_id)
|
218
|
+
@locked_owner_id = @locked_id = nil
|
218
219
|
@@redis_pool.execute(false) do |r|
|
219
220
|
@ns_names.each do |name|
|
220
221
|
r.watch(name) do
|
@@ -231,7 +232,6 @@ class Redis
|
|
231
232
|
end
|
232
233
|
end
|
233
234
|
end
|
234
|
-
@locked_owner_id = @locked_id = nil
|
235
235
|
end
|
236
236
|
sem_left.zero? && self
|
237
237
|
end
|
@@ -418,6 +418,31 @@ describe Redis::EM::Mutex do
|
|
418
418
|
end
|
419
419
|
end
|
420
420
|
|
421
|
+
it "should not raise deadlock exception when none is expected" do
|
422
|
+
mutex = described_class.new(*@lock_names, expire: 10000)
|
423
|
+
f = Fiber.current
|
424
|
+
count = 0
|
425
|
+
200.times do
|
426
|
+
EM::Synchrony.next_tick do
|
427
|
+
begin
|
428
|
+
count+=1
|
429
|
+
5.times do
|
430
|
+
mutex.synchronize do
|
431
|
+
EM::Synchrony.sleep(0.0001)
|
432
|
+
end
|
433
|
+
end
|
434
|
+
count-=1
|
435
|
+
f.resume if count.zero? && f
|
436
|
+
rescue Exception => e
|
437
|
+
f.resume e
|
438
|
+
end
|
439
|
+
end
|
440
|
+
end
|
441
|
+
e = Fiber.yield
|
442
|
+
f = nil
|
443
|
+
raise e if e
|
444
|
+
end
|
445
|
+
|
421
446
|
around(:each) do |testcase|
|
422
447
|
@after_em_stop = nil
|
423
448
|
@exception = nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-em-mutex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|