diff options
author | Eric Wong <normalperson@yhbt.net> | 2012-06-12 18:29:00 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2012-06-12 18:29:00 -0700 |
commit | 5c62376bc9a1b0d7c8e664784a1fb97747a7c392 (patch) | |
tree | 4f1fe250ca670465dc9576e9a73b3ce79105394f /lib/raindrops | |
parent | 506df98df1dae59281fbb3b3c2c6bea7549a2288 (diff) | |
download | raindrops-5c62376bc9a1b0d7c8e664784a1fb97747a7c392.tar.gz |
When unix_listener_stats is called without arguments, it should still match the behavior of tcp_listener_stats and return ListenerStats object with zero values. This allows callers to iterate through the results to find the pathnames of all the Unix domain sockets in in listen mode.
Diffstat (limited to 'lib/raindrops')
-rw-r--r-- | lib/raindrops/linux.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/raindrops/linux.rb b/lib/raindrops/linux.rb index 1752b8a..7cfb653 100644 --- a/lib/raindrops/linux.rb +++ b/lib/raindrops/linux.rb @@ -54,14 +54,20 @@ module Raindrops::Linux Regexp.escape(path) end end - paths = /^\w+: \d+ \d+ 00000000 \d+ (\d+)\s+\d+ (#{paths.join('|')})$/n + 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| path = s[-1] - case s[0].to_i - when 2 then rv[path].queued += 1 - when 3 then rv[path].active += 1 + case s[0] + when "00000000" # client sockets + case s[1].to_i + when 2 then rv[path].queued += 1 + when 3 then rv[path].active += 1 + end + else + # listeners, vivify empty stats + rv[path] end end |