nio4r 2.5.9 → 2.6.0

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: 1572a271d329a29e7168c04b8f3776a41f23f495227a0a41ab9f1cd80233f1d6
4
- data.tar.gz: 6c7e944abd93038272299db034c3c67829d093e2ce4a75292eba4c654cd2ae0f
3
+ metadata.gz: eab5b3508546814a4410d58d28544b2c7f03a342add4e5079b7c790d4f7c446f
4
+ data.tar.gz: 55379f65438359187736c5694cbc8f5d2d564db5bf53f1bc35581776a3ff21d2
5
5
  SHA512:
6
- metadata.gz: 78e502f54f1eedeb948c412e9ecc5fa241c082b3ed292d9a50d1acbff76ee499904d70367eccb52db5c513f6bd91ac647846fa6cce6632ca9ba22c5d28a46682
7
- data.tar.gz: 992198b186b8186e37bc84da3d89b1ddbae76ae9e8aaa45973111a8a9cd94e80c7b23ed9558449c409079b2b9c6cb1ca9edefa78ef5f8010c43a7c34ee000fc4
6
+ metadata.gz: e74ab1a8755c231e4e934b8aa7561c05a8cedb5397b2af56d507ec7e56c439dbb369b1282bdef89c25d294b0416306ae410e1731b588e027bfdeab0af1e9c0a6
7
+ data.tar.gz: acd27ad638957e8cc65a5d2cbf47e46c8269d99fc509a000810b20e58d795996e412d70f1b75d6bdf5b71701ff93fabca21bda8d2183d7506459b6e2e6c3c42f
@@ -1,3 +1,7 @@
1
+ ## 2.5.9 (2023-04-02)
2
+
3
+ https://github.com/socketry/nio4r/compare/v2.5.8..v2.5.9
4
+
1
5
  ## 2.5.8 (2021-08-03)
2
6
 
3
7
  * [#276](https://github.com/socketry/nio4r/pull/276)
@@ -36,6 +36,26 @@ static VALUE NIO_ByteBuffer_inspect(VALUE self);
36
36
 
37
37
  #define MARK_UNSET -1
38
38
 
39
+ /* Compatibility for Ruby <= 3.1 */
40
+ #ifndef HAVE_RB_IO_DESCRIPTOR
41
+ static int
42
+ io_descriptor_fallback(VALUE io)
43
+ {
44
+ rb_io_t *fptr;
45
+ GetOpenFile(io, fptr);
46
+ return fptr->fd;
47
+ }
48
+ #define rb_io_descriptor io_descriptor_fallback
49
+ #endif
50
+
51
+ static void
52
+ io_set_nonblock(VALUE io)
53
+ {
54
+ rb_io_t *fptr;
55
+ GetOpenFile(io, fptr);
56
+ rb_io_set_nonblock(fptr);
57
+ }
58
+
39
59
  void Init_NIO_ByteBuffer()
40
60
  {
41
61
  mNIO = rb_define_module("NIO");
@@ -281,19 +301,19 @@ static VALUE NIO_ByteBuffer_put(VALUE self, VALUE string)
281
301
  static VALUE NIO_ByteBuffer_read_from(VALUE self, VALUE io)
282
302
  {
283
303
  struct NIO_ByteBuffer *buffer;
284
- rb_io_t *fptr;
285
304
  ssize_t nbytes, bytes_read;
286
305
 
287
306
  Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
288
- GetOpenFile(rb_convert_type(io, T_FILE, "IO", "to_io"), fptr);
289
- rb_io_set_nonblock(fptr);
307
+
308
+ io = rb_convert_type(io, T_FILE, "IO", "to_io");
309
+ io_set_nonblock(io);
290
310
 
291
311
  nbytes = buffer->limit - buffer->position;
292
312
  if (nbytes == 0) {
293
313
  rb_raise(cNIO_ByteBuffer_OverflowError, "buffer is full");
294
314
  }
295
315
 
296
- bytes_read = read(FPTR_TO_FD(fptr), buffer->buffer + buffer->position, nbytes);
316
+ bytes_read = read(rb_io_descriptor(io), buffer->buffer + buffer->position, nbytes);
297
317
 
298
318
  if (bytes_read < 0) {
299
319
  if (errno == EAGAIN) {
@@ -305,25 +325,24 @@ static VALUE NIO_ByteBuffer_read_from(VALUE self, VALUE io)
305
325
 
306
326
  buffer->position += bytes_read;
307
327
 
308
- return INT2NUM(bytes_read);
328
+ return SIZET2NUM(bytes_read);
309
329
  }
310
330
 
311
331
  static VALUE NIO_ByteBuffer_write_to(VALUE self, VALUE io)
312
332
  {
313
333
  struct NIO_ByteBuffer *buffer;
314
- rb_io_t *fptr;
315
334
  ssize_t nbytes, bytes_written;
316
335
 
317
336
  Data_Get_Struct(self, struct NIO_ByteBuffer, buffer);
318
- GetOpenFile(rb_convert_type(io, T_FILE, "IO", "to_io"), fptr);
319
- rb_io_set_nonblock(fptr);
337
+ io = rb_convert_type(io, T_FILE, "IO", "to_io");
338
+ io_set_nonblock(io);
320
339
 
321
340
  nbytes = buffer->limit - buffer->position;
322
341
  if (nbytes == 0) {
323
342
  rb_raise(cNIO_ByteBuffer_UnderflowError, "no data remaining in buffer");
324
343
  }
325
344
 
326
- bytes_written = write(FPTR_TO_FD(fptr), buffer->buffer + buffer->position, nbytes);
345
+ bytes_written = write(rb_io_descriptor(io), buffer->buffer + buffer->position, nbytes);
327
346
 
328
347
  if (bytes_written < 0) {
329
348
  if (errno == EAGAIN) {
@@ -335,7 +354,7 @@ static VALUE NIO_ByteBuffer_write_to(VALUE self, VALUE io)
335
354
 
336
355
  buffer->position += bytes_written;
337
356
 
338
- return INT2NUM(bytes_written);
357
+ return SIZET2NUM(bytes_written);
339
358
  }
340
359
 
341
360
  static VALUE NIO_ByteBuffer_flip(VALUE self)
data/ext/nio4r/extconf.rb CHANGED
@@ -16,6 +16,7 @@ end
16
16
  require "mkmf"
17
17
 
18
18
  have_header("unistd.h")
19
+ have_func("rb_io_descriptor")
19
20
 
20
21
  $defs << "-DEV_USE_LINUXAIO" if have_header("linux/aio_abi.h")
21
22
  $defs << "-DEV_USE_IOURING" if have_header("linux/io_uring.h")
data/ext/nio4r/monitor.c CHANGED
@@ -34,6 +34,18 @@ static VALUE NIO_Monitor_readiness(VALUE self);
34
34
  static int NIO_Monitor_symbol2interest(VALUE interests);
35
35
  static void NIO_Monitor_update_interests(VALUE self, int interests);
36
36
 
37
+ /* Compatibility for Ruby <= 3.1 */
38
+ #ifndef HAVE_RB_IO_DESCRIPTOR
39
+ static int
40
+ io_descriptor_fallback(VALUE io)
41
+ {
42
+ rb_io_t *fptr;
43
+ GetOpenFile(io, fptr);
44
+ return fptr->fd;
45
+ }
46
+ #define rb_io_descriptor io_descriptor_fallback
47
+ #endif
48
+
37
49
  /* Monitor control how a channel is being waited for by a monitor */
38
50
  void Init_NIO_Monitor()
39
51
  {
@@ -81,7 +93,6 @@ static VALUE NIO_Monitor_initialize(VALUE self, VALUE io, VALUE interests, VALUE
81
93
  struct NIO_Monitor *monitor;
82
94
  struct NIO_Selector *selector;
83
95
  ID interests_id;
84
- rb_io_t *fptr;
85
96
 
86
97
  interests_id = SYM2ID(interests);
87
98
 
@@ -97,8 +108,8 @@ static VALUE NIO_Monitor_initialize(VALUE self, VALUE io, VALUE interests, VALUE
97
108
  rb_raise(rb_eArgError, "invalid event type %s (must be :r, :w, or :rw)", RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0)));
98
109
  }
99
110
 
100
- GetOpenFile(rb_convert_type(io, T_FILE, "IO", "to_io"), fptr);
101
- ev_io_init(&monitor->ev_io, NIO_Selector_monitor_callback, FPTR_TO_FD(fptr), monitor->interests);
111
+ io = rb_convert_type(io, T_FILE, "IO", "to_io");
112
+ ev_io_init(&monitor->ev_io, NIO_Selector_monitor_callback, rb_io_descriptor(io), monitor->interests);
102
113
 
103
114
  rb_ivar_set(self, rb_intern("io"), io);
104
115
  rb_ivar_set(self, rb_intern("interests"), interests);
@@ -182,7 +193,7 @@ static VALUE NIO_Monitor_add_interest(VALUE self, VALUE interest)
182
193
  Data_Get_Struct(self, struct NIO_Monitor, monitor);
183
194
 
184
195
  interest = monitor->interests | NIO_Monitor_symbol2interest(interest);
185
- NIO_Monitor_update_interests(self, interest);
196
+ NIO_Monitor_update_interests(self, (int)interest);
186
197
 
187
198
  return rb_ivar_get(self, rb_intern("interests"));
188
199
  }
@@ -193,7 +204,7 @@ static VALUE NIO_Monitor_remove_interest(VALUE self, VALUE interest)
193
204
  Data_Get_Struct(self, struct NIO_Monitor, monitor);
194
205
 
195
206
  interest = monitor->interests & ~NIO_Monitor_symbol2interest(interest);
196
- NIO_Monitor_update_interests(self, interest);
207
+ NIO_Monitor_update_interests(self, (int)interest);
197
208
 
198
209
  return rb_ivar_get(self, rb_intern("interests"));
199
210
  }
data/ext/nio4r/nio4r.h CHANGED
@@ -40,12 +40,6 @@ struct NIO_ByteBuffer {
40
40
  int position, limit, capacity, mark;
41
41
  };
42
42
 
43
- #ifdef GetReadFile
44
- #define FPTR_TO_FD(fptr) (fileno(GetReadFile(fptr)))
45
- #else
46
- #define FPTR_TO_FD(fptr) fptr->fd
47
- #endif /* GetReadFile */
48
-
49
43
  /* Thunk between libev callbacks in NIO::Monitors and NIO::Selectors */
50
44
  void NIO_Selector_monitor_callback(struct ev_loop *ev_loop, struct ev_io *io, int revents);
51
45
 
data/lib/nio/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NIO
4
- VERSION = "2.5.9"
4
+ VERSION = "2.6.0"
5
5
  end
data/lib/nio4r.rb ADDED
@@ -0,0 +1 @@
1
+ require_relative "nio"
@@ -93,6 +93,15 @@ rake release
93
93
  You might need to delete `Gemfile.lock` before trying to `bundle install`.
94
94
 
95
95
  ```
96
+ # Ensure you have the correct JDK:
97
+ pacman -Syu jdk-openjdk
98
+ archlinux-java set java-19-openjdk
99
+
100
+ # Ensure you are using jruby:
101
+ chruby jruby
102
+ bundle update
103
+
104
+ # Build the package:
96
105
  rake clean
97
106
  rake compile
98
107
  rake release
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nio4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.9
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-02 00:00:00.000000000 Z
11
+ date: 2023-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -51,10 +51,9 @@ files:
51
51
  - ".gitignore"
52
52
  - ".rspec"
53
53
  - ".rubocop.yml"
54
- - CHANGES.md
55
54
  - Gemfile
56
- - README.md
57
55
  - Rakefile
56
+ - changes.md
58
57
  - examples/echo_server.rb
59
58
  - ext/libev/Changes
60
59
  - ext/libev/LICENSE
@@ -88,12 +87,14 @@ files:
88
87
  - lib/nio/monitor.rb
89
88
  - lib/nio/selector.rb
90
89
  - lib/nio/version.rb
90
+ - lib/nio4r.rb
91
91
  - license.md
92
92
  - logo.png
93
93
  - nio4r.gemspec
94
94
  - rakelib/extension.rake
95
95
  - rakelib/rspec.rake
96
96
  - rakelib/rubocop.rake
97
+ - readme.md
97
98
  - spec/nio/acceptables_spec.rb
98
99
  - spec/nio/bytebuffer_spec.rb
99
100
  - spec/nio/monitor_spec.rb
@@ -110,8 +111,8 @@ licenses:
110
111
  metadata:
111
112
  bug_tracker_uri: https://github.com/socketry/nio4r/issues
112
113
  changelog_uri: https://github.com/socketry/nio4r/blob/master/CHANGES.md
113
- documentation_uri: https://www.rubydoc.info/gems/nio4r/2.5.9
114
- source_code_uri: https://github.com/socketry/nio4r/tree/v2.5.9
114
+ documentation_uri: https://www.rubydoc.info/gems/nio4r/2.6.0
115
+ source_code_uri: https://github.com/socketry/nio4r/tree/v2.6.0
115
116
  wiki_uri: https://github.com/socketry/nio4r/wiki
116
117
  post_install_message:
117
118
  rdoc_options: []
@@ -128,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
129
  - !ruby/object:Gem::Version
129
130
  version: '0'
130
131
  requirements: []
131
- rubygems_version: 3.4.6
132
+ rubygems_version: 3.4.10
132
133
  signing_key:
133
134
  specification_version: 4
134
135
  summary: New IO for Ruby