nio4r 2.5.2 → 2.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/workflow.yml +61 -0
  3. data/.rubocop.yml +30 -11
  4. data/CHANGES.md +60 -1
  5. data/Gemfile +2 -4
  6. data/README.md +7 -58
  7. data/examples/echo_server.rb +2 -2
  8. data/ext/libev/Changes +71 -2
  9. data/ext/libev/ev.c +611 -198
  10. data/ext/libev/ev.h +25 -22
  11. data/ext/libev/ev_epoll.c +16 -14
  12. data/ext/libev/ev_iouring.c +694 -0
  13. data/ext/libev/ev_kqueue.c +4 -4
  14. data/ext/libev/ev_linuxaio.c +78 -100
  15. data/ext/libev/ev_poll.c +6 -6
  16. data/ext/libev/ev_port.c +3 -3
  17. data/ext/libev/ev_select.c +6 -6
  18. data/ext/libev/ev_vars.h +34 -0
  19. data/ext/libev/ev_win32.c +2 -2
  20. data/ext/libev/ev_wrap.h +56 -0
  21. data/ext/nio4r/.clang-format +16 -0
  22. data/ext/nio4r/bytebuffer.c +27 -28
  23. data/ext/nio4r/extconf.rb +11 -0
  24. data/ext/nio4r/libev.h +1 -3
  25. data/ext/nio4r/monitor.c +34 -31
  26. data/ext/nio4r/nio4r.h +7 -12
  27. data/ext/nio4r/nio4r_ext.c +1 -1
  28. data/ext/nio4r/org/nio4r/ByteBuffer.java +2 -0
  29. data/ext/nio4r/org/nio4r/Monitor.java +1 -0
  30. data/ext/nio4r/org/nio4r/Selector.java +8 -10
  31. data/ext/nio4r/selector.c +89 -75
  32. data/lib/nio/bytebuffer.rb +4 -0
  33. data/lib/nio/monitor.rb +1 -1
  34. data/lib/nio/selector.rb +12 -10
  35. data/lib/nio/version.rb +1 -1
  36. data/lib/nio.rb +20 -1
  37. data/license.md +66 -0
  38. data/nio4r.gemspec +2 -2
  39. data/rakelib/extension.rake +1 -2
  40. data/spec/nio/bytebuffer_spec.rb +0 -1
  41. data/spec/nio/selectables/udp_socket_spec.rb +2 -2
  42. data/spec/nio/selector_spec.rb +4 -1
  43. data/spec/spec_helper.rb +2 -3
  44. metadata +13 -12
  45. data/.travis.yml +0 -44
  46. data/Guardfile +0 -10
  47. data/appveyor.yml +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f22175cceb7b718a2406d97b20a040f6d52890518791c128a5e27d93559ca7e2
4
- data.tar.gz: bf20935122a88cc94ff9989558b019c47c43b48c9e47847725f75469767a0518
3
+ metadata.gz: 1572a271d329a29e7168c04b8f3776a41f23f495227a0a41ab9f1cd80233f1d6
4
+ data.tar.gz: 6c7e944abd93038272299db034c3c67829d093e2ce4a75292eba4c654cd2ae0f
5
5
  SHA512:
6
- metadata.gz: ffee3fa5a0fdea7460a7f6b754f4c72a0ccba4607e743508f43db88b2d515fc484bc73904652625721218381b873d29bdbb1a8e98dd1150814111cb0a08768d1
7
- data.tar.gz: 9126b4ac6087248ad726abeced9dc001c7cbc350f42b562981e3b9c660d55c76b2d73cce15f96cb14873321b2802310dcf348caaa805d4ab69c7b8df28f2e6a4
6
+ metadata.gz: 78e502f54f1eedeb948c412e9ecc5fa241c082b3ed292d9a50d1acbff76ee499904d70367eccb52db5c513f6bd91ac647846fa6cce6632ca9ba22c5d28a46682
7
+ data.tar.gz: 992198b186b8186e37bc84da3d89b1ddbae76ae9e8aaa45973111a8a9cd94e80c7b23ed9558449c409079b2b9c6cb1ca9edefa78ef5f8010c43a7c34ee000fc4
@@ -0,0 +1,61 @@
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:
18
+ - ubuntu-22.04
19
+ - macos-11
20
+ - windows-2022
21
+ ruby:
22
+ - "2.4"
23
+ - "2.5"
24
+ - "2.6"
25
+ - "2.7"
26
+ - "3.0"
27
+ - "3.1"
28
+ - "3.2"
29
+ - "head"
30
+ - "jruby"
31
+ - "truffleruby"
32
+ include:
33
+ - {os: ubuntu-20.04, ruby: "3.2"}
34
+ - {os: windows-2019, ruby: "3.2"}
35
+ - {os: windows-2022, ruby: ucrt}
36
+ exclude:
37
+ - {os: windows-2022, ruby: head}
38
+ - {os: windows-2022, ruby: jruby}
39
+ - {os: windows-2022, ruby: truffleruby}
40
+
41
+ steps:
42
+ - uses: actions/checkout@v3
43
+
44
+ - name: set JAVA_HOME
45
+ if: |
46
+ startsWith(matrix.ruby, 'jruby')
47
+ shell: bash
48
+ run: |
49
+ echo JAVA_HOME=$JAVA_HOME_11_X64 >> $GITHUB_ENV
50
+
51
+ - uses: ruby/setup-ruby@v1
52
+ with:
53
+ ruby-version: ${{matrix.ruby}}
54
+ bundler-cache: true
55
+
56
+ - name: Compile
57
+ run: bundle exec rake compile
58
+
59
+ - name: Test
60
+ run: bundle exec rake spec
61
+ timeout-minutes: 10
data/.rubocop.yml CHANGED
@@ -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,58 @@
1
+ ## 2.5.8 (2021-08-03)
2
+
3
+ * [#276](https://github.com/socketry/nio4r/pull/276)
4
+ Fix missing return statement in function returning non-void (issue [#275](https://github.com/socketry/nio4r/pull/275))
5
+ ([@ioquatix])
6
+ * Remove `guard-rspec` from development dependencies ([@ioquatix])
7
+
8
+ ## 2.5.7 (2021-03-04)
9
+
10
+ * [#267](https://github.com/socketry/nio4r/pull/267)
11
+ Don't try to link universal extension
12
+ ([@ioquatix])
13
+
14
+ ## 2.5.6 (2021-03-04)
15
+
16
+ * [#268](https://github.com/socketry/nio4r/pull/268)
17
+ Prefer kqueue when on OSX >= v10.12.2
18
+ ([@jcmfernandes])
19
+
20
+ ## 2.5.5 (2021-02-05)
21
+
22
+ * [#256](https://github.com/socketry/nio4r/pull/256)
23
+ Use libev 4.33, featuring experimental `io_uring` support.
24
+ ([@jcmfernandes])
25
+
26
+ * [#260](https://github.com/socketry/nio4r/pull/260)
27
+ Workaround for ARM-based macOS Ruby: Use pure Ruby for M1, since the native extension is crashing on M1 (arm64).
28
+ ([@jasl])
29
+
30
+ * [#252](https://github.com/socketry/nio4r/pull/252)
31
+ JRuby: Fix javac -Xlint warnings
32
+ ([@headius])
33
+
34
+ ## 2.5.4 (2020-09-16)
35
+
36
+ * [#251](https://github.com/socketry/nio4r/issues/251)
37
+ Intermittent SEGV during GC.
38
+ ([@boazsegev])
39
+
40
+ ## 2.5.3 (2020-09-07)
41
+
42
+ * [#241](https://github.com/socketry/nio4r/issues/241)
43
+ Possible bug with Ruby >= 2.7.0 and `GC.compact`.
44
+ ([@boazsegev])
45
+
46
+ ## 2.5.2 (2019-09-24)
47
+
48
+ * [#220](https://github.com/socketry/nio4r/issues/220)
49
+ Update to libev-4.27 & fix assorted warnings.
50
+ ([@ioquatix])
51
+
52
+ * [#225](https://github.com/socketry/nio4r/issues/225)
53
+ Avoid need for linux headers.
54
+ ([@ioquatix])
55
+
1
56
  ## 2.4.0 (2019-07-07)
2
57
 
3
58
  * [#211](https://github.com/socketry/nio4r/pull/211)
@@ -9,7 +64,7 @@
9
64
 
10
65
  * Assorted fixes for TruffleRuby & JRuby.
11
66
  ([@eregon], [@olleolleolle])
12
-
67
+ Possible bug with Ruby >= 2.7.0 and `GC.compact`
13
68
  * Update libev to v4.25.
14
69
  ([@ioquatix])
15
70
 
@@ -242,3 +297,7 @@
242
297
  [@ioquatix]: https://github.com/ioquatix
243
298
  [@eregon]: https://github.com/eregon
244
299
  [@olleolleolle]: https://github.com/olleolleolle
300
+ [@boazsegev]: https://github.com/boazsegev
301
+ [@headius]: https://github.com/headius
302
+ [@jasl]: https://github.com/jasl
303
+ [@jcmfernandes]: https://github.com/jcmfernandes
data/Gemfile CHANGED
@@ -7,13 +7,11 @@ gemspec
7
7
  gem "jruby-openssl" if defined? JRUBY_VERSION
8
8
 
9
9
  group :development do
10
- gem "guard-rspec", require: false
11
10
  gem "pry", require: false
12
11
  end
13
12
 
14
13
  group :development, :test do
15
- gem "coveralls", require: false
16
- gem "rake-compiler", require: false
14
+ gem "rake-compiler", "~> 1.1.9", require: false
17
15
  gem "rspec", "~> 3.7", require: false
18
- gem "rubocop", "0.52.1", require: false
16
+ gem "rubocop", "0.82.0", require: false
19
17
  end
data/README.md CHANGED
@@ -1,17 +1,9 @@
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
- [![Coverage Status](https://coveralls.io/repos/socketry/nio4r/badge.svg?branch=master)](https://coveralls.io/r/socketry/nio4r)
8
6
  [![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
7
 
16
8
  **New I/O for Ruby (nio4r)**: cross-platform asynchronous I/O primitives for
17
9
  scalable network clients and servers. Modeled after the Java NIO API, but
@@ -25,13 +17,13 @@ writing.
25
17
  ## Projects using nio4r
26
18
 
27
19
  * [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
20
+ * [Celluloid]: Actor-based concurrency framework, uses nio4r for async I/O
21
+ * [Async]: Asynchronous I/O framework for Ruby
30
22
  * [Puma]: Ruby/Rack web server built for concurrency
31
23
 
32
24
  [ActionCable]: https://rubygems.org/gems/actioncable
33
- [Celluloid::IO]: https://github.com/celluloid/celluloid-io
34
- [Socketry Async]: https://github.com/socketry/async
25
+ [Celluloid]: https://github.com/celluloid/celluloid-io
26
+ [Async]: https://github.com/socketry/async
35
27
  [Puma]: https://github.com/puma/puma
36
28
 
37
29
  ## Goals
@@ -43,10 +35,11 @@ writing.
43
35
 
44
36
  ## Supported platforms
45
37
 
46
- * Ruby 2.3
47
38
  * Ruby 2.4
48
39
  * Ruby 2.5
49
40
  * Ruby 2.6
41
+ * Ruby 2.7
42
+ * Ruby 3.0
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)
@@ -115,36 +97,3 @@ rake clean
115
97
  rake compile
116
98
  rake release
117
99
  ```
118
-
119
- ## License
120
-
121
- Released under the MIT license.
122
-
123
- Copyright, 2019, by Tony Arcieri.
124
- Copyright, 2019, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
125
-
126
- Permission is hereby granted, free of charge, to any person obtaining a copy
127
- of this software and associated documentation files (the "Software"), to deal
128
- in the Software without restriction, including without limitation the rights
129
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
130
- copies of the Software, and to permit persons to whom the Software is
131
- furnished to do so, subject to the following conditions:
132
-
133
- The above copyright notice and this permission notice shall be included in
134
- all copies or substantial portions of the Software.
135
-
136
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
137
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
138
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
139
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
140
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
141
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
142
- THE SOFTWARE.
143
-
144
- ### libev
145
-
146
- Released under the BSD license. See [ext/libev/LICENSE] for details.
147
-
148
- Copyright, 2007-2019, by Marc Alexander Lehmann.
149
-
150
- [ext/libev/LICENSE]: https://github.com/socketry/nio4r/blob/master/ext/libev/LICENSE
@@ -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
 
data/ext/libev/Changes CHANGED
@@ -1,8 +1,77 @@
1
1
  Revision history for libev, a high-performance and full-featured event loop.
2
2
 
3
+ TODO: for next ABI/API change, consider moving EV__IOFDSSET into io->fd instead and provide a getter.
4
+ TODO: document EV_TSTAMP_T
5
+
6
+ 4.33 Wed Mar 18 13:22:29 CET 2020
7
+ - no changes w.r.t. 4.32.
8
+
9
+ 4.32 (EV only)
10
+ - the 4.31 timerfd code wrongly changed the priority of the signal
11
+ fd watcher, which is usually harmless unless signal fds are
12
+ also used (found via cpan tester service).
13
+ - the documentation wrongly claimed that user may modify fd and events
14
+ members in io watchers when the watcher was stopped
15
+ (found by b_jonas).
16
+ - new ev_io_modify mutator which changes only the events member,
17
+ which can be faster. also added ev::io::set (int events) method
18
+ to ev++.h.
19
+ - officially allow a zero events mask for io watchers. this should
20
+ work with older libev versions as well but was not officially
21
+ allowed before.
22
+ - do not wake up every minute when timerfd is used to detect timejumps.
23
+ - do not wake up every minute when periodics are disabled and we have
24
+ a monotonic clock.
25
+ - support a lot more "uncommon" compile time configurations,
26
+ such as ev_embed enabled but ev_timer disabled.
27
+ - use a start/stop wrapper class to reduce code duplication in
28
+ ev++.h and make it needlessly more c++-y.
29
+ - the linux aio backend is no longer compiled in by default.
30
+ - update to libecb version 0x00010008.
31
+
32
+ 4.31 Fri Dec 20 21:58:29 CET 2019
33
+ - handle backends with minimum wait time a bit better by not
34
+ waiting in the presence of already-expired timers
35
+ (behaviour reported by Felipe Gasper).
36
+ - new feature: use timerfd to detect timejumps quickly,
37
+ can be disabled with the new EVFLAG_NOTIMERFD loop flag.
38
+ - document EV_USE_SIGNALFD feature macro.
39
+
40
+ 4.30 (EV only)
41
+ - change non-autoconf test for __kernel_rwf_t by testing
42
+ LINUX_VERSION_CODE, the most direct test I could find.
43
+ - fix a bug in the io_uring backend that polled the wrong
44
+ backend fd, causing it to not work in many cases.
45
+
46
+ 4.29 (EV only)
47
+ - add io uring autoconf and non-autoconf detection.
48
+ - disable io_uring when some header files are too old.
49
+
50
+ 4.28 (EV only)
51
+ - linuxaio backend resulted in random memory corruption
52
+ when loop is forked.
53
+ - linuxaio backend might have tried to cancel an iocb
54
+ multiple times (was unable to trigger this).
55
+ - linuxaio backend now employs a generation counter to
56
+ avoid handling spurious events from cancelled requests.
57
+ - io_cancel can return EINTR, deal with it. also, assume
58
+ io_submit also returns EINTR.
59
+ - fix some other minor bugs in linuxaio backend.
60
+ - ev_tstamp type can now be overriden by defining EV_TSTAMP_T.
61
+ - cleanup: replace expect_true/false and noinline by their
62
+ libecb counterparts.
63
+ - move syscall infrastructure from ev_linuxaio.c to ev.c.
64
+ - prepare io_uring integration.
65
+ - tweak ev_floor.
66
+ - epoll, poll, win32 Sleep and other places that use millisecond
67
+ reslution now all try to round up times.
68
+ - solaris port backend didn't compile.
69
+ - abstract time constants into their macros, for more flexibility.
70
+
3
71
  4.27 Thu Jun 27 22:43:44 CEST 2019
4
- - linux aio backend almost complete rewritten to work around its
72
+ - linux aio backend almost completely rewritten to work around its
5
73
  limitations.
74
+ - linux aio backend now requires linux 4.19+.
6
75
  - epoll backend now mandatory for linux aio backend.
7
76
  - fail assertions more aggressively on invalid fd's detected
8
77
  in the event loop, do not just silently fd_kill in case of
@@ -22,7 +91,7 @@ Revision history for libev, a high-performance and full-featured event loop.
22
91
  4.25 Fri Dec 21 07:49:20 CET 2018
23
92
  - INCOMPATIBLE CHANGE: EV_THROW was renamed to EV_NOEXCEPT
24
93
  (EV_THROW still provided) and now uses noexcept on C++11 or newer.
25
- - move the darwin select workaround highe rin ev.c, as newer versions of
94
+ - move the darwin select workaround higher in ev.c, as newer versions of
26
95
  darwin managed to break their broken select even more.
27
96
  - ANDROID => __ANDROID__ (reported by enh@google.com).
28
97
  - disable epoll_create1 on android because it has broken header files