From bd7236fe23c4388d2fa42a4f836aca3c796dabab Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 5 Jun 2012 17:49:43 -0700 Subject: unix_listener_stats follows and remembers symlinks Teach unix_listener_stats to remember the symlink path it followed and have it point to the same object as the resolved (real) socket path. This allows the case where looking up stats by symlinks works if the symlink is given to unix_listener_stats: File.symlink("/real/path/of.sock", "/path/to/link.sock") stats = unix_listener_stats(["/path/to/link.sock"]) stats["/path/to/link.sock"] => # same as stats["/real/path/of.sock"] --- lib/raindrops/linux.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/raindrops/linux.rb') diff --git a/lib/raindrops/linux.rb b/lib/raindrops/linux.rb index a198253..1752b8a 100644 --- a/lib/raindrops/linux.rb +++ b/lib/raindrops/linux.rb @@ -43,9 +43,14 @@ module Raindrops::Linux else paths = paths.map do |path| path = path.dup - path = Pathname.new(path).realpath.to_s path.force_encoding(Encoding::BINARY) if defined?(Encoding) - rv[path] + if File.symlink?(path) + link = path + path = Pathname.new(link).realpath.to_s + rv[link] = rv[path] # vivify ListenerStats + else + rv[path] # vivify ListenerStats + end Regexp.escape(path) end end -- cgit v1.2.3-24-ge0c7