polyphony 1.2 → 1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +7 -0
- data/docs/cancellation.md +5 -4
- data/ext/polyphony/backend_io_uring.c +6 -4
- data/ext/polyphony/extconf.rb +5 -7
- data/lib/polyphony/extensions/socket.rb +2 -2
- data/lib/polyphony/version.rb +1 -1
- data/test/test_socket.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 537c28ec35d12c724a5f5ef4117ada1641d0b49b780757965615665bddbe995a
|
4
|
+
data.tar.gz: 5c11137a7a7dc6774ec815ec8b38791752f1beb939311b5968f0d0b242c7f8ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 912c4a3cea0a183350c939e588bba70656fcd14a07af6bd5912e3c2208cbb286150477d050482b030c494b0f87f21da7ec350c50f5bfee8e563bc21211143adc
|
7
|
+
data.tar.gz: c72b01fcef19a525cef49b277f0f1fe949956499be51f34f75fe1e87fc6efe9222a43ac96d282460610c3a82989934a0f661e78a27736120117c1ef391036dd6
|
data/.rubocop.yml
CHANGED
data/.yardopts
CHANGED
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
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
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
|
-
|
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) {
|
data/ext/polyphony/extconf.rb
CHANGED
@@ -44,11 +44,13 @@ if config[:io_uring]
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
if !find_header 'liburing.h', File.
|
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
|
-
|
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
|
|
data/lib/polyphony/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2023-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|