ractor_dns 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f04318c7ff68a828b56c907c840838eaf2db6bc713af5954d200a490a1fba78
4
- data.tar.gz: 3d63843ff098ab3de850f6a382b8b751045587c1e73001e939ccdb8abac09fdf
3
+ metadata.gz: '02339e90260e10f1dd8e76901a10e02e3435fa2e9b0cdde87fd0099a8cb250f4'
4
+ data.tar.gz: cd6d4423d563ce281960bf77659262ffe221e17b84b10f993f5b43ead544584b
5
5
  SHA512:
6
- metadata.gz: 5890c21087d4bfb40e99f6aad33b8e86bb3074ca2db3fd9eec968e7e6930b1dd60d96bad037a9c96a95a1faeb42e8e76b95f7231613bb3783254485c5d2241fc
7
- data.tar.gz: 9c0536c6a6910ac3ad69b56bda6740cbf372e186abf86b8164d832aa9314443f1afc0f9c18f196ae9712bd05a42983e58c962534fdd31aa85592fc13e8e7849d
6
+ metadata.gz: 4628cf0965ad76b018466ef3ecba44ef9d1939d5a7c97513d4eb1947e8ef35240a7985afd65fb1169ff4bc31f8ece340ad34027712e0da346709976c4ae8825c
7
+ data.tar.gz: 02a18d6559b4133de18a2115d77cd131c9fb72be31dfec27d06fbe27599e164830da419a66029bd078c5a18497de73c443fb923dfe6caeb602ebafda913385d9
@@ -23,10 +23,10 @@ module RactorDNS
23
23
  end
24
24
  end
25
25
 
26
- @resolvers = @cpu_count.times.map do
26
+ @resolvers = (@cpu_count ^ 2).times.map do
27
27
  Ractor.new(@pipe, @authority) do |pipe, authority|
28
28
  loop do
29
- data, zone_h = pipe.take
29
+ data, zone_h = Ractor.recv
30
30
 
31
31
  break if data == :stop && zone_h.nil?
32
32
 
@@ -49,16 +49,16 @@ module RactorDNS
49
49
  end
50
50
  end
51
51
  end
52
-
53
- @endpoint = Async::IO::Endpoint.udp('0.0.0.0', @port)
54
52
 
55
53
  @zones.start
56
54
 
57
55
  if here
58
56
  start_main_loop
59
57
  else
60
- @thread = Thread.new do
61
- start_main_loop
58
+ @threads = @cpu_count.times.map do |i|
59
+ Thread.new do
60
+ start_main_loop
61
+ end
62
62
  end
63
63
  end
64
64
 
@@ -69,7 +69,9 @@ module RactorDNS
69
69
 
70
70
  def stop
71
71
  begin
72
- @thread.kill
72
+ @threads.each do |t|
73
+ t.kill
74
+ end
73
75
  @pipe.send(:stop)
74
76
  @zones.stop
75
77
  rescue Ractor::ClosedError
@@ -77,14 +79,16 @@ module RactorDNS
77
79
  end
78
80
  end
79
81
 
80
- def start_main_loop
82
+ def start_main_loop(i = rand(0...@resolvers.length))
81
83
  Async do
82
- @endpoint.bind do |socket|
83
- loop do
84
- data, address = socket.recvfrom(1024)
85
- @pipe.send([data, @zones.freeze])
86
- _, encoded = Ractor.select(*@resolvers)
87
- socket.send(encoded, 0, address)
84
+ @cpu_count.times do
85
+ Async::IO::Endpoint.udp('0.0.0.0', @port).bind do |socket|
86
+ loop do
87
+ data, address = socket.recvfrom(1024)
88
+ @resolvers[i].send([data, @zones.freeze])
89
+ encoded = @resolvers[i].take
90
+ socket.send(encoded, 0, address)
91
+ end
88
92
  end
89
93
  end
90
94
  end
@@ -1,3 +1,3 @@
1
1
  module RactorDNS
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ractor_dns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - reesericci