polyphony 0.73.1 → 0.74

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: c1647a2b1735e71dd4adf19ff701a649198786c3055430a0941b93e0905cf9dc
4
- data.tar.gz: d00f4541d6bab4d7852ced8c0a8e15b6756305ab1c9eab3f7931bf7a18cfd6fc
3
+ metadata.gz: 2948e34f11b2bcb60406fda1024cac8d93c9019edfc97a8febe083d503b56d88
4
+ data.tar.gz: 4bedbe795bbdb669123da5d4d671e78e6cfe3a021ddf13f2a80563a80ca92571
5
5
  SHA512:
6
- metadata.gz: 5ec65b272aad6089f9f5a0a208a1e2a537e306fd1fc5247bb5aa25df22ad135d37c771947287b4d4ce5e3e4d5c5d8ced4fef9bab2291a6b7300f7b22245dd70f
7
- data.tar.gz: 245c18039397202618c4a70538878396048ce409f36e51ece94919cd1720020cc47e13f213020c378c4d6caa9017df1c5082cd292e5f7987f11730486a0b0c0a
6
+ metadata.gz: 36cf3fecb1b3ad6dc7aec6a5a12b2a0db5e7e4f2fc15a201c5e6dbe692a3ebcf5d62bc8aad8febfb224c393014c40090245c47c93dec8b41bd9732b6002c9a8f
7
+ data.tar.gz: 8ad3f84d0af1eb5bb1535eb53128fb4f0602491e673128a873c8ef5176735ed61c6e1c53eb0b5faeb0792e299e771321a204f42d588566274f1737f16281a09e
@@ -7,26 +7,29 @@ jobs:
7
7
  strategy:
8
8
  fail-fast: false
9
9
  matrix:
10
- os: [ubuntu-latest, ubuntu-18.04, macos-10.15]
11
- ruby: [2.6, 2.7, 3.0]
10
+ os: [ubuntu-latest, macos-latest]
11
+ ruby: ['2.7', '3.0', '3.1', 'head']
12
12
 
13
13
  name: >-
14
14
  ${{matrix.os}}, ${{matrix.ruby}}
15
15
 
16
16
  runs-on: ${{matrix.os}}
17
+
18
+ env:
19
+ POLYPHONY_USE_LIBEV: "1"
20
+
17
21
  steps:
18
- - uses: actions/checkout@v1
19
- - uses: ruby/setup-ruby@v1
22
+ - name: Setup OS
23
+ uses: actions/checkout@v1
24
+ - name: Setup Ruby
25
+ uses: ruby/setup-ruby@v1
20
26
  with:
21
27
  ruby-version: ${{matrix.ruby}}
22
28
  bundler-cache: true # 'bundle install' and cache
23
- - name: Install dependencies
24
- run: |
25
- gem install bundler
26
- bundle install
27
- - name: Show Linux kernel version
29
+ cache-version: 2
30
+ - name: Kernel version
28
31
  run: uname -a
29
32
  - name: Compile C-extension
30
- run: POLYPHONY_USE_LIBEV=1 bundle exec rake compile
33
+ run: bundle exec rake compile
31
34
  - name: Run tests
32
35
  run: bundle exec rake test
@@ -0,0 +1,32 @@
1
+ name: Tests with io_uring
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ os: [ubuntu-latest]
11
+ ruby: [2.6, 2.7, 3.0]
12
+
13
+ name: >-
14
+ ${{matrix.os}}, ${{matrix.ruby}}
15
+
16
+ runs-on: ${{matrix.os}}
17
+ steps:
18
+ - uses: actions/checkout@v1
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{matrix.ruby}}
22
+ bundler-cache: true # 'bundle install' and cache
23
+ - name: Install dependencies
24
+ run: |
25
+ gem install bundler
26
+ bundle install
27
+ - name: Show Linux kernel version
28
+ run: uname -a
29
+ - name: Compile C-extension
30
+ run: bundle exec rake compile
31
+ - name: Run tests
32
+ run: bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.74 2022-02-01
2
+
3
+ - Add support for IPv6 (#69)
4
+ - Override TCPSocket.open
5
+
1
6
  ## 0.73.1 2021-12-17
2
7
 
3
8
  - Fix Gemfile.lock
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polyphony (0.73.1)
4
+ polyphony (0.74)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -19,7 +19,7 @@ GEM
19
19
  method_source (1.0.0)
20
20
  mime-types (3.4.1)
21
21
  mime-types-data (~> 3.2015)
22
- mime-types-data (3.2021.1115)
22
+ mime-types-data (3.2022.0105)
23
23
  minitest (5.14.4)
24
24
  minitest-reporters (1.4.2)
25
25
  ansi
@@ -29,12 +29,12 @@ GEM
29
29
  msgpack (1.4.2)
30
30
  multi_xml (0.6.0)
31
31
  parallel (1.21.0)
32
- parser (3.0.3.2)
32
+ parser (3.1.0.0)
33
33
  ast (~> 2.4.1)
34
34
  pry (0.13.1)
35
35
  coderay (~> 1.1)
36
36
  method_source (~> 1.0)
37
- rainbow (3.0.0)
37
+ rainbow (3.1.1)
38
38
  rake (13.0.6)
39
39
  rake-compiler (1.1.1)
40
40
  rake
@@ -49,7 +49,7 @@ GEM
49
49
  rubocop-ast (>= 0.0.3)
50
50
  ruby-progressbar (~> 1.7)
51
51
  unicode-display_width (>= 1.4.0, < 2.0)
52
- rubocop-ast (1.15.0)
52
+ rubocop-ast (1.15.1)
53
53
  parser (>= 3.0.1.1)
54
54
  ruby-progressbar (1.11.0)
55
55
  simplecov (0.17.1)
@@ -60,7 +60,10 @@ GEM
60
60
  unicode-display_width (1.8.0)
61
61
 
62
62
  PLATFORMS
63
- ruby
63
+ universal-darwin
64
+ universal-freebsd
65
+ universal-linux
66
+ universal-unknown
64
67
 
65
68
  DEPENDENCIES
66
69
  httparty (= 0.17.1)
@@ -75,4 +78,4 @@ DEPENDENCIES
75
78
  simplecov (= 0.17.1)
76
79
 
77
80
  BUNDLED WITH
78
- 2.1.4
81
+ 2.3.3
data/bin/pdbg CHANGED
File without changes
data/bin/polyphony-debug CHANGED
File without changes
data/bin/stress.rb CHANGED
File without changes
data/bin/test CHANGED
File without changes
@@ -106,14 +106,14 @@ VALUE backend_base_switch_fiber(VALUE backend, struct Backend_base *base) {
106
106
 
107
107
  void backend_base_schedule_fiber(VALUE thread, VALUE backend, struct Backend_base *base, VALUE fiber, VALUE value, int prioritize) {
108
108
  int already_runnable;
109
+ runqueue_t *runqueue;
109
110
 
110
111
  if (rb_fiber_alive_p(fiber) != Qtrue) return;
111
112
  already_runnable = rb_ivar_get(fiber, ID_ivar_runnable) != Qnil;
112
113
 
113
114
  COND_TRACE(base, 4, SYM_fiber_schedule, fiber, value, prioritize ? Qtrue : Qfalse);
114
115
 
115
- runqueue_t *runqueue = rb_ivar_get(fiber, ID_ivar_parked) == Qtrue ?
116
- &base->parked_runqueue : &base->runqueue;
116
+ runqueue = rb_ivar_get(fiber, ID_ivar_parked) == Qtrue ? &base->parked_runqueue : &base->runqueue;
117
117
 
118
118
  (prioritize ? runqueue_unshift : runqueue_push)(runqueue, fiber, value, already_runnable);
119
119
  if (!already_runnable) {
@@ -206,6 +206,36 @@ inline VALUE io_enc_str(VALUE str, rb_io_t *fptr) {
206
206
  return str;
207
207
  }
208
208
 
209
+ static inline void free_io_buffer(rb_io_buffer_t *buf)
210
+ {
211
+ if (buf->ptr) {
212
+ ruby_xfree(buf->ptr);
213
+ buf->ptr = NULL;
214
+ }
215
+ }
216
+
217
+ static inline void clear_codeconv(rb_io_t *fptr) {
218
+ if (fptr->readconv) {
219
+ rb_econv_close(fptr->readconv);
220
+ fptr->readconv = NULL;
221
+ }
222
+ free_io_buffer(&fptr->cbuf);
223
+
224
+ if (fptr->writeconv) {
225
+ rb_econv_close(fptr->writeconv);
226
+ fptr->writeconv = NULL;
227
+ }
228
+ fptr->writeconv_initialized = 0;
229
+ }
230
+
231
+ void fptr_finalize(rb_io_t *fptr) {
232
+ fptr->fd = -1;
233
+ fptr->stdio_file = 0;
234
+ free_io_buffer(&fptr->rbuf);
235
+ free_io_buffer(&fptr->wbuf);
236
+ clear_codeconv(fptr);
237
+ }
238
+
209
239
  //////////////////////////////////////////////////////////////////////
210
240
  //////////////////////////////////////////////////////////////////////
211
241
 
@@ -238,17 +268,22 @@ inline void rectify_io_file_pos(rb_io_t *fptr) {
238
268
 
239
269
  inline double current_time() {
240
270
  struct timespec ts;
271
+ double t;
272
+ uint64_t ns;
273
+
241
274
  clock_gettime(CLOCK_MONOTONIC, &ts);
242
- long long ns = ts.tv_sec;
275
+ ns = ts.tv_sec;
243
276
  ns = ns * 1e9 + ts.tv_nsec;
244
- double t = ns;
277
+ t = ns;
245
278
  return t / 1e9;
246
279
  }
247
280
 
248
281
  inline uint64_t current_time_ns() {
249
282
  struct timespec ts;
283
+ uint64_t ns;
284
+
250
285
  clock_gettime(CLOCK_MONOTONIC, &ts);
251
- uint64_t ns = ts.tv_sec;
286
+ ns = ts.tv_sec;
252
287
  return ns * 1e9 + ts.tv_nsec;
253
288
  }
254
289
 
@@ -276,6 +311,9 @@ VALUE Backend_timeout_ensure_safe(VALUE arg) {
276
311
  static VALUE empty_string = Qnil;
277
312
 
278
313
  VALUE Backend_sendv(VALUE self, VALUE io, VALUE ary, VALUE flags) {
314
+ VALUE joined;
315
+ VALUE result;
316
+
279
317
  switch (RARRAY_LEN(ary)) {
280
318
  case 0:
281
319
  return Qnil;
@@ -286,14 +324,16 @@ VALUE Backend_sendv(VALUE self, VALUE io, VALUE ary, VALUE flags) {
286
324
  empty_string = rb_str_new_literal("");
287
325
  rb_global_variable(&empty_string);
288
326
  }
289
- VALUE joined = rb_ary_join(ary, empty_string);
290
- VALUE result = Backend_send(self, io, joined, flags);
327
+ joined = rb_ary_join(ary, empty_string);
328
+ result = Backend_send(self, io, joined, flags);
291
329
  RB_GC_GUARD(joined);
292
330
  return result;
293
331
  }
294
332
  }
295
333
 
296
334
  inline void io_verify_blocking_mode(rb_io_t *fptr, VALUE io, VALUE blocking) {
335
+ int flags;
336
+ int is_nonblocking;
297
337
  VALUE blocking_mode = rb_ivar_get(io, ID_ivar_blocking_mode);
298
338
  if (blocking == blocking_mode) return;
299
339
 
@@ -303,9 +343,9 @@ inline void io_verify_blocking_mode(rb_io_t *fptr, VALUE io, VALUE blocking) {
303
343
  if (blocking != Qtrue)
304
344
  rb_w32_set_nonblock(fptr->fd);
305
345
  #elif defined(F_GETFL)
306
- int flags = fcntl(fptr->fd, F_GETFL);
346
+ flags = fcntl(fptr->fd, F_GETFL);
307
347
  if (flags == -1) return;
308
- int is_nonblocking = flags & O_NONBLOCK;
348
+ is_nonblocking = flags & O_NONBLOCK;
309
349
 
310
350
  if (blocking == Qtrue) {
311
351
  if (!is_nonblocking) return;
@@ -319,12 +359,14 @@ inline void io_verify_blocking_mode(rb_io_t *fptr, VALUE io, VALUE blocking) {
319
359
  }
320
360
 
321
361
  inline void backend_run_idle_tasks(struct Backend_base *base) {
362
+ double now;
363
+
322
364
  if (base->idle_proc != Qnil)
323
365
  rb_funcall(base->idle_proc, ID_call, 0);
324
366
 
325
367
  if (base->idle_gc_period == 0) return;
326
368
 
327
- double now = current_time();
369
+ now = current_time();
328
370
  if (now - base->idle_gc_last_time < base->idle_gc_period) return;
329
371
 
330
372
  base->idle_gc_last_time = now;
@@ -389,4 +431,26 @@ void backend_setup_stats_symbols() {
389
431
  rb_global_variable(&SYM_switch_count);
390
432
  rb_global_variable(&SYM_poll_count);
391
433
  rb_global_variable(&SYM_pending_ops);
392
- }
434
+ }
435
+
436
+ int backend_getaddrinfo(VALUE host, VALUE port, struct sockaddr **ai_addr) {
437
+ VALUE port_string;
438
+ struct addrinfo hints;
439
+ struct addrinfo *addrinfo_result;
440
+ int ret;
441
+
442
+ memset(&hints, 0, sizeof(struct addrinfo));
443
+ hints.ai_family = AF_UNSPEC; /* allow IPv4 or IPv6 */
444
+ hints.ai_socktype = SOCK_STREAM;
445
+
446
+ port_string = rb_funcall(port, ID_to_s, 0);
447
+ ret = getaddrinfo(StringValueCStr(host), StringValueCStr(port_string), &hints, &addrinfo_result);
448
+ RB_GC_GUARD(port_string);
449
+ if (ret != 0) {
450
+ VALUE msg = rb_str_new2(gai_strerror(ret));
451
+ rb_funcall(rb_mKernel, ID_raise, 1, msg);
452
+ RB_GC_GUARD(msg);
453
+ }
454
+ *ai_addr = addrinfo_result->ai_addr;
455
+ return addrinfo_result->ai_addrlen;
456
+ }
@@ -1,6 +1,11 @@
1
1
  #ifndef BACKEND_COMMON_H
2
2
  #define BACKEND_COMMON_H
3
3
 
4
+ #include <sys/types.h>
5
+ #include <arpa/inet.h>
6
+ #include <netinet/in.h>
7
+ #include <netdb.h>
8
+
4
9
  #include "ruby.h"
5
10
  #include "ruby/io.h"
6
11
  #include "runqueue.h"
@@ -68,6 +73,7 @@ void io_shrink_read_string(VALUE str, long n);
68
73
  void io_set_read_length(VALUE str, long n, int shrinkable);
69
74
  rb_encoding* io_read_encoding(rb_io_t *fptr);
70
75
  VALUE io_enc_str(VALUE str, rb_io_t *fptr);
76
+ void fptr_finalize(rb_io_t *fptr);
71
77
 
72
78
  //////////////////////////////////////////////////////////////////////
73
79
  //////////////////////////////////////////////////////////////////////
@@ -109,5 +115,6 @@ VALUE Backend_stats(VALUE self);
109
115
  void backend_run_idle_tasks(struct Backend_base *base);
110
116
  void io_verify_blocking_mode(rb_io_t *fptr, VALUE io, VALUE blocking);
111
117
  void backend_setup_stats_symbols();
118
+ int backend_getaddrinfo(VALUE host, VALUE port, struct sockaddr **ai_addr);
112
119
 
113
120
  #endif /* BACKEND_COMMON_H */