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 CHANGED
@@ -1,3 +1,7 @@
1
+ 0.2.3
2
+ - fixed: rare but possible race condition in unlock!
3
+ manifesting as deadlock exception when no deadlock should occur
4
+
1
5
  0.2.2
2
6
  - fixed: uuid must be set only once
3
7
  - fixed: forking process or setup before reactor is running would hang
data/README.md CHANGED
@@ -53,7 +53,7 @@ $ [sudo] gem install redis-em-mutex
53
53
  #### Gemfile
54
54
 
55
55
  ```ruby
56
- gem "redis-em-mutex", "~> 0.2.2"
56
+ gem "redis-em-mutex", "~> 0.2.3"
57
57
  ```
58
58
 
59
59
  #### Github
@@ -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
@@ -1,7 +1,7 @@
1
1
  class Redis
2
2
  module EM
3
3
  class Mutex
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.3'
5
5
  end
6
6
  end
7
7
  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.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-06 00:00:00.000000000 Z
12
+ date: 2013-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis