nio4r 1.2.1 → 2.5.3

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.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/workflow.yml +43 -0
  3. data/.gitignore +1 -0
  4. data/.rspec +0 -1
  5. data/.rubocop.yml +70 -31
  6. data/CHANGES.md +190 -42
  7. data/Gemfile +8 -4
  8. data/Guardfile +10 -0
  9. data/README.md +102 -147
  10. data/Rakefile +3 -4
  11. data/examples/echo_server.rb +3 -2
  12. data/ext/libev/Changes +44 -13
  13. data/ext/libev/README +2 -1
  14. data/ext/libev/ev.c +314 -225
  15. data/ext/libev/ev.h +90 -88
  16. data/ext/libev/ev_epoll.c +30 -16
  17. data/ext/libev/ev_kqueue.c +19 -9
  18. data/ext/libev/ev_linuxaio.c +642 -0
  19. data/ext/libev/ev_poll.c +19 -11
  20. data/ext/libev/ev_port.c +13 -6
  21. data/ext/libev/ev_select.c +4 -2
  22. data/ext/libev/ev_vars.h +14 -3
  23. data/ext/libev/ev_wrap.h +16 -0
  24. data/ext/nio4r/bytebuffer.c +429 -0
  25. data/ext/nio4r/extconf.rb +17 -30
  26. data/ext/nio4r/monitor.c +113 -49
  27. data/ext/nio4r/nio4r.h +11 -13
  28. data/ext/nio4r/org/nio4r/ByteBuffer.java +293 -0
  29. data/ext/nio4r/org/nio4r/Monitor.java +175 -0
  30. data/ext/nio4r/org/nio4r/Nio4r.java +22 -391
  31. data/ext/nio4r/org/nio4r/Selector.java +299 -0
  32. data/ext/nio4r/selector.c +155 -68
  33. data/lib/nio.rb +4 -4
  34. data/lib/nio/bytebuffer.rb +229 -0
  35. data/lib/nio/monitor.rb +73 -11
  36. data/lib/nio/selector.rb +64 -21
  37. data/lib/nio/version.rb +1 -1
  38. data/nio4r.gemspec +34 -20
  39. data/{tasks → rakelib}/extension.rake +4 -0
  40. data/{tasks → rakelib}/rspec.rake +2 -0
  41. data/{tasks → rakelib}/rubocop.rake +2 -0
  42. data/spec/nio/acceptables_spec.rb +5 -5
  43. data/spec/nio/bytebuffer_spec.rb +354 -0
  44. data/spec/nio/monitor_spec.rb +128 -79
  45. data/spec/nio/selectables/pipe_spec.rb +12 -3
  46. data/spec/nio/selectables/ssl_socket_spec.rb +61 -29
  47. data/spec/nio/selectables/tcp_socket_spec.rb +47 -34
  48. data/spec/nio/selectables/udp_socket_spec.rb +24 -7
  49. data/spec/nio/selector_spec.rb +65 -16
  50. data/spec/spec_helper.rb +12 -3
  51. data/spec/support/selectable_examples.rb +45 -18
  52. metadata +33 -23
  53. data/.rubocop_todo.yml +0 -35
  54. data/.travis.yml +0 -27
  55. data/LICENSE.txt +0 -20
  56. data/ext/libev/README.embed +0 -3
  57. data/ext/libev/test_libev_win32.c +0 -123
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 40a72f524510c03062dc6c3dbf8a6a20236b1f25
4
- data.tar.gz: 0378f2eeeb4ab372da04f9a2f1010d4847c85587
2
+ SHA256:
3
+ metadata.gz: b2f91e950d2b359914f616398cde41cf003910ee62838e63de394215429083ac
4
+ data.tar.gz: e68a7d42ad6a361c1e72af4118d1220c23bda526b0517d1888869afd3ee8d1a1
5
5
  SHA512:
6
- metadata.gz: 02c255084b29eccedf83860ece30471660af81abcf294cc332cd86816c963ff53e81d1fa4ed7f84108e33762775b08fbf124877452690dfe4755d23cb5788bf4
7
- data.tar.gz: 6b5e34b3863e6cfe1311f4aed6706de099cc09371a2fb8a6439c6a5f164afa2511a18cf0086abded3541770561342c0d6a58ad4e96aaa6b5d7021e66054f1bbe
6
+ metadata.gz: d2ca4be61b7262f36189846fbbb50f18b96621de525fdad9b997320d58100b1eb7fe7997429025f183408282535dafea5cea05eb523b417a3aa1a883a20e7772
7
+ data.tar.gz: d603073fe98cdafecac3e380ac5bbf745d8e18066fdc095cb22baa0304768625f89ccdb6ab95bd8d9a8bad0a25fdd93ce9358b958848ac8a4a1b98cae01ed863
@@ -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/.gitignore CHANGED
@@ -18,3 +18,4 @@ tmp
18
18
  lib/nio4r_ext.*
19
19
  ext/**/*.o
20
20
  ext/**/nio4r_ext.*
21
+ .rspec_status
data/.rspec CHANGED
@@ -1,5 +1,4 @@
1
1
  --color
2
2
  --format documentation
3
- --backtrace
4
3
  --order random
5
4
  --warnings
@@ -1,61 +1,100 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+ DisplayCopNames: true
4
+
5
+ Layout/HashAlignment:
6
+ Enabled: false
7
+
8
+ Layout/LineLength:
9
+ Max: 128
10
+
11
+ Layout/SpaceAroundMethodCallOperator:
12
+ Enabled: false
13
+
14
+ Layout/SpaceInsideBlockBraces:
15
+ Enabled: false
16
+
17
+ Style/IfUnlessModifier:
18
+ Enabled: false
19
+
20
+ Style/UnpackFirst:
21
+ Enabled: false
22
+
1
23
  #
2
- # Deliberate style choices
24
+ # Lint
3
25
  #
4
26
 
5
- LineLength:
6
- Max: 100
27
+ Lint/SuppressedException:
28
+ Enabled: false
7
29
 
8
- Style/StringLiterals:
9
- EnforcedStyle: double_quotes
30
+ Lint/Loop:
31
+ Enabled: false
32
+
33
+ Lint/RaiseException:
34
+ Enabled: false
35
+
36
+ Lint/StructNewOverride:
37
+ Enabled: false
38
+ #
39
+ # Metrics
40
+ #
41
+
42
+ Metrics/AbcSize:
43
+ Max: 35
44
+
45
+ Metrics/BlockLength:
46
+ Max: 128
47
+ Enabled: false
48
+
49
+ Metrics/ClassLength:
50
+ Max: 128
10
51
 
11
52
  Metrics/MethodLength:
12
53
  CountComments: false
13
- Max: 40
54
+ Max: 50
14
55
 
15
- Metrics/AbcSize:
16
- Max: 40
56
+ Metrics/CyclomaticComplexity:
57
+ Max: 15
17
58
 
18
59
  Metrics/PerceivedComplexity:
19
60
  Max: 15
20
61
 
21
- Metrics/CyclomaticComplexity:
22
- Max: 10
62
+ #
63
+ # Style
64
+ #
23
65
 
24
- Style/GlobalVars:
66
+ Style/ExponentialNotation:
25
67
  Enabled: false
26
68
 
27
- Style/TrivialAccessors:
69
+ Style/FormatStringToken:
28
70
  Enabled: false
29
71
 
30
- #
31
- # Auto-generated overrides
32
- #
72
+ Style/FrozenStringLiteralComment:
73
+ Enabled: true
33
74
 
34
- # Offense count: 2
35
- Lint/HandleExceptions:
75
+ Style/GlobalVars:
36
76
  Enabled: false
37
77
 
38
- # Offense count: 3
39
- Lint/Loop:
78
+ Style/HashEachMethods:
40
79
  Enabled: false
41
80
 
42
- # Offense count: 1
43
- Lint/NonLocalExitFromIterator:
81
+ Style/HashTransformKeys:
44
82
  Enabled: false
45
83
 
46
- # Offense count: 7
47
- Lint/UselessAssignment:
84
+ Style/HashTransformValues:
48
85
  Enabled: false
49
86
 
50
- # Offense count: 1
51
- # Configuration parameters: SupportedStyles, IndentOneStep.
52
- Style/CaseIndentation:
53
- IndentWhenRelativeTo: end
54
-
55
- # Offense count: 1
56
- Style/Documentation:
87
+ Style/NumericPredicate:
57
88
  Enabled: false
58
89
 
59
- # Offense count: 2
60
90
  Style/RescueModifier:
61
91
  Enabled: false
92
+
93
+ Style/SafeNavigation:
94
+ Enabled: false
95
+
96
+ Style/StringLiterals:
97
+ EnforcedStyle: double_quotes
98
+
99
+ Style/TrivialAccessors:
100
+ Enabled: false
data/CHANGES.md CHANGED
@@ -1,28 +1,162 @@
1
- 1.2.1 (2016-01-31)
2
- ------------------
1
+ ## 2.5.3 (2020-09-07)
2
+
3
+ * [#241](https://github.com/socketry/nio4r/issues/241)
4
+ Possible bug with Ruby >= 2.7.0 and `GC.compact`.
5
+ ([@boazsegev])
6
+
7
+ ## 2.5.2 (2019-09-24)
8
+
9
+ * [#220](https://github.com/socketry/nio4r/issues/220)
10
+ Update to libev-4.27 & fix assorted warnings.
11
+ ([@ioquatix])
12
+
13
+ * [#225](https://github.com/socketry/nio4r/issues/225)
14
+ Avoid need for linux headers.
15
+ ([@ioquatix])
16
+
17
+ ## 2.4.0 (2019-07-07)
18
+
19
+ * [#211](https://github.com/socketry/nio4r/pull/211)
20
+ Enable KQUEUE on macOS 10.14+.
21
+ ([@ioquatix])
22
+
23
+ * Bump minimum supported Ruby to 2.3.
24
+ ([@ioquatix])
25
+
26
+ * Assorted fixes for TruffleRuby & JRuby.
27
+ ([@eregon], [@olleolleolle])
28
+ Possible bug with Ruby >= 2.7.0 and `GC.compact`
29
+ * Update libev to v4.25.
30
+ ([@ioquatix])
31
+
32
+ * Bind to ephemeral (port 0) for more reliable specs.
33
+ ([@ioquatix])
34
+
35
+ * Improve handling of SSL sockets and related specs.
36
+ ([@MSP-Greg])
37
+
38
+ ## 2.3.1 (2018-05-03)
39
+
40
+ * [#188](https://github.com/socketry/nio4r/pull/188)
41
+ Fix remove interests
42
+ ([@ioquatix])
43
+
44
+ ## 2.3.0 (2018-03-15)
45
+
46
+ * [#183](https://github.com/socketry/nio4r/pull/183)
47
+ Allow `Monitor#interests` to be nil
48
+ ([@ioquatix])
49
+
50
+ ## 2.2.0 (2017-12-27)
51
+
52
+ * [#151](https://github.com/socketry/nio4r/pull/151)
53
+ `NIO::Selector`: Support for enumerating and configuring backend
54
+ ([@tarcieri])
55
+
56
+ * [#153](https://github.com/socketry/nio4r/pull/153)
57
+ Fix builds on Windows
58
+ ([@unak])
59
+
60
+ * [#157](https://github.com/socketry/nio4r/pull/157)
61
+ Windows / MinGW test failure - fix spec_helper.rb
62
+ ([@MSP-Greg])
63
+
64
+ * [#162](https://github.com/socketry/nio4r/pull/162)
65
+ Don't build the C extension on Windows
66
+ ([@larskanis])
67
+
68
+ * [#164](https://github.com/socketry/nio4r/pull/164)
69
+ Fix NIO::ByteBuffer leak
70
+ ([@HoneyryderChuck])
71
+
72
+ * [#170](https://github.com/socketry/nio4r/pull/170)
73
+ Avoid CancelledKeyExceptions on JRuby
74
+ ([@HoneyryderChuck])
75
+
76
+ * [#177](https://github.com/socketry/nio4r/pull/177)
77
+ Fix `NIO::ByteBuffer` string conversions on JRuby
78
+ ([@tarcieri])
79
+
80
+ * [#179](https://github.com/socketry/nio4r/pull/179)
81
+ Fix argument error when running on ruby 2.5.0
82
+ ([@tompng])
83
+
84
+ * [#180](https://github.com/socketry/nio4r/pull/180)
85
+ ext/nio4r/extconf.rb: check for port_event_t in port.h (fixes #178)
86
+ ([@tarcieri])
87
+
88
+ ## 2.1.0 (2017-05-28)
89
+
90
+ * [#130](https://github.com/socketry/nio4r/pull/130)
91
+ Add -fno-strict-aliasing flag when compiling C ext.
92
+ ([@junaruga])
93
+
94
+ * [#146](https://github.com/socketry/nio4r/pull/146)
95
+ Use non-blocking select when a timeout of 0 is given.
96
+ ([@tarcieri])
97
+
98
+ * [#147](https://github.com/socketry/nio4r/pull/147)
99
+ Update to libev 4.24.
100
+ ([@tarcieri])
101
+
102
+ * [#148](https://github.com/socketry/nio4r/pull/148)
103
+ Switch to the libev 4 API internally.
104
+ ([@tarcieri])
105
+
106
+ ## 2.0.0 (2016-12-28)
107
+
108
+ * [#53](https://github.com/socketry/nio4r/pull/53)
109
+ Limit lock scope to prevent recursive locking.
110
+ ([@johnnyt])
111
+
112
+ * [#95](https://github.com/socketry/nio4r/pull/95)
113
+ NIO::ByteBuffer Google Summer of Code project.
114
+ ([@UpeksheJay], [@tarcieri])
115
+
116
+ * [#111](https://github.com/socketry/nio4r/pull/111)
117
+ NIO::Selector#backend introspection support.
118
+ ([@tarcieri])
119
+
120
+ * [#112](https://github.com/socketry/nio4r/pull/112)
121
+ Upgrade to libev 4.23.
122
+ ([@tarcieri])
123
+
124
+ * [#119](https://github.com/socketry/nio4r/pull/119)
125
+ Disambiguate wakeup vs timeout (fixes #63, #66).
126
+ ([@tarcieri])
127
+
128
+ * [#124](https://github.com/socketry/nio4r/pull/124)
129
+ Monitor interests API improvements.
130
+ ([@tarcieri])
131
+
132
+ * Drop Ruby 2.0 and 2.1 support, require Ruby 2.2.2+.
133
+ ([@tarcieri])
134
+
135
+ ## 1.2.1 (2016-01-31)
136
+
3
137
  * Fix bug in the JRuby backend which cases indefinite blocking when small
4
138
  timeout values are passed to the selector
5
139
 
6
- 1.2.0 (2015-12-22)
7
- ------------------
140
+ ## 1.2.0 (2015-12-22)
141
+
8
142
  * Add NIO::Monitor#interests= API for changing interests. Contributed by
9
143
  Upekshe Jayasekera as a Google Summer of Code project.
10
144
  * Update to libev 4.22
11
145
 
12
- 1.1.1 (2015-07-17)
13
- ------------------
146
+ ## 1.1.1 (2015-07-17)
147
+
14
148
  * Update to libev 4.20
15
149
  * Fall back to io.h if unistd.h is not found
16
150
  * RSpec updates
17
151
  * RuboCop
18
152
 
19
- 1.1.0 (2015-01-10)
20
- ------------------
153
+ ## 1.1.0 (2015-01-10)
154
+
21
155
  * Update to libev 4.19
22
156
  * Do not call ev_io_stop on monitors if the loop is already closed
23
157
 
24
- 1.0.1 (2014-09-01)
25
- ------------------
158
+ ## 1.0.1 (2014-09-01)
159
+
26
160
  * Fix C compiler warnings
27
161
  * Eliminate Ruby warnings about @lock_holder
28
162
  * Windows improvements
@@ -30,59 +164,59 @@
30
164
  * Automatically require 'set'
31
165
  * Update to RSpec 3
32
166
 
33
- 1.0.0 (2014-01-14)
34
- ------------------
167
+ ## 1.0.0 (2014-01-14)
168
+
35
169
  * Have Selector#register obtain the actual IO from a Monitor object
36
170
  because Monitor#initialize might convert it.
37
171
  * Drop 1.8 support
38
172
 
39
- 0.5.0 (2013-08-06)
40
- ------------------
173
+ ## 0.5.0 (2013-08-06)
174
+
41
175
  * Fix segv when attempting to register to a closed selector
42
176
  * Fix Windows support on Ruby 2.0.0
43
177
  * Upgrade to libev 4.15
44
178
 
45
- 0.4.6 (2013-05-27)
46
- ------------------
179
+ ## 0.4.6 (2013-05-27)
180
+
47
181
  * Fix for JRuby on Windows
48
182
 
49
- 0.4.5
50
- -----
183
+ ## 0.4.5
184
+
51
185
  * Fix botched gem release
52
186
 
53
- 0.4.4
54
- -----
187
+ ## 0.4.4
188
+
55
189
  * Fix return values for Selector_synchronize and Selector_unlock
56
190
 
57
- 0.4.3
58
- -----
191
+ ## 0.4.3
192
+
59
193
  * REALLY have thread synchronization when closing selectors ;)
60
194
 
61
- 0.4.2
62
- -----
195
+ ## 0.4.2
196
+
63
197
  * Attempt to work around packaging problems with bundler-api o_O
64
198
 
65
- 0.4.1
66
- -----
199
+ ## 0.4.1
200
+
67
201
  * Thread synchronization when closing selectors
68
202
 
69
- 0.4.0
70
- -----
203
+ ## 0.4.0
204
+
71
205
  * OpenSSL::SSL::SSLSocket support
72
206
 
73
- 0.3.3
74
- -----
207
+ ## 0.3.3
208
+
75
209
  * NIO::Selector#select_each removed
76
210
  * Remove event buffer
77
211
  * Patch GIL unlock directly into libev
78
212
  * Re-release since 0.3.2 was botched :(
79
213
 
80
- 0.3.1
81
- -----
214
+ ## 0.3.1
215
+
82
216
  * Prevent CancelledKeyExceptions on JRuby
83
217
 
84
- 0.3.0
85
- -----
218
+ ## 0.3.0
219
+
86
220
  * NIO::Selector#select now takes a block and behaves like select_each
87
221
  * NIO::Selector#select_each is now deprecated and will be removed
88
222
  * Closing monitors detaches them from their selector
@@ -91,23 +225,37 @@
91
225
  * Bugfixes for zero/negative select timeouts
92
226
  * Handle OP_CONNECT properly on JRuby
93
227
 
94
- 0.2.2
95
- -----
228
+ ## 0.2.2
229
+
96
230
  * Raise IOError if asked to wake up a closed selector
97
231
 
98
- 0.2.1
99
- -----
232
+ ## 0.2.1
233
+
100
234
  * Implement wakeup mechanism using raw pipes instead of ev_async, since
101
235
  ev_async likes to cause segvs when used across threads (despite claims
102
236
  in the documentation to the contrary)
103
237
 
104
- 0.2.0
105
- -----
238
+ ## 0.2.0
239
+
106
240
  * NIO::Monitor#readiness API to query readiness, along with #readable? and
107
241
  #writable? helper methods
108
242
  * NIO::Selector#select_each API which avoids memory allocations if possible
109
243
  * Bugfixes for the JRuby implementation
110
244
 
111
- 0.1.0
112
- -----
245
+ ## 0.1.0
246
+
113
247
  * Initial release. Merry Christmas!
248
+
249
+ [@tarcieri]: https://github.com/tarcieri
250
+ [@johnnyt]: https://github.com/johnnyt
251
+ [@UpeksheJay]: https://github.com/UpeksheJay
252
+ [@junaruga]: https://github.com/junaruga
253
+ [@unak]: https://github.com/unak
254
+ [@MSP-Greg]: https://github.com/MSP-Greg
255
+ [@larskanis]: https://github.com/larskanis
256
+ [@HoneyryderChuck]: https://github.com/HoneyryderChuck
257
+ [@tompng]: https://github.com/tompng
258
+ [@ioquatix]: https://github.com/ioquatix
259
+ [@eregon]: https://github.com/eregon
260
+ [@olleolleolle]: https://github.com/olleolleolle
261
+ [@boazsegev]: https://github.com/boazsegev