From 653c9661a0a49a22336c831d806c4b2198520a98 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sun, 7 Jul 2019 12:54:36 +1200 Subject: [PATCH 1/3] Bump minimum supported Ruby to 2.3. --- .rubocop.yml | 2 +- appveyor.yml | 10 ++-------- nio4r.gemspec | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1559f6e..1fc780b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.2 + TargetRubyVersion: 2.3 DisplayCopNames: true Layout/SpaceInsideBlockBraces: diff --git a/appveyor.yml b/appveyor.yml index f84c922..5e92524 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,6 @@ environment: - RUBY_VERSION: 24-x64 - RUBY_VERSION: 23-x64 - RUBY_VERSION: 23 - - RUBY_VERSION: 22 init: - ps: | @@ -23,16 +22,11 @@ init: install: - SET RAKEOPT=-rdevkit - - ps: | - if ($env:RUBY_VERSION -eq '_trunk' -or $env:RUBY_VERSION -ge '23' ) { - gem update --system --conservative --no-document - } else { - gem update --system 2.7.9 --conservative --no-document - } + - gem update --system --conservative --no-document - ruby -v - gem -v - bundle -v - - bundle install --path vendor\bundle + - bundle install --path vendor\bundle --without development test_script: - bundle exec rake spec diff --git a/nio4r.gemspec b/nio4r.gemspec index b2e039d..c52577c 100644 --- a/nio4r.gemspec +++ b/nio4r.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.version = NIO::VERSION - spec.required_ruby_version = ">= 2.2.2" + spec.required_ruby_version = ">= 2.3" if defined? JRUBY_VERSION spec.files << "lib/nio4r_ext.jar" From cb792f70b37d6234461148d4db8447ec477c5664 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sun, 7 Jul 2019 12:55:22 +1200 Subject: [PATCH 2/3] Don't freeze strings in file with `frozen_string_literal`. --- lib/nio.rb | 6 +++--- lib/nio/version.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/nio.rb b/lib/nio.rb index 8b8f5e0..728c250 100644 --- a/lib/nio.rb +++ b/lib/nio.rb @@ -18,7 +18,7 @@ def self.engine require "nio/monitor" require "nio/selector" require "nio/bytebuffer" - NIO::ENGINE = "ruby".freeze + NIO::ENGINE = "ruby" else require "nio4r_ext" @@ -26,8 +26,8 @@ def self.engine require "java" require "jruby" org.nio4r.Nio4r.new.load(JRuby.runtime, false) - NIO::ENGINE = "java".freeze + NIO::ENGINE = "java" else - NIO::ENGINE = "libev".freeze + NIO::ENGINE = "libev" end end diff --git a/lib/nio/version.rb b/lib/nio/version.rb index dc6b26f..029a593 100644 --- a/lib/nio/version.rb +++ b/lib/nio/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module NIO - VERSION = "2.4.0".freeze + VERSION = "2.4.0" end From ab49b3e9a6ef51054327412415d3586f9c1e4ca6 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sun, 7 Jul 2019 12:55:46 +1200 Subject: [PATCH 3/3] Experimentally enable KQUEUE on macOS 10.14+. --- ext/libev/ev.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ext/libev/ev.c b/ext/libev/ev.c index fab6760..b380b14 100644 --- a/ext/libev/ev.c +++ b/ext/libev/ev.c @@ -40,6 +40,10 @@ /* ########## NIO4R PATCHERY HO! ########## */ #include "ruby.h" #include "ruby/thread.h" + +#ifdef __APPLE__ +#include +#endif /* ######################################## */ /* this big block deduces configuration from config.h */ @@ -2765,16 +2769,17 @@ ev_recommended_backends (void) EV_NOEXCEPT { unsigned int flags = ev_supported_backends (); -#ifndef __NetBSD__ +#if defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_14) + /* apple has a poor track record but post 10.12.2 it seems to work sufficiently well */ +#elif defined(__NetBSD__) /* kqueue is borked on everything but netbsd apparently */ /* it usually doesn't work correctly on anything but sockets and pipes */ - flags &= ~EVBACKEND_KQUEUE; -#endif -#ifdef __APPLE__ +#else /* only select works correctly on that "unix-certified" platform */ flags &= ~EVBACKEND_KQUEUE; /* horribly broken, even for sockets */ flags &= ~EVBACKEND_POLL; /* poll is based on kqueue from 10.5 onwards */ #endif + #ifdef __FreeBSD__ flags &= ~EVBACKEND_POLL; /* poll return value is unusable (http://forums.freebsd.org/archive/index.php/t-10270.html) */ #endif