From: Eric Wong <normalperson@yhbt.net> To: raindrops@librelist.org Subject: [PATCH] unix: show zero-value stats for idle listeners Date: Wed, 13 Jun 2012 01:39:37 +0000 Message-ID: <20120613013937.GA24491@dcvr.yhbt.net> (raw) In-Reply-To: <20120613013937.GA24491@dcvr.yhbt.net> 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. --- Pushed to "master" git://bogomips.org/raindrops I'm thinking about releasing raindrops v0.10.0 soon. I probably won't have time to use unix_diag functionality in the Linux 3.3 kernel. I'm also lacking motivation since it'll be a while before Linux 3.3 is widely-available on servers, and I'm still supporting raindrops on 2.6.18 kernels :< Brian Corrigan (1): resolve symlinks to Unix domain sockets Eric Wong (3): unix_listener_stats follows and remembers symlinks middleware/proxy: favor __send__ for method dispatch unix: show zero-value stats for idle listeners lib/raindrops/linux.rb | 14 ++++++++++---- test/test_linux.rb | 11 +++++++++++ 2 files changed, 21 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 diff --git a/test/test_linux.rb b/test/test_linux.rb index a84eecf..0e79a86 100644 --- a/test/test_linux.rb +++ b/test/test_linux.rb @@ -67,6 +67,17 @@ class TestLinux < Test::Unit::TestCase assert_equal 1, stats[tmp.path].queued end + def test_unix_all_unused + tmp = Tempfile.new("\xde\xad\xbe\xef") # valid path, really :) + File.unlink(tmp.path) + us = UNIXServer.new(tmp.path) + stats = unix_listener_stats + assert stats.keys.include?(tmp.path), stats.inspect + + assert_equal 0, stats[tmp.path].active + assert_equal 0, stats[tmp.path].queued + end + def test_unix_resolves_symlinks tmp = Tempfile.new("\xde\xad\xbe\xef") # valid path, really :) File.unlink(tmp.path) -- Eric Wong
parent reply other threads:[~2012-06-13 1:39 UTC|newest] Thread overview: expand[flat|nested] mbox.gz Atom feed [parent not found: <20120613013937.GA24491@dcvr.yhbt.net>]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://yhbt.net/raindrops/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20120613013937.GA24491@dcvr.yhbt.net \ --to=normalperson@yhbt.net \ --cc=raindrops@librelist.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
raindrops RubyGem user+dev discussion/patches/pulls/bugs/help This inbox may be cloned and mirrored by anyone: git clone --mirror https://yhbt.net/raindrops-public git clone --mirror http://ou63pmih66umazou.onion/raindrops-public # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V1 raindrops-public raindrops-public/ https://yhbt.net/raindrops-public \ raindrops-public@yhbt.net raindrops-public@bogomips.org raindrops@librelist.org raindrops@librelist.com public-inbox-index raindrops-public Example config snippet for mirrors. Newsgroups are available over NNTP: nntp://news.public-inbox.org/inbox.comp.lang.ruby.raindrops nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.raindrops note: .onion URLs require Tor: https://www.torproject.org/ code repositories for the project(s) associated with this inbox: ../../raindrops.git AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git