Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
fixed bug with connecting to peers
Browse files Browse the repository at this point in the history
  • Loading branch information
Arya Asemanfar committed Jun 25, 2009
1 parent 3e3c3bf commit eaaecba
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -2,7 +2,7 @@ require 'rubygems'
require 'rake'
require 'echoe'

Echoe.new('pandemic', '0.3.6') do |p|
Echoe.new('pandemic', '0.3.7') 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"
Expand Down
3 changes: 2 additions & 1 deletion lib/pandemic/connection_pool.rb
Expand Up @@ -11,6 +11,7 @@ def initialize(options = {})
@connections = []
@max_connections = options[:max_connections] || 10
@min_connections = options[:min_connections] || 1
@connect_at_define = options.include?(:connect_at_define) ? options[:connect_at_define] : true
@timeout = options[:timeout] || 3
end

Expand All @@ -36,7 +37,7 @@ def create_connection(&block)
end
else
@create_connection = block
connect
connect if @connect_at_define
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/pandemic/server_side/peer.rb
Expand Up @@ -86,7 +86,7 @@ def add_incoming_connection(conn)
private
def initialize_connection_pool
return if @connection_pool
@connection_pool = ConnectionPool.new
@connection_pool = ConnectionPool.new(:connect_at_define => false)

@connection_pool.create_connection do
connection = nil
Expand Down
5 changes: 3 additions & 2 deletions lib/pandemic/server_side/server.rb
Expand Up @@ -50,17 +50,18 @@ def handler=(handler)
def start
raise "You must specify a handler" unless @handler

debug("Listening")
@listener = TCPServer.new(@host, @port)
@running = true
@running_since = Time.now

debug("Connecting to peers")
@peers.values.each { |peer| peer.connect }

@listener_thread = Thread.new do
begin
while @running
begin
debug("Listening")
conn = @listener.accept
Thread.new(conn) { |c| handle_connection(c) }
rescue Errno::ECONNABORTED, Errno::EINTR
Expand Down
2 changes: 1 addition & 1 deletion pandemic.gemspec
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = %q{pandemic}
s.version = "0.3.6"
s.version = "0.3.7"

s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = ["Arya Asemanfar"]
Expand Down

0 comments on commit eaaecba

Please sign in to comment.