From c478549ea7490de2432ed31ffee37a2bfc1d24f3 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 12 Mar 2011 12:56:15 -0800 Subject: allow reusing netlink socket for inet_diag No need to waste resources on creating/destroying a socket. --- examples/linux-listener-stats.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/linux-listener-stats.rb b/examples/linux-listener-stats.rb index 5826296..70d60c6 100755 --- a/examples/linux-listener-stats.rb +++ b/examples/linux-listener-stats.rb @@ -79,6 +79,7 @@ end combined = {} tcp = nil if tcp.empty? unix = nil if unix.empty? +sock = Raindrops::InetDiagSocket.new if tcp len = 35 if len > 35 fmt = "%20s % #{len}s % 10u % 10u\n" @@ -89,7 +90,7 @@ begin combined.clear now = nil end - tcp and combined.merge! Raindrops::Linux.tcp_listener_stats(tcp) + tcp and combined.merge! Raindrops::Linux.tcp_listener_stats(tcp, sock) unix and combined.merge! Raindrops::Linux.unix_listener_stats(unix) combined.each do |addr,stats| active, queued = stats.active, stats.queued -- cgit v1.2.3-24-ge0c7