From 85486f9af18e4f249f23253e3b251e685b323912 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 6 Jan 2020 09:54:50 +0000 Subject: fixes for newer rubies Newer rubies have more warnings --- lib/raindrops/aggregate/pmq.rb | 12 ++++++------ lib/raindrops/linux.rb | 9 ++++----- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/raindrops/aggregate/pmq.rb b/lib/raindrops/aggregate/pmq.rb index 8623cb1..64d0a4f 100644 --- a/lib/raindrops/aggregate/pmq.rb +++ b/lib/raindrops/aggregate/pmq.rb @@ -142,8 +142,8 @@ class Raindrops::Aggregate::PMQ warn "Unhandled exception in #{__FILE__}:#{__LINE__}: #{e}" break end while true - ensure - flush_master + ensure + flush_master end # Loads the last shared \Aggregate from the master thread/process @@ -175,14 +175,14 @@ class Raindrops::Aggregate::PMQ # worker thread or process def stop_master_loop sleep 0.1 until mq_send(false) - rescue Errno::EINTR - retry + rescue Errno::EINTR + retry end def lock! io, type # :nodoc: io.fcntl Fcntl::F_SETLKW, type - rescue Errno::EINTR - retry + rescue Errno::EINTR + retry end # we use both a mutex for thread-safety and fcntl lock for process-safety diff --git a/lib/raindrops/linux.rb b/lib/raindrops/linux.rb index 4166ec7..9842ae1 100644 --- a/lib/raindrops/linux.rb +++ b/lib/raindrops/linux.rb @@ -14,8 +14,7 @@ module Raindrops::Linux # The standard proc path for active UNIX domain sockets, feel free to call # String#replace on this if your /proc is mounted in a non-standard location # for whatever reason - PROC_NET_UNIX_ARGS = %w(/proc/net/unix) - defined?(::Encoding) and PROC_NET_UNIX_ARGS.push({ :encoding => "binary" }) + PROC_NET_UNIX_ARGS = [ '/proc/net/unix', { encoding: "binary" }] # Get ListenStats from an array of +paths+ # @@ -42,11 +41,11 @@ module Raindrops::Linux else paths = paths.map do |path| path = path.dup - path.force_encoding(Encoding::BINARY) if defined?(Encoding) + path.force_encoding(Encoding::BINARY) if File.symlink?(path) link = path path = File.readlink(link) - path.force_encoding(Encoding::BINARY) if defined?(Encoding) + path.force_encoding(Encoding::BINARY) rv[link] = rv[path] # vivify ListenerStats else rv[path] # vivify ListenerStats @@ -57,7 +56,7 @@ module Raindrops::Linux paths = /^\w+: \d+ \d+ (\d+) \d+ (\d+)\s+\d+ (#{paths.join('|')})$/n # no point in pread since we can't stat for size on this file - File.read(*PROC_NET_UNIX_ARGS).scan(paths) do |s| + File.read(PROC_NET_UNIX_ARGS[0], encoding: 'binary').scan(paths) do |s| path = s[-1] case s[0] when "00000000" # client sockets -- cgit v1.2.3-24-ge0c7