Permalink
Browse files

Merge pull request #214 from jarmo/ruby193_rinda_patch

Patch for Rinda::RingFinger in Ruby 1.9.
  • Loading branch information...
2 parents 935bb62 + e9b3f7c commit 8ac98544869c3b4c5cf1f664b2d9281bb75c7e3e @timcharper timcharper committed Oct 28, 2012
@@ -17,6 +17,7 @@
$:.unshift(File.dirname(__FILE__))
require 'magazine/magazine_slave'
+require 'magazine/rinda_ring_finger_patch' if RUBY_VERSION > '1.9.1'
class Spork::RunStrategy::Magazine < Spork::RunStrategy
@@ -1,6 +1,7 @@
# magazine_slave_provider.rb
require 'drb'
require 'rinda/ring'
+require './rinda_ring_finger_patch' if RUBY_VERSION > '1.9.1'
require 'rinda/tuplespace'
require './magazine_slave'
@@ -0,0 +1,26 @@
+# Patch for Rinda::RingFinger.primary hanging forever on Ruby 1.9.2 & 1.9.3
+# from http://www.ruby-forum.com/topic/4229908
+require 'rinda/ring'
+
+module Rinda
+ class RingFinger
+ def lookup_ring_any(timeout=5)
+ queue = Queue.new
+
+ Thread.new do
+ self.lookup_ring(timeout) do |ts|
+ queue.push(ts)
+ end
+ queue.push(nil)
+ end
+
+ @primary = queue.pop
+ raise('RingNotFound') if @primary.nil?
+ while it = queue.pop
+ @rings.push(it)
+ end
+
+ @primary
+ end
+ end
+end
@@ -1,5 +1,6 @@
# ring_server.rb
require 'rinda/ring'
+require './rinda_ring_finger_patch' if RUBY_VERSION > '1.9.1'
require 'rinda/tuplespace'
DRb.start_service

0 comments on commit 8ac9854

Please sign in to comment.