Hello community, here is the log from the commit of package rubygem-nio4r for openSUSE:Factory checked in at 2020-10-05 19:32:27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-nio4r (Old) and /work/SRC/openSUSE:Factory/.rubygem-nio4r.new.4249 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-nio4r" Mon Oct 5 19:32:27 2020 rev:9 rq:838059 version:2.5.4 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-nio4r/rubygem-nio4r.changes 2020-09-14 12:32:06.837243495 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-nio4r.new.4249/rubygem-nio4r.changes 2020-10-05 19:32:33.229057065 +0200 @@ -1,0 +2,13 @@ +Fri Sep 25 14:26:27 UTC 2020 - Stephan Kulow <[email protected]> + +updated to version 2.5.4 + see installed CHANGES.md + + ## 2.5.4 (2020-09-16) + + * [#251](https://github.com/socketry/nio4r/issues/251) + Intermittent SEGV during GC. + ([@boazsegev]) + + +------------------------------------------------------------------- Old: ---- nio4r-2.5.3.gem New: ---- nio4r-2.5.4.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-nio4r.spec ++++++ --- /var/tmp/diff_new_pack.FgQAiE/_old 2020-10-05 19:32:33.849059681 +0200 +++ /var/tmp/diff_new_pack.FgQAiE/_new 2020-10-05 19:32:33.853059697 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-nio4r -Version: 2.5.3 +Version: 2.5.4 Release: 0 %define mod_name nio4r %define mod_full_name %{mod_name}-%{version} ++++++ nio4r-2.5.3.gem -> nio4r-2.5.4.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGES.md new/CHANGES.md --- old/CHANGES.md 2020-09-07 09:29:16.000000000 +0200 +++ new/CHANGES.md 2020-09-16 00:16:52.000000000 +0200 @@ -1,3 +1,9 @@ +## 2.5.4 (2020-09-16) + +* [#251](https://github.com/socketry/nio4r/issues/251) + Intermittent SEGV during GC. + ([@boazsegev]) + ## 2.5.3 (2020-09-07) * [#241](https://github.com/socketry/nio4r/issues/241) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Guardfile new/Guardfile --- old/Guardfile 2020-09-07 09:29:16.000000000 +0200 +++ new/Guardfile 1970-01-01 01:00:00.000000000 +0100 @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -directories %w[lib spec] -clearing :on - -guard :rspec, cmd: "bundle exec rspec" do - watch(%r{^spec/.+_spec\.rb$}) - watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } - watch("spec/spec_helper.rb") { "spec" } -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2020-09-07 09:29:16.000000000 +0200 +++ new/README.md 2020-09-16 00:16:52.000000000 +0200 @@ -1,17 +1,10 @@ #  [](http://rubygems.org/gems/nio4r) -[](http://travis-ci.org/socketry/nio4r) -[](https://ci.appveyor.com/project/tarcieri/nio4r/branch/master) +[](https://github.com/socketry/nio4r/actions?query=workflow:nio4r) [](https://codeclimate.com/github/socketry/nio4r) [](https://coveralls.io/r/socketry/nio4r) [](http://www.rubydoc.info/gems/nio4r/2.2.0) -[](https://github.com/socketry/nio4r/blob/master/LICENSE.txt) - -_NOTE: This is the 2.x **stable** branch of nio4r. For the 1.x **legacy** branch, -please see:_ - -https://github.com/socketry/nio4r/tree/1-x-stable **New I/O for Ruby (nio4r)**: cross-platform asynchronous I/O primitives for scalable network clients and servers. Modeled after the Java NIO API, but @@ -25,13 +18,13 @@ ## Projects using nio4r * [ActionCable]: Rails 5 WebSocket protocol, uses nio4r for a WebSocket server -* [Celluloid::IO]: Actor-based concurrency framework, uses nio4r for async I/O -* [Socketry Async]: Asynchronous I/O framework for Ruby +* [Celluloid]: Actor-based concurrency framework, uses nio4r for async I/O +* [Async]: Asynchronous I/O framework for Ruby * [Puma]: Ruby/Rack web server built for concurrency [ActionCable]: https://rubygems.org/gems/actioncable -[Celluloid::IO]: https://github.com/celluloid/celluloid-io -[Socketry Async]: https://github.com/socketry/async +[Celluloid]: https://github.com/celluloid/celluloid-io +[Async]: https://github.com/socketry/async [Puma]: https://github.com/puma/puma ## Goals @@ -43,7 +36,6 @@ ## Supported platforms -* Ruby 2.3 * Ruby 2.4 * Ruby 2.5 * Ruby 2.6 @@ -57,17 +49,6 @@ * **Java NIO**: JRuby extension which wraps the Java NIO subsystem * **Pure Ruby**: `Kernel.select`-based backend that should work on any Ruby interpreter -## Discussion - -For discussion and general help with nio4r, email -[[email protected]][subscribe] -or join on the web via the [Google Group]. - -We're also on IRC at ##socketry on irc.freenode.net. - -[subscribe]: mailto:[email protected] -[google group]: https://groups.google.com/group/socketry - ## Documentation [Please see the nio4r wiki](https://github.com/socketry/nio4r/wiki) Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nio4r/.clang-format new/ext/nio4r/.clang-format --- old/ext/nio4r/.clang-format 1970-01-01 01:00:00.000000000 +0100 +++ new/ext/nio4r/.clang-format 2020-09-16 00:16:52.000000000 +0200 @@ -0,0 +1,16 @@ +--- +Language: Cpp +BasedOnStyle: WebKit +AllowAllParametersOfDeclarationOnNextLine: false +BinPackArguments: false +BinPackParameters: false +AlignConsecutiveMacros: false +AlignConsecutiveAssignments: false +BreakBeforeBraces: Linux +BraceWrapping: + AfterControlStatement: Never +IndentCaseLabels: true +PointerAlignment: Right +SpaceBeforeParens: ControlStatements +IndentWidth: 4 +... diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nio4r/bytebuffer.c new/ext/nio4r/bytebuffer.c --- old/ext/nio4r/bytebuffer.c 2020-09-07 09:29:16.000000000 +0200 +++ new/ext/nio4r/bytebuffer.c 2020-09-16 00:16:52.000000000 +0200 @@ -42,7 +42,7 @@ cNIO_ByteBuffer = rb_define_class_under(mNIO, "ByteBuffer", rb_cObject); rb_define_alloc_func(cNIO_ByteBuffer, NIO_ByteBuffer_allocate); - cNIO_ByteBuffer_OverflowError = rb_define_class_under(cNIO_ByteBuffer, "OverflowError", rb_eIOError); + cNIO_ByteBuffer_OverflowError = rb_define_class_under(cNIO_ByteBuffer, "OverflowError", rb_eIOError); cNIO_ByteBuffer_UnderflowError = rb_define_class_under(cNIO_ByteBuffer, "UnderflowError", rb_eIOError); cNIO_ByteBuffer_MarkUnsetError = rb_define_class_under(cNIO_ByteBuffer, "MarkUnsetError", rb_eIOError); @@ -85,8 +85,8 @@ static void NIO_ByteBuffer_free(struct NIO_ByteBuffer *buffer) { - if(buffer->buffer) - xfree(buffer->buffer); + if (buffer->buffer) + xfree(buffer->buffer); xfree(buffer); } @@ -133,17 +133,17 @@ pos = NUM2INT(new_position); - if(pos < 0) { + if (pos < 0) { rb_raise(rb_eArgError, "negative position given"); } - if(pos > buffer->limit) { + if (pos > buffer->limit) { rb_raise(rb_eArgError, "specified position exceeds limit"); } buffer->position = pos; - if(buffer->mark > buffer->position) { + if (buffer->mark > buffer->position) { buffer->mark = MARK_UNSET; } @@ -166,21 +166,21 @@ lim = NUM2INT(new_limit); - if(lim < 0) { + if (lim < 0) { rb_raise(rb_eArgError, "negative limit given"); } - if(lim > buffer->capacity) { + if (lim > buffer->capacity) { rb_raise(rb_eArgError, "specified limit exceeds capacity"); } buffer->limit = lim; - if(buffer->position > lim) { + if (buffer->position > lim) { buffer->position = lim; } - if(buffer->mark > lim) { + if (buffer->mark > lim) { buffer->mark = MARK_UNSET; } @@ -220,17 +220,17 @@ rb_scan_args(argc, argv, "01", &length); - if(length == Qnil) { + if (length == Qnil) { len = buffer->limit - buffer->position; } else { len = NUM2INT(length); } - if(len < 0) { + if (len < 0) { rb_raise(rb_eArgError, "negative length given"); } - if(len > buffer->limit - buffer->position) { + if (len > buffer->limit - buffer->position) { rb_raise(cNIO_ByteBuffer_UnderflowError, "not enough data in buffer"); } @@ -248,11 +248,11 @@ i = NUM2INT(index); - if(i < 0) { + if (i < 0) { rb_raise(rb_eArgError, "negative index given"); } - if(i >= buffer->limit) { + if (i >= buffer->limit) { rb_raise(rb_eArgError, "specified index exceeds limit"); } @@ -268,7 +268,7 @@ StringValue(string); length = RSTRING_LEN(string); - if(length > buffer->limit - buffer->position) { + if (length > buffer->limit - buffer->position) { rb_raise(cNIO_ByteBuffer_OverflowError, "buffer is full"); } @@ -289,14 +289,14 @@ rb_io_set_nonblock(fptr); nbytes = buffer->limit - buffer->position; - if(nbytes == 0) { + if (nbytes == 0) { rb_raise(cNIO_ByteBuffer_OverflowError, "buffer is full"); } bytes_read = read(FPTR_TO_FD(fptr), buffer->buffer + buffer->position, nbytes); - if(bytes_read < 0) { - if(errno == EAGAIN) { + if (bytes_read < 0) { + if (errno == EAGAIN) { return INT2NUM(0); } else { rb_sys_fail("write"); @@ -319,14 +319,14 @@ rb_io_set_nonblock(fptr); nbytes = buffer->limit - buffer->position; - if(nbytes == 0) { + if (nbytes == 0) { rb_raise(cNIO_ByteBuffer_UnderflowError, "no data remaining in buffer"); } bytes_written = write(FPTR_TO_FD(fptr), buffer->buffer + buffer->position, nbytes); - if(bytes_written < 0) { - if(errno == EAGAIN) { + if (bytes_written < 0) { + if (errno == EAGAIN) { return INT2NUM(0); } else { rb_sys_fail("write"); @@ -375,7 +375,7 @@ struct NIO_ByteBuffer *buffer; Data_Get_Struct(self, struct NIO_ByteBuffer, buffer); - if(buffer->mark < 0) { + if (buffer->mark < 0) { rb_raise(cNIO_ByteBuffer_MarkUnsetError, "mark has not been set"); } else { buffer->position = buffer->mark; @@ -402,8 +402,8 @@ struct NIO_ByteBuffer *buffer; Data_Get_Struct(self, struct NIO_ByteBuffer, buffer); - if(rb_block_given_p()) { - for(i = 0; i < buffer->limit; i++) { + if (rb_block_given_p()) { + for (i = 0; i < buffer->limit; i++) { rb_yield(INT2NUM(buffer->buffer[i])); } } else { @@ -421,9 +421,8 @@ return rb_sprintf( "#<%s:%p @position=%d @limit=%d @capacity=%d>", rb_class2name(CLASS_OF(self)), - (void*)self, + (void *)self, buffer->position, buffer->limit, - buffer->capacity - ); + buffer->capacity); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nio4r/extconf.rb new/ext/nio4r/extconf.rb --- old/ext/nio4r/extconf.rb 2020-09-07 09:29:16.000000000 +0200 +++ new/ext/nio4r/extconf.rb 2020-09-16 00:16:52.000000000 +0200 @@ -22,6 +22,8 @@ $defs << "-DEV_USE_PORT" if have_type("port_event_t", "port.h") $defs << "-DHAVE_SYS_RESOURCE_H" if have_header("sys/resource.h") +$defs << "-DEV_STANDALONE" # prevent libev from assuming "config.h" exists + CONFIG["optflags"] << " -fno-strict-aliasing" unless RUBY_PLATFORM =~ /mswin/ dir_config "nio4r_ext" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nio4r/libev.h new/ext/nio4r/libev.h --- old/ext/nio4r/libev.h 2020-09-07 09:29:16.000000000 +0200 +++ new/ext/nio4r/libev.h 2020-09-16 00:16:52.000000000 +0200 @@ -1,9 +1,7 @@ -#define EV_STANDALONE /* keeps ev from requiring config.h */ - #ifdef _WIN32 #define EV_SELECT_IS_WINSOCKET 1 #define EV_USE_MONOTONIC 0 #define EV_USE_REALTIME 0 #endif -#include "../libev/ev.h" \ No newline at end of file +#include "../libev/ev.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nio4r/monitor.c new/ext/nio4r/monitor.c --- old/ext/nio4r/monitor.c 2020-09-07 09:29:16.000000000 +0200 +++ new/ext/nio4r/monitor.c 2020-09-16 00:16:52.000000000 +0200 @@ -4,6 +4,7 @@ */ #include "nio4r.h" +#include <assert.h> static VALUE mNIO = Qnil; static VALUE cNIO_Monitor = Qnil; @@ -60,13 +61,14 @@ static VALUE NIO_Monitor_allocate(VALUE klass) { struct NIO_Monitor *monitor = (struct NIO_Monitor *)xmalloc(sizeof(struct NIO_Monitor)); - + assert(monitor); + *monitor = (struct NIO_Monitor){.self = Qnil}; return Data_Wrap_Struct(klass, NIO_Monitor_mark, NIO_Monitor_free, monitor); } static void NIO_Monitor_mark(struct NIO_Monitor *monitor) { - return rb_gc_mark(monitor->self); + rb_gc_mark(monitor->self); } static void NIO_Monitor_free(struct NIO_Monitor *monitor) @@ -85,15 +87,14 @@ Data_Get_Struct(self, struct NIO_Monitor, monitor); - if(interests_id == rb_intern("r")) { + if (interests_id == rb_intern("r")) { monitor->interests = EV_READ; - } else if(interests_id == rb_intern("w")) { + } else if (interests_id == rb_intern("w")) { monitor->interests = EV_WRITE; - } else if(interests_id == rb_intern("rw")) { + } else if (interests_id == rb_intern("rw")) { monitor->interests = EV_READ | EV_WRITE; } else { - rb_raise(rb_eArgError, "invalid event type %s (must be :r, :w, or :rw)", - RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0))); + rb_raise(rb_eArgError, "invalid event type %s (must be :r, :w, or :rw)", RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0))); } GetOpenFile(rb_convert_type(io, T_FILE, "IO", "to_io"), fptr); @@ -113,7 +114,7 @@ monitor->selector = selector; if (monitor->interests) { - ev_io_start(selector->ev_loop, &monitor->ev_io); + ev_io_start(selector->ev_loop, &monitor->ev_io); } return Qnil; @@ -128,17 +129,17 @@ rb_scan_args(argc, argv, "01", &deregister); selector = rb_ivar_get(self, rb_intern("selector")); - if(selector != Qnil) { + if (selector != Qnil) { /* if ev_loop is 0, it means that the loop has been stopped already (see NIO_Selector_shutdown) */ - if(monitor->interests && monitor->selector->ev_loop) { - ev_io_stop(monitor->selector->ev_loop, &monitor->ev_io); + if (monitor->interests && monitor->selector->ev_loop) { + ev_io_stop(monitor->selector->ev_loop, &monitor->ev_io); } monitor->selector = 0; rb_ivar_set(self, rb_intern("selector"), Qnil); - + /* Default value is true */ - if(deregister == Qtrue || deregister == Qnil) { + if (deregister == Qtrue || deregister == Qnil) { rb_funcall(selector, rb_intern("deregister"), 1, rb_ivar_get(self, rb_intern("io"))); } } @@ -166,7 +167,7 @@ static VALUE NIO_Monitor_set_interests(VALUE self, VALUE interests) { - if(NIL_P(interests)) { + if (NIL_P(interests)) { NIO_Monitor_update_interests(self, 0); } else { NIO_Monitor_update_interests(self, NIO_Monitor_symbol2interest(interests)); @@ -175,7 +176,8 @@ return rb_ivar_get(self, rb_intern("interests")); } -static VALUE NIO_Monitor_add_interest(VALUE self, VALUE interest) { +static VALUE NIO_Monitor_add_interest(VALUE self, VALUE interest) +{ struct NIO_Monitor *monitor; Data_Get_Struct(self, struct NIO_Monitor, monitor); @@ -185,7 +187,8 @@ return rb_ivar_get(self, rb_intern("interests")); } -static VALUE NIO_Monitor_remove_interest(VALUE self, VALUE interest) { +static VALUE NIO_Monitor_remove_interest(VALUE self, VALUE interest) +{ struct NIO_Monitor *monitor; Data_Get_Struct(self, struct NIO_Monitor, monitor); @@ -215,11 +218,11 @@ struct NIO_Monitor *monitor; Data_Get_Struct(self, struct NIO_Monitor, monitor); - if((monitor->revents & (EV_READ | EV_WRITE)) == (EV_READ | EV_WRITE)) { + if ((monitor->revents & (EV_READ | EV_WRITE)) == (EV_READ | EV_WRITE)) { return ID2SYM(rb_intern("rw")); - } else if(monitor->revents & EV_READ) { + } else if (monitor->revents & EV_READ) { return ID2SYM(rb_intern("r")); - } else if(monitor->revents & EV_WRITE) { + } else if (monitor->revents & EV_WRITE) { return ID2SYM(rb_intern("w")); } else { return Qnil; @@ -231,7 +234,7 @@ struct NIO_Monitor *monitor; Data_Get_Struct(self, struct NIO_Monitor, monitor); - if(monitor->revents & EV_READ) { + if (monitor->revents & EV_READ) { return Qtrue; } else { return Qfalse; @@ -243,7 +246,7 @@ struct NIO_Monitor *monitor; Data_Get_Struct(self, struct NIO_Monitor, monitor); - if(monitor->revents & EV_WRITE) { + if (monitor->revents & EV_WRITE) { return Qtrue; } else { return Qfalse; @@ -257,15 +260,14 @@ ID interests_id; interests_id = SYM2ID(interests); - if(interests_id == rb_intern("r")) { + if (interests_id == rb_intern("r")) { return EV_READ; - } else if(interests_id == rb_intern("w")) { + } else if (interests_id == rb_intern("w")) { return EV_WRITE; - } else if(interests_id == rb_intern("rw")) { + } else if (interests_id == rb_intern("rw")) { return EV_READ | EV_WRITE; } else { - rb_raise(rb_eArgError, "invalid interest type %s (must be :r, :w, or :rw)", - RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0))); + rb_raise(rb_eArgError, "invalid interest type %s (must be :r, :w, or :rw)", RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0))); } } @@ -275,12 +277,12 @@ struct NIO_Monitor *monitor; Data_Get_Struct(self, struct NIO_Monitor, monitor); - if(NIO_Monitor_is_closed(self) == Qtrue) { + if (NIO_Monitor_is_closed(self) == Qtrue) { rb_raise(rb_eEOFError, "monitor is closed"); } - if(interests) { - switch(interests) { + if (interests) { + switch (interests) { case EV_READ: interests_id = rb_intern("r"); break; @@ -299,9 +301,9 @@ rb_ivar_set(self, rb_intern("interests"), Qnil); } - if(monitor->interests != interests) { + if (monitor->interests != interests) { // If the monitor currently has interests, we should stop it. - if(monitor->interests) { + if (monitor->interests) { ev_io_stop(monitor->selector->ev_loop, &monitor->ev_io); } @@ -310,7 +312,7 @@ ev_io_set(&monitor->ev_io, monitor->ev_io.fd, monitor->interests); // If we are interested in events, schedule the monitor back into the event loop: - if(monitor->interests) { + if (monitor->interests) { ev_io_start(monitor->selector->ev_loop, &monitor->ev_io); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nio4r/nio4r.h new/ext/nio4r/nio4r.h --- old/ext/nio4r/nio4r.h 2020-09-07 09:29:16.000000000 +0200 +++ new/ext/nio4r/nio4r.h 2020-09-16 00:16:52.000000000 +0200 @@ -6,12 +6,11 @@ #ifndef NIO4R_H #define NIO4R_H +#include "libev.h" #include "ruby.h" #include "ruby/io.h" -#include "libev.h" -struct NIO_Selector -{ +struct NIO_Selector { struct ev_loop *ev_loop; struct ev_timer timer; /* for timeouts */ struct ev_io wakeup; @@ -24,31 +23,27 @@ VALUE ready_array; }; -struct NIO_callback_data -{ +struct NIO_callback_data { VALUE *monitor; struct NIO_Selector *selector; }; -struct NIO_Monitor -{ +struct NIO_Monitor { VALUE self; int interests, revents; struct ev_io ev_io; struct NIO_Selector *selector; }; -struct NIO_ByteBuffer -{ +struct NIO_ByteBuffer { char *buffer; int position, limit, capacity, mark; }; - #ifdef GetReadFile -# define FPTR_TO_FD(fptr) (fileno(GetReadFile(fptr))) +#define FPTR_TO_FD(fptr) (fileno(GetReadFile(fptr))) #else -# define FPTR_TO_FD(fptr) fptr->fd +#define FPTR_TO_FD(fptr) fptr->fd #endif /* GetReadFile */ /* Thunk between libev callbacks in NIO::Monitors and NIO::Selectors */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nio4r/nio4r_ext.c new/ext/nio4r/nio4r_ext.c --- old/ext/nio4r/nio4r_ext.c 2020-09-07 09:29:16.000000000 +0200 +++ new/ext/nio4r/nio4r_ext.c 2020-09-16 00:16:52.000000000 +0200 @@ -3,8 +3,8 @@ * See LICENSE.txt for further details. */ -#include "nio4r.h" #include "../libev/ev.c" +#include "nio4r.h" void Init_NIO_Selector(); void Init_NIO_Monitor(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nio4r/selector.c new/ext/nio4r/selector.c --- old/ext/nio4r/selector.c 2020-09-07 09:29:16.000000000 +0200 +++ new/ext/nio4r/selector.c 2020-09-16 00:16:52.000000000 +0200 @@ -5,7 +5,7 @@ #include "nio4r.h" #ifdef HAVE_RUBYSIG_H -# include "rubysig.h" +#include "rubysig.h" #endif #ifdef HAVE_UNISTD_H @@ -14,11 +14,11 @@ #include <io.h> #endif -#include <fcntl.h> #include <assert.h> +#include <fcntl.h> static VALUE mNIO = Qnil; -static VALUE cNIO_Monitor = Qnil; +static VALUE cNIO_Monitor = Qnil; static VALUE cNIO_Selector = Qnil; /* Allocator/deallocator */ @@ -80,7 +80,7 @@ rb_define_method(cNIO_Selector, "closed?", NIO_Selector_closed, 0); rb_define_method(cNIO_Selector, "empty?", NIO_Selector_is_empty, 0); - cNIO_Monitor = rb_define_class_under(mNIO, "Monitor", rb_cObject); + cNIO_Monitor = rb_define_class_under(mNIO, "Monitor", rb_cObject); } /* Create the libev event loop and incoming event buffer */ @@ -95,13 +95,12 @@ safety. Pipes are nice and safe to use between threads. Note that Java NIO uses this same mechanism */ - if(pipe(fds) < 0) { + if (pipe(fds) < 0) { rb_sys_fail("pipe"); } /* Use non-blocking reads/writes during wakeup, in case the buffer is full */ - if(fcntl(fds[0], F_SETFL, O_NONBLOCK) < 0 || - fcntl(fds[1], F_SETFL, O_NONBLOCK) < 0) { + if (fcntl(fds[0], F_SETFL, O_NONBLOCK) < 0 || fcntl(fds[1], F_SETFL, O_NONBLOCK) < 0) { rb_sys_fail("fcntl"); } @@ -127,7 +126,7 @@ /* NIO selectors store all Ruby objects in instance variables so mark is a stub */ static void NIO_Selector_mark(struct NIO_Selector *selector) { - if(selector->ready_array != Qnil) { + if (selector->ready_array != Qnil) { rb_gc_mark(selector->ready_array); } } @@ -136,14 +135,14 @@ Called by both NIO::Selector#close and the finalizer below */ static void NIO_Selector_shutdown(struct NIO_Selector *selector) { - if(selector->closed) { + if (selector->closed) { return; } close(selector->wakeup_reader); close(selector->wakeup_writer); - if(selector->ev_loop) { + if (selector->ev_loop) { ev_loop_destroy(selector->ev_loop); selector->ev_loop = 0; } @@ -159,27 +158,28 @@ } /* Return an array of symbols for supported backends */ -static VALUE NIO_Selector_supported_backends(VALUE klass) { +static VALUE NIO_Selector_supported_backends(VALUE klass) +{ unsigned int backends = ev_supported_backends(); VALUE result = rb_ary_new(); - if(backends & EVBACKEND_EPOLL) { + if (backends & EVBACKEND_EPOLL) { rb_ary_push(result, ID2SYM(rb_intern("epoll"))); } - if(backends & EVBACKEND_POLL) { + if (backends & EVBACKEND_POLL) { rb_ary_push(result, ID2SYM(rb_intern("poll"))); } - if(backends & EVBACKEND_KQUEUE) { + if (backends & EVBACKEND_KQUEUE) { rb_ary_push(result, ID2SYM(rb_intern("kqueue"))); } - if(backends & EVBACKEND_SELECT) { + if (backends & EVBACKEND_SELECT) { rb_ary_push(result, ID2SYM(rb_intern("select"))); } - if(backends & EVBACKEND_PORT) { + if (backends & EVBACKEND_PORT) { rb_ary_push(result, ID2SYM(rb_intern("port"))); } @@ -201,27 +201,25 @@ rb_scan_args(argc, argv, "01", &backend); - if(backend != Qnil) { - if(!rb_ary_includes(NIO_Selector_supported_backends(CLASS_OF(self)), backend)) { - rb_raise(rb_eArgError, "unsupported backend: %s", - RSTRING_PTR(rb_funcall(backend, rb_intern("inspect"), 0))); + if (backend != Qnil) { + if (!rb_ary_includes(NIO_Selector_supported_backends(CLASS_OF(self)), backend)) { + rb_raise(rb_eArgError, "unsupported backend: %s", RSTRING_PTR(rb_funcall(backend, rb_intern("inspect"), 0))); } backend_id = SYM2ID(backend); - if(backend_id == rb_intern("epoll")) { + if (backend_id == rb_intern("epoll")) { flags = EVBACKEND_EPOLL; - } else if(backend_id == rb_intern("poll")) { + } else if (backend_id == rb_intern("poll")) { flags = EVBACKEND_POLL; - } else if(backend_id == rb_intern("kqueue")) { + } else if (backend_id == rb_intern("kqueue")) { flags = EVBACKEND_KQUEUE; - } else if(backend_id == rb_intern("select")) { + } else if (backend_id == rb_intern("select")) { flags = EVBACKEND_SELECT; - } else if(backend_id == rb_intern("port")) { + } else if (backend_id == rb_intern("port")) { flags = EVBACKEND_PORT; } else { - rb_raise(rb_eArgError, "unsupported backend: %s", - RSTRING_PTR(rb_funcall(backend, rb_intern("inspect"), 0))); + rb_raise(rb_eArgError, "unsupported backend: %s", RSTRING_PTR(rb_funcall(backend, rb_intern("inspect"), 0))); } } @@ -229,7 +227,7 @@ assert(!selector->ev_loop); selector->ev_loop = ev_loop_new(flags); - if(!selector->ev_loop) { + if (!selector->ev_loop) { rb_raise(rb_eIOError, "error initializing event loop"); } @@ -245,11 +243,12 @@ return Qnil; } -static VALUE NIO_Selector_backend(VALUE self) { +static VALUE NIO_Selector_backend(VALUE self) +{ struct NIO_Selector *selector; Data_Get_Struct(self, struct NIO_Selector, selector); - if(selector->closed) { + if (selector->closed) { rb_raise(rb_eIOError, "selector is closed"); } @@ -277,7 +276,7 @@ current_thread = rb_thread_current(); lock_holder = rb_ivar_get(self, rb_intern("lock_holder")); - if(lock_holder != current_thread) { + if (lock_holder != current_thread) { lock = rb_ivar_get(self, rb_intern("lock")); rb_funcall(lock, rb_intern("lock"), 0); rb_ivar_set(self, rb_intern("lock_holder"), current_thread); @@ -306,7 +305,7 @@ /* Register an IO object with the selector for the given interests */ static VALUE NIO_Selector_register(VALUE self, VALUE io, VALUE interests) { - VALUE args[3] = {self, io, interests}; + VALUE args[3] = { self, io, interests }; return NIO_Selector_synchronize(self, NIO_Selector_register_synchronized, args); } @@ -322,14 +321,14 @@ interests = args[2]; Data_Get_Struct(self, struct NIO_Selector, selector); - if(selector->closed) { + if (selector->closed) { rb_raise(rb_eIOError, "selector is closed"); } selectables = rb_ivar_get(self, rb_intern("selectables")); monitor = rb_hash_lookup(selectables, io); - if(monitor != Qnil) + if (monitor != Qnil) rb_raise(rb_eArgError, "this IO is already registered with selector"); /* Create a new NIO::Monitor */ @@ -346,7 +345,7 @@ /* Deregister an IO object from the selector */ static VALUE NIO_Selector_deregister(VALUE self, VALUE io) { - VALUE args[2] = {self, io}; + VALUE args[2] = { self, io }; return NIO_Selector_synchronize(self, NIO_Selector_deregister_synchronized, args); } @@ -361,7 +360,7 @@ selectables = rb_ivar_get(self, rb_intern("selectables")); monitor = rb_hash_delete(selectables, io); - if(monitor != Qnil) { + if (monitor != Qnil) { rb_funcall(monitor, rb_intern("close"), 1, Qfalse); } @@ -385,7 +384,7 @@ rb_scan_args(argc, argv, "01", &timeout); - if(timeout != Qnil && NUM2DBL(timeout) < 0) { + if (timeout != Qnil && NUM2DBL(timeout) < 0) { rb_raise(rb_eArgError, "time interval must be positive"); } @@ -404,26 +403,26 @@ Data_Get_Struct(args[0], struct NIO_Selector, selector); - if(selector->closed) { + if (selector->closed) { rb_raise(rb_eIOError, "selector is closed"); } - if(!rb_block_given_p()) { + if (!rb_block_given_p()) { selector->ready_array = rb_ary_new(); } ready = NIO_Selector_run(selector, args[1]); /* Timeout */ - if(ready < 0) { - if(!rb_block_given_p()) { + if (ready < 0) { + if (!rb_block_given_p()) { selector->ready_array = Qnil; } return Qnil; } - if(rb_block_given_p()) { + if (rb_block_given_p()) { return INT2NUM(ready); } else { ready_array = selector->ready_array; @@ -441,12 +440,12 @@ selector->selecting = 1; selector->wakeup_fired = 0; - if(timeout == Qnil) { + if (timeout == Qnil) { /* Don't fire a wakeup timeout if we weren't passed one */ ev_timer_stop(selector->ev_loop, &selector->timer); } else { timeout_val = NUM2DBL(timeout); - if(timeout_val == 0) { + if (timeout_val == 0) { /* If we've been given an explicit timeout of 0, perform a non-blocking select operation */ ev_run_flags = EVRUN_NOWAIT; @@ -462,7 +461,7 @@ result = selector->ready_count; selector->selecting = selector->ready_count = 0; - if(result > 0 || selector->wakeup_fired) { + if (result > 0 || selector->wakeup_fired) { selector->wakeup_fired = 0; return result; } else { @@ -476,7 +475,7 @@ struct NIO_Selector *selector; Data_Get_Struct(self, struct NIO_Selector, selector); - if(selector->closed) { + if (selector->closed) { rb_raise(rb_eIOError, "selector is closed"); } @@ -489,7 +488,7 @@ /* Close the selector and free system resources */ static VALUE NIO_Selector_close(VALUE self) { - VALUE args[1] = {self}; + VALUE args[1] = { self }; return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, args); } @@ -507,7 +506,7 @@ /* Is the selector closed? */ static VALUE NIO_Selector_closed(VALUE self) { - VALUE args[1] = {self}; + VALUE args[1] = { self }; return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, args); } @@ -528,7 +527,6 @@ return rb_funcall(selectables, rb_intern("empty?"), 0) == Qtrue ? Qtrue : Qfalse; } - /* Called whenever a timeout fires on the event loop */ static void NIO_Selector_timeout_callback(struct ev_loop *ev_loop, struct ev_timer *timer, int revents) { @@ -542,7 +540,8 @@ selector->selecting = 0; /* Drain the wakeup pipe, giving us level-triggered behavior */ - while(read(selector->wakeup_reader, buffer, 128) > 0); + while (read(selector->wakeup_reader, buffer, 128) > 0) + ; } /* libev callback fired whenever a monitor gets an event */ @@ -558,7 +557,7 @@ selector->ready_count++; monitor_data->revents = revents; - if(rb_block_given_p()) { + if (rb_block_given_p()) { rb_yield(monitor); } else { assert(selector->ready_array != Qnil); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/nio/version.rb new/lib/nio/version.rb --- old/lib/nio/version.rb 2020-09-07 09:29:16.000000000 +0200 +++ new/lib/nio/version.rb 2020-09-16 00:16:52.000000000 +0200 @@ -1,5 +1,5 @@ # frozen_string_literal: true module NIO - VERSION = "2.5.3" + VERSION = "2.5.4" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2020-09-07 09:29:16.000000000 +0200 +++ new/metadata 2020-09-16 00:16:52.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: nio4r version: !ruby/object:Gem::Version - version: 2.5.3 + version: 2.5.4 platform: ruby authors: - Tony Arcieri autorequire: bindir: bin cert_chain: [] -date: 2020-09-07 00:00:00.000000000 Z +date: 2020-09-15 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: bundler @@ -53,7 +53,6 @@ - ".rubocop.yml" - CHANGES.md - Gemfile -- Guardfile - README.md - Rakefile - examples/echo_server.rb @@ -71,6 +70,7 @@ - ext/libev/ev_vars.h - ext/libev/ev_win32.c - ext/libev/ev_wrap.h +- ext/nio4r/.clang-format - ext/nio4r/bytebuffer.c - ext/nio4r/extconf.rb - ext/nio4r/libev.h @@ -108,8 +108,8 @@ metadata: bug_tracker_uri: https://github.com/socketry/nio4r/issues changelog_uri: https://github.com/socketry/nio4r/blob/master/CHANGES.md - documentation_uri: https://www.rubydoc.info/gems/nio4r/2.5.3 - source_code_uri: https://github.com/socketry/nio4r/tree/v2.5.3 + documentation_uri: https://www.rubydoc.info/gems/nio4r/2.5.4 + source_code_uri: https://github.com/socketry/nio4r/tree/v2.5.4 wiki_uri: https://github.com/socketry/nio4r/wiki post_install_message: rdoc_options: []
