diff --git a/lib/libuv/ext/ext.rb b/lib/libuv/ext/ext.rb index 350eea6..f8d1b76 100644 --- a/lib/libuv/ext/ext.rb +++ b/lib/libuv/ext/ext.rb @@ -26,7 +26,7 @@ def self.malloc(bytes) def self.free(pointer) ::Libuv::Ext::LIBC.free(pointer) end - + def self.path_to_internal_libuv @path_to_internal_libuv ||= ::File.expand_path("../../../../ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}", __FILE__) @@ -49,22 +49,25 @@ def self.path_to_internal_libuv # Using home/user/lib is the best we can do on OSX # Primarily a dev platform so that is OK paths.unshift "#{ENV['HOME']}/lib" - elsif FFI::Platform.windows? - module Kernel32 - extend FFI::Library - ffi_lib 'Kernel32' - - attach_function :add_dll_dir, :AddDllDirectory, - [ :buffer_in ], :pointer + LIBUV_PATHS = paths.map{|path| "#{path}/libuv.1.#{FFI::Platform::LIBSUFFIX}"} + else + LIBUV_PATHS = paths.map{|path| "#{path}/libuv.#{FFI::Platform::LIBSUFFIX}"} + if FFI::Platform.windows? + module Kernel32 + extend FFI::Library + ffi_lib 'Kernel32' + + attach_function :add_dll_dir, :AddDllDirectory, + [ :buffer_in ], :pointer + end + # This ensures that externally loaded libraries like the libcouchbase gem + # will always use the same binary image and not load a second into memory + Kernel32.add_dll_dir "#{lib_path}\0".encode("UTF-16LE") + else # UNIX + # TODO:: ?? end - # This ensures that externally loaded libraries like the libcouchbase gem - # will always use the same binary image and not load a second into memory - Kernel32.add_dll_dir "#{lib_path}\0".encode("UTF-16LE") - else # UNIX - # TODO:: ?? end - LIBUV_PATHS = paths.map{|path| "#{path}/libuv.#{FFI::Platform::LIBSUFFIX}"} libuv = ffi_lib(LIBUV_PATHS + %w{libuv}).first rescue LoadError warn <<-WARNING diff --git a/lib/libuv/ext/tasks/mac.rb b/lib/libuv/ext/tasks/mac.rb index ceda755..cf704c0 100644 --- a/lib/libuv/ext/tasks/mac.rb +++ b/lib/libuv/ext/tasks/mac.rb @@ -18,7 +18,7 @@ FileUtils.cp("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}", "ext/libuv/lib/libuv.#{FFI::Platform::LIBSUFFIX}") # Primrary load location - falls back to above if not available - FileUtils.cp("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}", "#{user_lib}/libuv.#{FFI::Platform::LIBSUFFIX}") + FileUtils.cp("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}", "#{user_lib}/libuv.1.#{FFI::Platform::LIBSUFFIX}") end CLOBBER.include("ext/libuv/.libs/libuv.1.#{FFI::Platform::LIBSUFFIX}") diff --git a/lib/libuv/reactor.rb b/lib/libuv/reactor.rb index 55f412d..f6efec6 100644 --- a/lib/libuv/reactor.rb +++ b/lib/libuv/reactor.rb @@ -110,6 +110,7 @@ def initialize(pointer) # :notnew: def stop_cb + return unless @reactor_running Thread.current.thread_variable_set(:reactor, nil) @reactor_running = false @@ -541,6 +542,7 @@ def log(error, msg = nil, trace = nil) # Closes handles opened by the reactor class and completes the current reactor iteration (thread safe) def stop + return unless @reactor_running @stop_reactor.call end diff --git a/lib/libuv/version.rb b/lib/libuv/version.rb index e567107..05e9fa2 100644 --- a/lib/libuv/version.rb +++ b/lib/libuv/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Libuv - VERSION = '4.0.4' + VERSION = '4.1.0' end