nio4r 2.5.2 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/workflow.yml +43 -0
- data/.rubocop.yml +30 -11
- data/CHANGES.md +24 -1
- data/Gemfile +1 -1
- data/README.md +6 -24
- data/examples/echo_server.rb +2 -2
- data/ext/nio4r/.clang-format +16 -0
- data/ext/nio4r/bytebuffer.c +27 -28
- data/ext/nio4r/extconf.rb +3 -0
- data/ext/nio4r/libev.h +1 -3
- data/ext/nio4r/monitor.c +34 -31
- data/ext/nio4r/nio4r.h +7 -12
- data/ext/nio4r/selector.c +50 -51
- data/lib/nio/bytebuffer.rb +4 -0
- data/lib/nio/monitor.rb +1 -1
- data/lib/nio/selector.rb +1 -1
- data/lib/nio/version.rb +1 -1
- data/nio4r.gemspec +2 -2
- data/spec/nio/bytebuffer_spec.rb +0 -1
- data/spec/nio/selectables/ssl_socket_spec.rb +3 -1
- data/spec/nio/selectables/udp_socket_spec.rb +2 -2
- data/spec/nio/selector_spec.rb +0 -1
- metadata +11 -12
- data/.travis.yml +0 -44
- data/Guardfile +0 -10
- data/appveyor.yml +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3353e688cab0a1d45f509edcb0a5bc5fa3beb6faca9e6e5703fe75ecbb220ed9
|
4
|
+
data.tar.gz: d5186d282adfa316128165ca4d2ccae5322a0605b15508d47170f9f7517e3346
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05c2472803019de225a4d813f302bad6810fecf193adad4291c4b58e0e5aaa34d02b60945bc6641be55103324b82eee001988641d2b9937f63d18e7d00a03f8d
|
7
|
+
data.tar.gz: fcbb1f1aa622df5e82df481e40567c153d15ca2e59ca21fbd3aff00006326e1f8ec44ff108c59fc8e8124bcc3b8e99f23d6291fe7ca27092d7af6ac22be71eb5
|
@@ -0,0 +1,43 @@
|
|
1
|
+
name: nio4r
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
name: >-
|
8
|
+
${{matrix.os}}, ${{matrix.ruby}}
|
9
|
+
env:
|
10
|
+
CI: true
|
11
|
+
TESTOPTS: -v
|
12
|
+
|
13
|
+
runs-on: ${{matrix.os}}
|
14
|
+
strategy:
|
15
|
+
fail-fast: false
|
16
|
+
matrix:
|
17
|
+
os: [ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest]
|
18
|
+
ruby: [2.4, 2.5, 2.6, 2.7, jruby, truffleruby-head]
|
19
|
+
exclude:
|
20
|
+
- { os: windows-latest, ruby: jruby }
|
21
|
+
- { os: windows-latest, ruby: truffleruby-head }
|
22
|
+
|
23
|
+
steps:
|
24
|
+
- name: repo checkout
|
25
|
+
uses: actions/checkout@v2
|
26
|
+
|
27
|
+
- name: load ruby
|
28
|
+
uses: ruby/setup-ruby@v1
|
29
|
+
with:
|
30
|
+
ruby-version: ${{matrix.ruby}}
|
31
|
+
|
32
|
+
- name: RubyGems, Bundler Update
|
33
|
+
run: gem update --system --no-document --conservative
|
34
|
+
|
35
|
+
- name: bundle install
|
36
|
+
run: bundle install --path .bundle/gems --without development
|
37
|
+
|
38
|
+
- name: compile
|
39
|
+
run: bundle exec rake compile
|
40
|
+
|
41
|
+
- name: test
|
42
|
+
run: bundle exec rake spec
|
43
|
+
timeout-minutes: 10
|
data/.rubocop.yml
CHANGED
@@ -1,23 +1,40 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.4
|
3
3
|
DisplayCopNames: true
|
4
4
|
|
5
|
+
Layout/HashAlignment:
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
Layout/LineLength:
|
9
|
+
Max: 128
|
10
|
+
|
11
|
+
Layout/SpaceAroundMethodCallOperator:
|
12
|
+
Enabled: false
|
13
|
+
|
5
14
|
Layout/SpaceInsideBlockBraces:
|
6
15
|
Enabled: false
|
7
16
|
|
8
17
|
Style/IfUnlessModifier:
|
9
18
|
Enabled: false
|
10
19
|
|
20
|
+
Style/UnpackFirst:
|
21
|
+
Enabled: false
|
22
|
+
|
11
23
|
#
|
12
24
|
# Lint
|
13
25
|
#
|
14
26
|
|
15
|
-
Lint/
|
27
|
+
Lint/SuppressedException:
|
16
28
|
Enabled: false
|
17
29
|
|
18
30
|
Lint/Loop:
|
19
31
|
Enabled: false
|
20
32
|
|
33
|
+
Lint/RaiseException:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Lint/StructNewOverride:
|
37
|
+
Enabled: false
|
21
38
|
#
|
22
39
|
# Metrics
|
23
40
|
#
|
@@ -32,9 +49,6 @@ Metrics/BlockLength:
|
|
32
49
|
Metrics/ClassLength:
|
33
50
|
Max: 128
|
34
51
|
|
35
|
-
Metrics/LineLength:
|
36
|
-
Max: 128
|
37
|
-
|
38
52
|
Metrics/MethodLength:
|
39
53
|
CountComments: false
|
40
54
|
Max: 50
|
@@ -46,16 +60,12 @@ Metrics/PerceivedComplexity:
|
|
46
60
|
Max: 15
|
47
61
|
|
48
62
|
#
|
49
|
-
#
|
63
|
+
# Style
|
50
64
|
#
|
51
65
|
|
52
|
-
|
66
|
+
Style/ExponentialNotation:
|
53
67
|
Enabled: false
|
54
68
|
|
55
|
-
#
|
56
|
-
# Style
|
57
|
-
#
|
58
|
-
|
59
69
|
Style/FormatStringToken:
|
60
70
|
Enabled: false
|
61
71
|
|
@@ -65,6 +75,15 @@ Style/FrozenStringLiteralComment:
|
|
65
75
|
Style/GlobalVars:
|
66
76
|
Enabled: false
|
67
77
|
|
78
|
+
Style/HashEachMethods:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
Style/HashTransformKeys:
|
82
|
+
Enabled: false
|
83
|
+
|
84
|
+
Style/HashTransformValues:
|
85
|
+
Enabled: false
|
86
|
+
|
68
87
|
Style/NumericPredicate:
|
69
88
|
Enabled: false
|
70
89
|
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
## 2.5.4 (2020-09-16)
|
2
|
+
|
3
|
+
* [#251](https://github.com/socketry/nio4r/issues/251)
|
4
|
+
Intermittent SEGV during GC.
|
5
|
+
([@boazsegev])
|
6
|
+
|
7
|
+
## 2.5.3 (2020-09-07)
|
8
|
+
|
9
|
+
* [#241](https://github.com/socketry/nio4r/issues/241)
|
10
|
+
Possible bug with Ruby >= 2.7.0 and `GC.compact`.
|
11
|
+
([@boazsegev])
|
12
|
+
|
13
|
+
## 2.5.2 (2019-09-24)
|
14
|
+
|
15
|
+
* [#220](https://github.com/socketry/nio4r/issues/220)
|
16
|
+
Update to libev-4.27 & fix assorted warnings.
|
17
|
+
([@ioquatix])
|
18
|
+
|
19
|
+
* [#225](https://github.com/socketry/nio4r/issues/225)
|
20
|
+
Avoid need for linux headers.
|
21
|
+
([@ioquatix])
|
22
|
+
|
1
23
|
## 2.4.0 (2019-07-07)
|
2
24
|
|
3
25
|
* [#211](https://github.com/socketry/nio4r/pull/211)
|
@@ -9,7 +31,7 @@
|
|
9
31
|
|
10
32
|
* Assorted fixes for TruffleRuby & JRuby.
|
11
33
|
([@eregon], [@olleolleolle])
|
12
|
-
|
34
|
+
Possible bug with Ruby >= 2.7.0 and `GC.compact`
|
13
35
|
* Update libev to v4.25.
|
14
36
|
([@ioquatix])
|
15
37
|
|
@@ -242,3 +264,4 @@
|
|
242
264
|
[@ioquatix]: https://github.com/ioquatix
|
243
265
|
[@eregon]: https://github.com/eregon
|
244
266
|
[@olleolleolle]: https://github.com/olleolleolle
|
267
|
+
[@boazsegev]: https://github.com/boazsegev
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,17 +1,10 @@
|
|
1
1
|
# 
|
2
2
|
|
3
3
|
[](http://rubygems.org/gems/nio4r)
|
4
|
-
[](https://ci.appveyor.com/project/tarcieri/nio4r/branch/master)
|
4
|
+
[](https://github.com/socketry/nio4r/actions?query=workflow:nio4r)
|
6
5
|
[](https://codeclimate.com/github/socketry/nio4r)
|
7
6
|
[](https://coveralls.io/r/socketry/nio4r)
|
8
7
|
[](http://www.rubydoc.info/gems/nio4r/2.2.0)
|
9
|
-
[](https://github.com/socketry/nio4r/blob/master/LICENSE.txt)
|
10
|
-
|
11
|
-
_NOTE: This is the 2.x **stable** branch of nio4r. For the 1.x **legacy** branch,
|
12
|
-
please see:_
|
13
|
-
|
14
|
-
https://github.com/socketry/nio4r/tree/1-x-stable
|
15
8
|
|
16
9
|
**New I/O for Ruby (nio4r)**: cross-platform asynchronous I/O primitives for
|
17
10
|
scalable network clients and servers. Modeled after the Java NIO API, but
|
@@ -25,13 +18,13 @@ writing.
|
|
25
18
|
## Projects using nio4r
|
26
19
|
|
27
20
|
* [ActionCable]: Rails 5 WebSocket protocol, uses nio4r for a WebSocket server
|
28
|
-
* [Celluloid
|
29
|
-
* [
|
21
|
+
* [Celluloid]: Actor-based concurrency framework, uses nio4r for async I/O
|
22
|
+
* [Async]: Asynchronous I/O framework for Ruby
|
30
23
|
* [Puma]: Ruby/Rack web server built for concurrency
|
31
24
|
|
32
25
|
[ActionCable]: https://rubygems.org/gems/actioncable
|
33
|
-
[Celluloid
|
34
|
-
[
|
26
|
+
[Celluloid]: https://github.com/celluloid/celluloid-io
|
27
|
+
[Async]: https://github.com/socketry/async
|
35
28
|
[Puma]: https://github.com/puma/puma
|
36
29
|
|
37
30
|
## Goals
|
@@ -43,10 +36,10 @@ writing.
|
|
43
36
|
|
44
37
|
## Supported platforms
|
45
38
|
|
46
|
-
* Ruby 2.3
|
47
39
|
* Ruby 2.4
|
48
40
|
* Ruby 2.5
|
49
41
|
* Ruby 2.6
|
42
|
+
* Ruby 2.7
|
50
43
|
* [JRuby](https://github.com/jruby/jruby)
|
51
44
|
* [TruffleRuby](https://github.com/oracle/truffleruby)
|
52
45
|
|
@@ -56,17 +49,6 @@ writing.
|
|
56
49
|
* **Java NIO**: JRuby extension which wraps the Java NIO subsystem
|
57
50
|
* **Pure Ruby**: `Kernel.select`-based backend that should work on any Ruby interpreter
|
58
51
|
|
59
|
-
## Discussion
|
60
|
-
|
61
|
-
For discussion and general help with nio4r, email
|
62
|
-
[socketry+subscribe@googlegroups.com][subscribe]
|
63
|
-
or join on the web via the [Google Group].
|
64
|
-
|
65
|
-
We're also on IRC at ##socketry on irc.freenode.net.
|
66
|
-
|
67
|
-
[subscribe]: mailto:socketry+subscribe@googlegroups.com
|
68
|
-
[google group]: https://groups.google.com/group/socketry
|
69
|
-
|
70
52
|
## Documentation
|
71
53
|
|
72
54
|
[Please see the nio4r wiki](https://github.com/socketry/nio4r/wiki)
|
data/examples/echo_server.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
$LOAD_PATH.push File.expand_path("
|
4
|
+
$LOAD_PATH.push File.expand_path("../lib", __dir__)
|
5
5
|
require "nio"
|
6
6
|
require "socket"
|
7
7
|
|
@@ -19,7 +19,7 @@ class EchoServer
|
|
19
19
|
|
20
20
|
def run
|
21
21
|
loop do
|
22
|
-
@selector.select { |monitor| monitor.value.call
|
22
|
+
@selector.select { |monitor| monitor.value.call }
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
Language: Cpp
|
3
|
+
BasedOnStyle: WebKit
|
4
|
+
AllowAllParametersOfDeclarationOnNextLine: false
|
5
|
+
BinPackArguments: false
|
6
|
+
BinPackParameters: false
|
7
|
+
AlignConsecutiveMacros: false
|
8
|
+
AlignConsecutiveAssignments: false
|
9
|
+
BreakBeforeBraces: Linux
|
10
|
+
BraceWrapping:
|
11
|
+
AfterControlStatement: Never
|
12
|
+
IndentCaseLabels: true
|
13
|
+
PointerAlignment: Right
|
14
|
+
SpaceBeforeParens: ControlStatements
|
15
|
+
IndentWidth: 4
|
16
|
+
...
|
data/ext/nio4r/bytebuffer.c
CHANGED
@@ -42,7 +42,7 @@ void Init_NIO_ByteBuffer()
|
|
42
42
|
cNIO_ByteBuffer = rb_define_class_under(mNIO, "ByteBuffer", rb_cObject);
|
43
43
|
rb_define_alloc_func(cNIO_ByteBuffer, NIO_ByteBuffer_allocate);
|
44
44
|
|
45
|
-
cNIO_ByteBuffer_OverflowError
|
45
|
+
cNIO_ByteBuffer_OverflowError = rb_define_class_under(cNIO_ByteBuffer, "OverflowError", rb_eIOError);
|
46
46
|
cNIO_ByteBuffer_UnderflowError = rb_define_class_under(cNIO_ByteBuffer, "UnderflowError", rb_eIOError);
|
47
47
|
cNIO_ByteBuffer_MarkUnsetError = rb_define_class_under(cNIO_ByteBuffer, "MarkUnsetError", rb_eIOError);
|
48
48
|
|
@@ -85,8 +85,8 @@ static void NIO_ByteBuffer_gc_mark(struct NIO_ByteBuffer *buffer)
|
|
85
85
|
|
86
86
|
static void NIO_ByteBuffer_free(struct NIO_ByteBuffer *buffer)
|
87
87
|
{
|
88
|
-
if(buffer->buffer)
|
89
|
-
|
88
|
+
if (buffer->buffer)
|
89
|
+
xfree(buffer->buffer);
|
90
90
|
xfree(buffer);
|
91
91
|
}
|
92
92
|
|
@@ -133,17 +133,17 @@ static VALUE NIO_ByteBuffer_set_position(VALUE self, VALUE new_position)
|
|
133
133
|
|
134
134
|
pos = NUM2INT(new_position);
|
135
135
|
|
136
|
-
if(pos < 0) {
|
136
|
+
if (pos < 0) {
|
137
137
|
rb_raise(rb_eArgError, "negative position given");
|
138
138
|
}
|
139
139
|
|
140
|
-
if(pos > buffer->limit) {
|
140
|
+
if (pos > buffer->limit) {
|
141
141
|
rb_raise(rb_eArgError, "specified position exceeds limit");
|
142
142
|
}
|
143
143
|
|
144
144
|
buffer->position = pos;
|
145
145
|
|
146
|
-
if(buffer->mark > buffer->position) {
|
146
|
+
if (buffer->mark > buffer->position) {
|
147
147
|
buffer->mark = MARK_UNSET;
|
148
148
|
}
|
149
149
|
|
@@ -166,21 +166,21 @@ static VALUE NIO_ByteBuffer_set_limit(VALUE self, VALUE new_limit)
|
|
166
166
|
|
167
167
|
lim = NUM2INT(new_limit);
|
168
168
|
|
169
|
-
if(lim < 0) {
|
169
|
+
if (lim < 0) {
|
170
170
|
rb_raise(rb_eArgError, "negative limit given");
|
171
171
|
}
|
172
172
|
|
173
|
-
if(lim > buffer->capacity) {
|
173
|
+
if (lim > buffer->capacity) {
|
174
174
|
rb_raise(rb_eArgError, "specified limit exceeds capacity");
|
175
175
|
}
|
176
176
|
|
177
177
|
buffer->limit = lim;
|
178
178
|
|
179
|
-
if(buffer->position > lim) {
|
179
|
+
if (buffer->position > lim) {
|
180
180
|
buffer->position = lim;
|
181
181
|
}
|
182
182
|
|
183
|
-
if(buffer->mark > lim) {
|
183
|
+
if (buffer->mark > lim) {
|
184
184
|
buffer->mark = MARK_UNSET;
|
185
185
|
}
|
186
186
|
|
@@ -220,17 +220,17 @@ static VALUE NIO_ByteBuffer_get(int argc, VALUE *argv, VALUE self)
|
|
220
220
|
|
221
221
|
rb_scan_args(argc, argv, "01", &length);
|
222
222
|
|
223
|
-
if(length == Qnil) {
|
223
|
+
if (length == Qnil) {
|
224
224
|
len = buffer->limit - buffer->position;
|
225
225
|
} else {
|
226
226
|
len = NUM2INT(length);
|
227
227
|
}
|
228
228
|
|
229
|
-
if(len < 0) {
|
229
|
+
if (len < 0) {
|
230
230
|
rb_raise(rb_eArgError, "negative length given");
|
231
231
|
}
|
232
232
|
|
233
|
-
if(len > buffer->limit - buffer->position) {
|
233
|
+
if (len > buffer->limit - buffer->position) {
|
234
234
|
rb_raise(cNIO_ByteBuffer_UnderflowError, "not enough data in buffer");
|
235
235
|
}
|
236
236
|
|
@@ -248,11 +248,11 @@ static VALUE NIO_ByteBuffer_fetch(VALUE self, VALUE index)
|
|
248
248
|
|
249
249
|
i = NUM2INT(index);
|
250
250
|
|
251
|
-
if(i < 0) {
|
251
|
+
if (i < 0) {
|
252
252
|
rb_raise(rb_eArgError, "negative index given");
|
253
253
|
}
|
254
254
|
|
255
|
-
if(i >= buffer->limit) {
|
255
|
+
if (i >= buffer->limit) {
|
256
256
|
rb_raise(rb_eArgError, "specified index exceeds limit");
|
257
257
|
}
|
258
258
|
|
@@ -268,7 +268,7 @@ static VALUE NIO_ByteBuffer_put(VALUE self, VALUE string)
|
|
268
268
|
StringValue(string);
|
269
269
|
length = RSTRING_LEN(string);
|
270
270
|
|
271
|
-
if(length > buffer->limit - buffer->position) {
|
271
|
+
if (length > buffer->limit - buffer->position) {
|
272
272
|
rb_raise(cNIO_ByteBuffer_OverflowError, "buffer is full");
|
273
273
|
}
|
274
274
|
|
@@ -289,14 +289,14 @@ static VALUE NIO_ByteBuffer_read_from(VALUE self, VALUE io)
|
|
289
289
|
rb_io_set_nonblock(fptr);
|
290
290
|
|
291
291
|
nbytes = buffer->limit - buffer->position;
|
292
|
-
if(nbytes == 0) {
|
292
|
+
if (nbytes == 0) {
|
293
293
|
rb_raise(cNIO_ByteBuffer_OverflowError, "buffer is full");
|
294
294
|
}
|
295
295
|
|
296
296
|
bytes_read = read(FPTR_TO_FD(fptr), buffer->buffer + buffer->position, nbytes);
|
297
297
|
|
298
|
-
if(bytes_read < 0) {
|
299
|
-
if(errno == EAGAIN) {
|
298
|
+
if (bytes_read < 0) {
|
299
|
+
if (errno == EAGAIN) {
|
300
300
|
return INT2NUM(0);
|
301
301
|
} else {
|
302
302
|
rb_sys_fail("write");
|
@@ -319,14 +319,14 @@ static VALUE NIO_ByteBuffer_write_to(VALUE self, VALUE io)
|
|
319
319
|
rb_io_set_nonblock(fptr);
|
320
320
|
|
321
321
|
nbytes = buffer->limit - buffer->position;
|
322
|
-
if(nbytes == 0) {
|
322
|
+
if (nbytes == 0) {
|
323
323
|
rb_raise(cNIO_ByteBuffer_UnderflowError, "no data remaining in buffer");
|
324
324
|
}
|
325
325
|
|
326
326
|
bytes_written = write(FPTR_TO_FD(fptr), buffer->buffer + buffer->position, nbytes);
|
327
327
|
|
328
|
-
if(bytes_written < 0) {
|
329
|
-
if(errno == EAGAIN) {
|
328
|
+
if (bytes_written < 0) {
|
329
|
+
if (errno == EAGAIN) {
|
330
330
|
return INT2NUM(0);
|
331
331
|
} else {
|
332
332
|
rb_sys_fail("write");
|
@@ -375,7 +375,7 @@ static VALUE NIO_ByteBuffer_reset(VALUE self)
|
|
375
375
|
struct NIO_ByteBuffer *buffer;
|
376
376
|
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
|
377
377
|
|
378
|
-
if(buffer->mark < 0) {
|
378
|
+
if (buffer->mark < 0) {
|
379
379
|
rb_raise(cNIO_ByteBuffer_MarkUnsetError, "mark has not been set");
|
380
380
|
} else {
|
381
381
|
buffer->position = buffer->mark;
|
@@ -402,8 +402,8 @@ static VALUE NIO_ByteBuffer_each(VALUE self)
|
|
402
402
|
struct NIO_ByteBuffer *buffer;
|
403
403
|
Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
|
404
404
|
|
405
|
-
if(rb_block_given_p()) {
|
406
|
-
for(i = 0; i < buffer->limit; i++) {
|
405
|
+
if (rb_block_given_p()) {
|
406
|
+
for (i = 0; i < buffer->limit; i++) {
|
407
407
|
rb_yield(INT2NUM(buffer->buffer[i]));
|
408
408
|
}
|
409
409
|
} else {
|
@@ -421,9 +421,8 @@ static VALUE NIO_ByteBuffer_inspect(VALUE self)
|
|
421
421
|
return rb_sprintf(
|
422
422
|
"#<%s:%p @position=%d @limit=%d @capacity=%d>",
|
423
423
|
rb_class2name(CLASS_OF(self)),
|
424
|
-
(void*)self,
|
424
|
+
(void *)self,
|
425
425
|
buffer->position,
|
426
426
|
buffer->limit,
|
427
|
-
buffer->capacity
|
428
|
-
);
|
427
|
+
buffer->capacity);
|
429
428
|
}
|