polyphony 1.2 → 1.3

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: d8069af9a528319585e1112ca1c1fc97981ae7106da100701691d7caf1478fdc
4
- data.tar.gz: c5ec274b188332a18f8de7b595fad457f25cfc79bf903c05db0aaf7bf20507dc
3
+ metadata.gz: 537c28ec35d12c724a5f5ef4117ada1641d0b49b780757965615665bddbe995a
4
+ data.tar.gz: 5c11137a7a7dc6774ec815ec8b38791752f1beb939311b5968f0d0b242c7f8ad
5
5
  SHA512:
6
- metadata.gz: f4e8fbd79cce5062a1fa054838186c925fa626c29faf86f589889f418838b681923863d07603036c2276bd3644ce99eac1f84cdc57b7c57e97787bceec6f4cd0
7
- data.tar.gz: 22dbe0e38bc0d46ac1dcd543b0ae2b5e4a282c286f6dd40d823347542cbb37e2f21cf3c7c5503389f80f4b057b644c19c683d346a3500ada6a39e83bdbd1516f
6
+ metadata.gz: 912c4a3cea0a183350c939e588bba70656fcd14a07af6bd5912e3c2208cbb286150477d050482b030c494b0f87f21da7ec350c50f5bfee8e563bc21211143adc
7
+ data.tar.gz: c72b01fcef19a525cef49b277f0f1fe949956499be51f34f75fe1e87fc6efe9222a43ac96d282460610c3a82989934a0f661e78a27736120117c1ef391036dd6
data/.rubocop.yml CHANGED
@@ -7,6 +7,7 @@ AllCops:
7
7
  - 'test/**/*.rb'
8
8
  - 'examples/**/*.rb'
9
9
  - 'Gemfile*'
10
+ - 'ext/**/*.rb'
10
11
  - lib/polyphony/adapters/irb.rb
11
12
 
12
13
  Style/LambdaCall:
data/.yardopts CHANGED
@@ -20,6 +20,7 @@
20
20
  docs/readme.md
21
21
  docs/overview.md
22
22
  docs/tutorial.md
23
+ docs/cancellation.md
23
24
  docs/advanced-io.md
24
25
  docs/cheat-sheet.md
25
26
  docs/faq.md
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 1.3 2023-06-23
2
+
3
+ - Improve cancellation doc page
4
+ - Fix linking to liburing under certain conditions (#107)
5
+ - Fix reference to `Socket::ZERO_LINGER` (#106 @floriandejonckheere)
6
+ - Handle error when calling `pidfd_open`
7
+
1
8
  ## 1.2 2023-06-17
2
9
 
3
10
  - Require Ruby 3.1 or newer
data/docs/cancellation.md CHANGED
@@ -101,10 +101,11 @@ with_timeout(5) { sleep 10; :bar } #=> MyTimeoutError raised!
101
101
  In the code above, we create a `with_timeout` method that takes a duration
102
102
  argument. It starts by spinning up a fiber that will sleep for the given
103
103
  duration, then raise a custom exception. It then runs the given block by calling
104
- `yield`. If the given block stops running before the timeout, it exists
105
- normally, not before making sure to stop the timeout fiber. If the given block
106
- runs longer than the timeout, the exception raised by the timeout fiber will be
107
- propagated to the fiber running the block, causing it to be stopped.
104
+ `yield`. If the given block returns before the timeout, its return value is
105
+ returned from the call to `with_timeout`, not before making sure to stop the
106
+ timeout fiber. If the given block runs longer than the timeout, the exception
107
+ raised by the timeout will interrupt the fiber running the block, and will
108
+ propagate to the call site.
108
109
 
109
110
  Now that we have an idea of how we can construct timeouts, let's look at the
110
111
  different timeout APIs included in Polyphony:
@@ -14,7 +14,7 @@
14
14
  #include <errno.h>
15
15
 
16
16
  #include "polyphony.h"
17
- #include "liburing.h"
17
+ #include <liburing.h>
18
18
  #include "backend_io_uring_context.h"
19
19
  #include "ruby/thread.h"
20
20
  #include "ruby/io.h"
@@ -141,8 +141,6 @@ typedef struct poll_context {
141
141
  int result;
142
142
  } poll_context_t;
143
143
 
144
- extern int __sys_io_uring_enter(int fd, unsigned to_submit, unsigned min_complete, unsigned flags, sigset_t *sig);
145
-
146
144
  void *io_uring_backend_poll_without_gvl(void *ptr) {
147
145
  poll_context_t *ctx = (poll_context_t *)ptr;
148
146
  ctx->result = io_uring_wait_cqe(ctx->ring, &ctx->cqe);
@@ -215,7 +213,7 @@ again:
215
213
  if (overflow_checked) goto done;
216
214
 
217
215
  if (cq_ring_needs_flush(ring)) {
218
- __sys_io_uring_enter(ring->ring_fd, 0, 0, IORING_ENTER_GETEVENTS, NULL);
216
+ io_uring_enter(ring->ring_fd, 0, 0, IORING_ENTER_GETEVENTS, NULL);
219
217
  overflow_checked = true;
220
218
  goto again;
221
219
  }
@@ -1539,6 +1537,10 @@ VALUE Backend_waitpid(VALUE self, VALUE pid) {
1539
1537
  RAISE_IF_EXCEPTION(resume_value);
1540
1538
  RB_GC_GUARD(resume_value);
1541
1539
  }
1540
+ else {
1541
+ int e = errno;
1542
+ rb_syserr_fail(e, strerror(e));
1543
+ }
1542
1544
 
1543
1545
  ret = waitpid(pid_int, &status, WNOHANG);
1544
1546
  if (ret < 0) {
@@ -44,11 +44,13 @@ if config[:io_uring]
44
44
  end
45
45
  end
46
46
 
47
- if !find_header 'liburing.h', File.expand_path('../../vendor/liburing/src/include', __dir__)
47
+ if !find_header 'liburing.h', File.join(liburing_path, 'src/include')
48
48
  raise "Couldn't find liburing.h"
49
49
  end
50
50
 
51
- $LDFLAGS << " -L#{File.expand_path('../../vendor/liburing/src', __dir__)} -l uring"
51
+ if !find_library('uring', nil, File.join(liburing_path, 'src'))
52
+ raise "Couldn't find liburing.a"
53
+ end
52
54
  end
53
55
 
54
56
  def define_bool(name, value)
@@ -92,12 +94,8 @@ $defs << '-DPOLYPHONY_PLAYGROUND' if ENV['POLYPHONY_PLAYGROUND']
92
94
 
93
95
  CONFIG['optflags'] << ' -fno-strict-aliasing' unless RUBY_PLATFORM =~ /mswin/
94
96
 
95
- if RUBY_VERSION >= '3.1'
96
- have_func('rb_fiber_transfer', 'ruby.h')
97
- end
98
-
99
97
  have_header('ruby/io/buffer.h')
100
-
98
+ have_func('rb_fiber_transfer')
101
99
  have_func('rb_io_path')
102
100
  have_func('rb_io_descriptor')
103
101
  have_func('rb_io_get_write_io')
@@ -177,7 +177,7 @@ class ::Socket < ::BasicSocket
177
177
  #
178
178
  # @return [::Socket] self
179
179
  def dont_linger
180
- setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, ZERO_LINGER)
180
+ setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, Socket::ZERO_LINGER)
181
181
  self
182
182
  end
183
183
 
@@ -287,7 +287,7 @@ class ::TCPSocket < ::IPSocket
287
287
  #
288
288
  # @return [::Socket] self
289
289
  def dont_linger
290
- setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, ZERO_LINGER)
290
+ setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, Socket::ZERO_LINGER)
291
291
  self
292
292
  end
293
293
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Polyphony
4
4
  # @!visibility private
5
- VERSION = '1.2'
5
+ VERSION = '1.3'
6
6
  end
data/test/test_socket.rb CHANGED
@@ -163,6 +163,17 @@ class TCPSocketTest < MiniTest::Test
163
163
  server_fiber&.await
164
164
  server&.close
165
165
  end
166
+
167
+ def test_sockopt
168
+ client = TCPSocket.open('ipinfo.io', 80)
169
+
170
+ client.dont_linger
171
+ client.no_delay
172
+ client.reuse_addr
173
+ client.reuse_port
174
+ ensure
175
+ client.close
176
+ end
166
177
  end
167
178
 
168
179
  class UNIXSocketTest < MiniTest::Test
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: '1.2'
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-17 00:00:00.000000000 Z
11
+ date: 2023-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler