polyphony 0.49.1 → 0.49.2

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: 4d455bffada65a186f47a33dec9a29bf81a8a025b4c536a0d3136e256a3aaa55
4
- data.tar.gz: '094f9bae247c640ac2ea721625b5dd4b58ae4943186bfc015c9c830117a9dbee'
3
+ metadata.gz: 18278f9c013191fd5a96520a07e3b6e5c4bc088665a1b1a769b02552bd0e5448
4
+ data.tar.gz: 4e1e42fa5e2a6ddc6dcff7982415dd16246a0d75212aa2eb9ae7a97e030a2bdb
5
5
  SHA512:
6
- metadata.gz: e8a462663b9e1bca1f99b301c8d904b5fad091851dff9cf5af785bf3a76802ddeb5904565b4a79e916b8a4b97001181a48bed7a56dadf1143dfc11d9ae7762d2
7
- data.tar.gz: 68765d941201a2d74ae1e8cc20a9ea3c6fba9e68b6a552dc65a399a7ad8853a619a259ebc1dc705cdb2f3eae77adee4098de1186212755f7d87064bbaaf125f8
6
+ metadata.gz: 483158709045a9dc59fa75c912067c4fafbb02885e15f3fa57f482b97903a0c919abbb5ad19bea85837222a44d5ec2778f1e1421839c2e6a595a64e84f2d707d
7
+ data.tar.gz: c1162de70de5aa2d92804e7c4ccb3a372c5839d5600a7f68ae6f84363677a52f23923dbe8e407a84607ac4f0145736c7a5b9ada8b4956fd9c742cec182ed3a70
@@ -1,3 +1,8 @@
1
+ ## 0.49.2
2
+
3
+ - Fix hang with 100s or more child fibers when terminating
4
+ - Fix double pending_count increment in io_uring backend
5
+
1
6
  ## 0.49.1
2
7
 
3
8
  - Use `TCPSocket` instead of `Socket` in `Net.tcp_connect`
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polyphony (0.49.1)
4
+ polyphony (0.49.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -26,15 +26,13 @@ def write_response(socket)
26
26
  socket.write "HTTP/1.1 #{status_code}\r\n#{headers}\r\n#{data}"
27
27
  end
28
28
 
29
- server = TCPServer.open('0.0.0.0', 1234)
30
- puts "pid #{Process.pid} Polyphony (#{Thread.current.backend.kind}) listening on port 1234"
29
+ server = TCPServer.open('0.0.0.0', 4411)
30
+ puts "pid #{Process.pid} Polyphony (#{Thread.current.backend.kind}) listening on port 4411"
31
31
 
32
32
  spin_loop(interval: 10) do
33
33
  p Thread.current.fiber_scheduling_stats
34
34
  end
35
35
 
36
- GC.disable
37
-
38
36
  server.accept_loop do |c|
39
37
  spin { handle_client(c) }
40
38
  end
@@ -263,9 +263,7 @@ int io_uring_backend_defer_submit_and_await(
263
263
  // io_uring_sqe_set_flags(sqe, IOSQE_ASYNC);
264
264
  io_uring_backend_defer_submit(backend);
265
265
 
266
- backend->pending_count++;
267
266
  switchpoint_result = backend_await(backend);
268
- backend->pending_count--;
269
267
 
270
268
  if (!ctx->completed) {
271
269
  ctx->result = -ECANCELED;
@@ -245,8 +245,12 @@ module Polyphony
245
245
  end
246
246
 
247
247
  def shutdown_all_children(graceful = false)
248
- terminate_all_children(graceful)
249
- await_all_children
248
+ return unless @children
249
+
250
+ @children.keys.each do |c|
251
+ c.terminate(graceful)
252
+ c.await
253
+ end
250
254
  end
251
255
  end
252
256
 
@@ -319,13 +323,10 @@ module Polyphony
319
323
  # the children are shut down, it is returned along with the uncaught_exception
320
324
  # flag set. Otherwise, it returns the given arguments.
321
325
  def finalize_children(result, uncaught_exception)
322
- begin
323
- shutdown_all_children
324
- rescue Exception => e
325
- result = e
326
- uncaught_exception = true
327
- end
326
+ shutdown_all_children
328
327
  [result, uncaught_exception]
328
+ rescue Exception => e
329
+ [e, true]
329
330
  end
330
331
 
331
332
  def inform_dependants(result, uncaught_exception)
@@ -41,8 +41,7 @@ class ::Thread
41
41
 
42
42
  def finalize(result)
43
43
  unless Fiber.current.children.empty?
44
- Fiber.current.terminate_all_children
45
- Fiber.current.await_all_children
44
+ Fiber.current.shutdown_all_children
46
45
  end
47
46
  @finalization_mutex.synchronize do
48
47
  @terminated = true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polyphony
4
- VERSION = '0.49.1'
4
+ VERSION = '0.49.2'
5
5
  end
@@ -57,8 +57,7 @@ class MiniTest::Test
57
57
 
58
58
  def teardown
59
59
  # trace "* teardown #{self.name}"
60
- Fiber.current.terminate_all_children
61
- Fiber.current.await_all_children
60
+ Fiber.current.shutdown_all_children
62
61
  Fiber.current.instance_variable_set(:@auto_watcher, nil)
63
62
  rescue => e
64
63
  puts e
@@ -100,6 +100,31 @@ class BackendTest < MiniTest::Test
100
100
  assert_equal [:ready, 'foo', 'bar', :done], buf
101
101
  end
102
102
 
103
+ def test_read_loop_terminate
104
+ i, o = IO.pipe
105
+
106
+ buf = []
107
+ parent = spin do
108
+ f = spin do
109
+ buf << :ready
110
+ @backend.read_loop(i) { |d| buf << d }
111
+ buf << :done
112
+ end
113
+ suspend
114
+ end
115
+
116
+ # writing always causes snoozing
117
+ o << 'foo'
118
+ sleep 0.01
119
+ o << 'bar'
120
+ sleep 0.01
121
+
122
+ parent.stop
123
+
124
+ parent.await
125
+ assert_equal [:ready, 'foo', 'bar'], buf
126
+ end
127
+
103
128
  def test_accept_loop
104
129
  server = TCPServer.new('127.0.0.1', 1234)
105
130
 
@@ -1038,6 +1038,21 @@ class RestartTest < MiniTest::Test
1038
1038
  end
1039
1039
  end
1040
1040
 
1041
+ class ChildrenTerminationTest < MiniTest::Test
1042
+ def test_shutdown_all_children
1043
+ f = spin do
1044
+ 1000.times { spin { suspend } }
1045
+ suspend
1046
+ end
1047
+
1048
+ snooze
1049
+ assert_equal 1000, f.children.size
1050
+
1051
+ f.shutdown_all_children
1052
+ assert_equal 0, f.children.size
1053
+ end
1054
+ end
1055
+
1041
1056
  class GracefulTerminationTest < MiniTest::Test
1042
1057
  def test_graceful_termination
1043
1058
  buffer = []
@@ -46,8 +46,7 @@ class SignalTrapTest < Minitest::Test
46
46
  end.await
47
47
  rescue Interrupt
48
48
  o.puts "3 - interrupted"
49
- Fiber.current.terminate_all_children
50
- Fiber.current.await_all_children
49
+ Fiber.current.shutdown_all_children
51
50
  ensure
52
51
  o.close
53
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyphony
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.49.1
4
+ version: 0.49.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-13 00:00:00.000000000 Z
11
+ date: 2021-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler