From a9bfa55f9a1d1c96d73367d3bb46f7b9e81fbbf9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 14 Mar 2011 16:38:58 -0700 Subject: linux: unix_listener_stats may scan all paths This matches behavior of the TCP version. --- lib/raindrops/linux.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'lib/raindrops/linux.rb') diff --git a/lib/raindrops/linux.rb b/lib/raindrops/linux.rb index 889c661..55887f0 100644 --- a/lib/raindrops/linux.rb +++ b/lib/raindrops/linux.rb @@ -34,15 +34,19 @@ module Raindrops::Linux # counterpart due to the latter being able to use inet_diag via netlink. # This parses /proc/net/unix as there is no other (known) way # to expose Unix domain socket statistics over netlink. - def unix_listener_stats(paths) + def unix_listener_stats(paths = nil) rv = Hash.new { |h,k| h[k.freeze] = Raindrops::ListenStats.new(0, 0) } - paths = paths.map do |path| - path = path.dup - path.force_encoding(Encoding::BINARY) if defined?(Encoding) - rv[path] - Regexp.escape(path) + if nil == paths + paths = [ '[^\n]+' ] + else + paths = paths.map do |path| + path = path.dup + path.force_encoding(Encoding::BINARY) if defined?(Encoding) + rv[path] + Regexp.escape(path) + end end - paths = / 00000000 \d+ (\d+)\s+\d+ (#{paths.join('|')})$/n + paths = /^\w+: \d+ \d+ 00000000 \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| -- cgit v1.2.3-24-ge0c7