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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f22175cceb7b718a2406d97b20a040f6d52890518791c128a5e27d93559ca7e2
4
- data.tar.gz: bf20935122a88cc94ff9989558b019c47c43b48c9e47847725f75469767a0518
3
+ metadata.gz: 3353e688cab0a1d45f509edcb0a5bc5fa3beb6faca9e6e5703fe75ecbb220ed9
4
+ data.tar.gz: d5186d282adfa316128165ca4d2ccae5322a0605b15508d47170f9f7517e3346
5
5
  SHA512:
6
- metadata.gz: ffee3fa5a0fdea7460a7f6b754f4c72a0ccba4607e743508f43db88b2d515fc484bc73904652625721218381b873d29bdbb1a8e98dd1150814111cb0a08768d1
7
- data.tar.gz: 9126b4ac6087248ad726abeced9dc001c7cbc350f42b562981e3b9c660d55c76b2d73cce15f96cb14873321b2802310dcf348caaa805d4ab69c7b8df28f2e6a4
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
@@ -1,23 +1,40 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
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/HandleExceptions:
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
- # Performance
63
+ # Style
50
64
  #
51
65
 
52
- Performance/RegexpMatch:
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
@@ -15,5 +15,5 @@ group :development, :test do
15
15
  gem "coveralls", require: false
16
16
  gem "rake-compiler", require: false
17
17
  gem "rspec", "~> 3.7", require: false
18
- gem "rubocop", "0.52.1", require: false
18
+ gem "rubocop", "0.82.0", require: false
19
19
  end
data/README.md CHANGED
@@ -1,17 +1,10 @@
1
1
  # ![nio4r](https://raw.github.com/socketry/nio4r/master/logo.png)
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/nio4r.svg)](http://rubygems.org/gems/nio4r)
4
- [![Travis CI Status](https://secure.travis-ci.org/socketry/nio4r.svg?branch=master)](http://travis-ci.org/socketry/nio4r)
5
- [![Appveyor Status](https://ci.appveyor.com/api/projects/status/1ru8x81v91vaewax/branch/master?svg=true)](https://ci.appveyor.com/project/tarcieri/nio4r/branch/master)
4
+ [![Build Status](https://github.com/socketry/nio4r/workflows/nio4r/badge.svg?branch=master&event=push)](https://github.com/socketry/nio4r/actions?query=workflow:nio4r)
6
5
  [![Code Climate](https://codeclimate.com/github/socketry/nio4r.svg)](https://codeclimate.com/github/socketry/nio4r)
7
6
  [![Coverage Status](https://coveralls.io/repos/socketry/nio4r/badge.svg?branch=master)](https://coveralls.io/r/socketry/nio4r)
8
7
  [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/gems/nio4r/2.2.0)
9
- [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](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::IO]: Actor-based concurrency framework, uses nio4r for async I/O
29
- * [Socketry Async]: Asynchronous I/O framework for Ruby
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::IO]: https://github.com/celluloid/celluloid-io
34
- [Socketry Async]: https://github.com/socketry/async
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)
@@ -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("../../lib", __FILE__)
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(monitor) }
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
+ ...
@@ -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 = rb_define_class_under(cNIO_ByteBuffer, "OverflowError", rb_eIOError);
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
- xfree(buffer->buffer);
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
  }