about summary refs log tree commit homepage
path: root/lib/raindrops/linux.rb
DateCommit message (Collapse)
2024-03-23treewide: future-proof frozen_string_literal changes
Once again Ruby seems ready to introduce more incompatibilities and force busywork upon maintainers[1]. In order to avoid incompatibilities in the future, I used the following Perl script to prepend `frozen_string_literal: false' to every Ruby file: use v5.12; use autodie; my $usage = 'perl /path/to/script <LIST_OF_RB_FILES>'; my $fsl = "# frozen_string_literal: false\n"; for my $f (@ARGV) { open my $fh, '<', $f; my $s = do { local $/; <$fh> } // die "read($f): $!"; next if $s =~ /^#\s*frozen_string_literal:/sm; # fsl must be after encoding: line if it exists: if ($s =~ s/^([ \t]*\#[ \t\-\*\#]+encoding:[^\n]+\n)/$1$fsl/sm # or after the shebang || $s =~ s/^(#![^\n]+\n)/$1$fsl/ # or after embedded switches in rackup files: || ($f =~ /\.ru$/ && $s =~ s/^(#\\[^\n]+\n)/$1$fsl/) # or prepend as a last resort: || (substr($s, 0, 0) = $fsl)) { open $fh, '>', $f; print $fh $s; close $fh; } } Somebody interested will have to go through every Ruby source file and enable frozen_string_literal once they've thoroughly verified it's safe to do so. [1] https://bugs.ruby-lang.org/issues/20205
2020-01-06fixes for newer rubies
Newer rubies have more warnings
2016-02-23linux: remove Pathname stdlib dependency
The File.readlink has been available since the earliest SVN import of Ruby from Jan 16 1998. There's no reason to load the Pathname class here since we don't do any further pathname manipulation. So avoid loading the extra .so here and creating extra objects.
2016-02-23linux: workaround Ruby 2.3 change
File.readlink (and thus Pathname#realpath) returns the filesystem encoding (Encoding.find "filesystem"). The filesystem encoding defaults to the locale encoding, which tends to be UTF-8. This is true even on *nix filesystems which can have any byte besides "\0". ref: https://bugs.ruby-lang.org/issues/12034 ref: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/73593
2012-06-12unix: show zero-value stats for idle listeners
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.
2012-06-05unix_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"]
2012-06-05resolve symlinks to Unix domain sockets
Raindrops currently fails when provided a symlink to a socket. As this is a common practice for many deployment tools (Vlad, etc.) this patch adds support for finding the realpath prior to looking the socket up in /proc/net/unix [ew: commit message subject] [ew: fixed test to pass under 1.9.3 and 1.8.7: * Tempfile#unlink is unsafe to call if we want to reuse the path, use File.unlink(tmp.path) instead * The return value of File.symlink is zero (or it raises), so it's unusable. * File.symlink will not call #to_path under 1.8.7, so it's necessary to pass pathnames to it, not Tempfile objects. ] Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-01-07fix ListenStats documentation error in Raindrops::Linux.unix_listener_stats
Signed-off-by: Aman Gupta <aman@tmm1.net> Acked-by: Eric Wong <normalperson@yhbt.net>
2011-03-14linux: avoid Array#first/Array#last
More confusing for me, actually...
2011-03-14linux: unix_listener_stats may scan all paths
This matches behavior of the TCP version.
2011-03-11doc: more rdoc updates for Linux users
Yes we love Linux more than other systems :>
2011-03-10rdoc: 100% documentation coverage!
Of course, RDoc doesn't know quantity vs quality :)
2011-02-28doc: mention tcp_diag/inet_diag for old kernels
People actually need to load modules manually on older kernels :<
2011-02-15unindent modules
No need to clutter/confuse namespace lookups
2010-04-08linux: slightly simpler scan for /proc/net/unix
File.read under 1.9 takes an :encoding argument to force binary encoding for its return value.
2010-04-07initial