pingpongpear 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ping_pong_pear.rb +17 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afed9cc278b796593e762db52f5c88a00772ddf3
4
- data.tar.gz: 66b88d3a57b647727468dc2f10decdb1975ef3b5
3
+ metadata.gz: 59d1e06b1237bfe9eb504c6a8ea597d5129de5ea
4
+ data.tar.gz: 4f1ea5538b22476adab3b709791a979e29381fa0
5
5
  SHA512:
6
- metadata.gz: 5cf8c120cf54ff7f9dd85ee13c445e9d6b91a24c8aee2bf517102d42e43f7b5e1ba3cc88e61d288d690e05b11716d523df113e3505909ce27ff9b9cce0fd72a0
7
- data.tar.gz: 412493d73d7993d5916dc7826bdd8be9923e0b4b425a816b985ac143dddc92f60f3df75bc82f64c79176d07adb14f56d7c480632dfb5f9d51055afe0099d1129
6
+ metadata.gz: 6f8f93661c838750a24f45661386897e57d460f0dff3247c12c7e3e455ed4e09d95d7475687b7fa409e672508b72ecb9d6aaffde63e5fb7ea1392a1a37ca4749
7
+ data.tar.gz: d41b22097d6cbeb2d862baaba5083a8e01b48d930654699119cf836df056ed6afb27a87bb0db93def074a82d740e69ef4f075343f610ccbd15aa9587f8368634
@@ -7,7 +7,7 @@ require 'logger'
7
7
  require 'shellwords'
8
8
 
9
9
  class PingPongPear
10
- VERSION = '2.0.1'
10
+ VERSION = '2.0.2'
11
11
 
12
12
  SERVICE = "_http._tcp,pingpongpear"
13
13
 
@@ -25,7 +25,7 @@ class PingPongPear
25
25
 
26
26
  def initialize
27
27
  @pull_requests = Queue.new
28
- @send_pull_requests = Queue.new
28
+ @send_pull_requests = []
29
29
  @peers = Set.new
30
30
  @logger = Logger.new $stdout
31
31
  end
@@ -69,9 +69,12 @@ kill -INFO $(cat #{pidfile})
69
69
 
70
70
  discover identifier, name, peers
71
71
  process_pull_requests pull_requests
72
- process_send_pull_requests @send_pull_requests
72
+ t = process_send_pull_requests @send_pull_requests
73
73
 
74
- trap('INFO') { send_pull_requests peers, hostname, http_port }
74
+ trap('INFO') {
75
+ send_pull_requests peers, hostname, http_port
76
+ t.wakeup
77
+ }
75
78
 
76
79
  advertise(identifier, name, hostname, http_port).each { |x| x }
77
80
  end
@@ -143,12 +146,16 @@ kill -INFO $(cat #{pidfile})
143
146
 
144
147
  def process_send_pull_requests requests
145
148
  Thread.new do
146
- while pr = requests.pop
147
- host, port, http_host, http_port = *pr
148
- http = Net::HTTP.new host, port
149
- request = Net::HTTP::Post.new '/pull'
150
- request.set_form_data 'host' => http_host, 'port' => http_port
151
- http.request request
149
+ loop do
150
+ requests.each do |pr|
151
+ host, port, http_host, http_port = *pr
152
+ http = Net::HTTP.new host, port
153
+ request = Net::HTTP::Post.new '/pull'
154
+ request.set_form_data 'host' => http_host, 'port' => http_port
155
+ http.request request
156
+ end
157
+ requests.clear
158
+ Thread.stop
152
159
  end
153
160
  end
154
161
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pingpongpear
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-31 00:00:00.000000000 Z
11
+ date: 2015-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dnssd