nio4r 2.5.9-java → 2.6.0-java

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: 926dfd6f5d97b42c4f9123427c65d0981637bb6f20f4dc91777e1dae04b01b2d
4
- data.tar.gz: 0b36d60e26ef7ae81ce236ce67e22fb8572318ed51a72dcdc6f9ba20cf78b0ee
3
+ metadata.gz: aa7ff0bd09ef7e889ab134788e01d7adee76d918828a04770b7870218b5d4209
4
+ data.tar.gz: 7e86a3c72cbc429069af232f7e01b526135a1d0318ff5ed26ed17fada28529cf
5
5
  SHA512:
6
- metadata.gz: dd38f20089fd654f43604ce0b72a00918a0e412caf3d6ab39ce07f99635e22f597c0647db46793dda31b5b19545d36abb54241053391aba3255cd9cc9569bd76
7
- data.tar.gz: af4fa2e1d9bda70ae2b9ada8a409d503fb4254acc9fcd57f212cf70549d9252cc5d95e3f80eee211a714ec897897d8e400d4655ae65f8a9028ead8fc514efd0f
6
+ metadata.gz: '0900a204af3c7da49f8f1e8752f91b611edaa5c7520cd5abd338c42018de9a543cc3ca9fd95134a2d22d1e71f6739e5908122a93638ca4fcbe42879a5217ce2a'
7
+ data.tar.gz: 53123e588d68838ce473aeae69891d1d54321e934df358421f40238485cc3881286b89f839cb7634c75cd65e50592eabf8d2d026a26bf627a35fa1c9c5b2587d
@@ -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"
data/lib/nio4r_ext.jar CHANGED
Binary file
@@ -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: java
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
  requirement: !ruby/object:Gem::Requirement
@@ -50,10 +50,9 @@ files:
50
50
  - ".gitignore"
51
51
  - ".rspec"
52
52
  - ".rubocop.yml"
53
- - CHANGES.md
54
53
  - Gemfile
55
- - README.md
56
54
  - Rakefile
55
+ - changes.md
57
56
  - examples/echo_server.rb
58
57
  - ext/libev/Changes
59
58
  - ext/libev/LICENSE
@@ -87,6 +86,7 @@ files:
87
86
  - lib/nio/monitor.rb
88
87
  - lib/nio/selector.rb
89
88
  - lib/nio/version.rb
89
+ - lib/nio4r.rb
90
90
  - lib/nio4r_ext.jar
91
91
  - license.md
92
92
  - logo.png
@@ -94,6 +94,7 @@ files:
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: []