Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed broken pipe issue that occurs with async requests

  • Loading branch information...
commit 0041fde716906e59a9faed3c82766a528d524ab1 1 parent 8a48243
Arya Asemanfar authored
View
2  Rakefile
@@ -2,7 +2,7 @@ require 'rubygems'
require 'rake'
require 'echoe'
-Echoe.new('pandemic', '0.3.8') do |p|
+Echoe.new('pandemic', '0.3.9') do |p|
p.description = "Distribute MapReduce to any of the workers and it will spread, like a pandemic."
p.url = "https://github.com/arya/pandemic/"
p.author = "Arya Asemanfar"
View
8 lib/pandemic/client_side/cluster_connection.rb
@@ -44,6 +44,7 @@ def request(body, key = nil, options = {})
key, options = nil, key if key.is_a?(Hash)
with_connection(key) do |socket|
begin
+ raise LostConnectionToNode if socket.nil?
flags = []
if options[:async]
flags << "a"
@@ -64,7 +65,7 @@ def request(body, key = nil, options = {})
raise LostConnectionToNode
end
end
- rescue Errno::ECONNRESET
+ rescue Errno::ECONNRESET, Errno::EPIPE
raise LostConnectionToNode
end
end
@@ -76,6 +77,9 @@ def with_connection(key, &block)
begin
connection = checkout_connection(key)
block.call(connection.socket)
+ rescue LostConnectionToNode
+ connection.died!
+ raise
ensure
checkin_connection(connection) if connection
end
@@ -90,6 +94,8 @@ def checkout_connection(key)
if select_from.size > 0
connection = select_from.pop
connection.ensure_alive!
+ break unless connection.alive?
+
if key.nil?
@grouped_available[key].delete(connection)
else
View
7 lib/pandemic/client_side/connection.rb
@@ -12,7 +12,12 @@ def alive?
end
def ensure_alive!
- connect unless alive?
+ connect unless self.alive?
+ end
+
+ def died!
+ @socket.close if self.alive?
+ @socket = nil
end
private
View
2  pandemic.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = %q{pandemic}
- s.version = "0.3.8"
+ s.version = "0.3.9"
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = ["Arya Asemanfar"]
Please sign in to comment.
Something went wrong with that request. Please try again.