Date | Commit message (Collapse) |
|
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
|
|
Eric Wong <bofh@yhbt.net> wrote:
> I'll squash this in for fork+preload safety.
I forget there are multithreaded servers using this :x
------8<-----
Subject: [PATCH v3] middleware: reuse inet_diag netlink socket
No point in constantly allocating and deallocating FDs (and Ruby
IO objects) when reusing them is supported.
However, we must guard it against parallel callers since
linux_inet_diag.c::diag releases the GVL while calling
sendmsg(2) and recvmsg(2), so it's possible two Ruby threads can
end up crossing streams if the middlware is used with a
multi-threaded server.
AFAIK, Raindrops::Middleware isn't a heavily-trafficked endpoint,
so saving FDs and avoiding thread specific data is preferable
for memory-constrained systems I use.
|
|
Socket#accept and Socket#accept_nonblock return an Addrinfo
object in addition to a client socket. This allows web servers
to avoid having to make getpeername(2) syscalls to get the
same information.
|
|
Currently, all memory used by Raindrops is mapped as MAP_ANONYMOUS. This
means that although Raindrops counters can be shared between processes
that have forked from each other, it is not possible to share the
counter values with another, unrelated process.
This patch adds support for backing the Raindrops mapping with a file
descriptor obtained from an IO object. The #initialize API has been
enhanced with two new keyword options:
Raindrops.new(size, io: nil, zero: false)
If an instance of IO is provided, then the underlying file descriptor
for that IO will be used to back the memory mapping Raindrops creates.
An unrelated process can then open the same file, and read the counters;
either by mmap'ing the file itself (or using Raindrops to do so), or by
making ordinary seek()/read() calls if performance is not a concern.
Note that the provided IO object _must_ implement #truncate; this is
used to set the size of the file to be right-sized for the memory
mapping that is created.
If the zero argument is passed as true, then the mapping will be zero'd
by Raindrops as part of its initialization. If it's false, then the
Raindrops counters existing in the file will be preserved. This allows
counter values to be persisted (although note that Raindrops makes no
attempt to msync the values, so they are not durable to e.g. system
crashes).
Counter values can easily be shared between processes
in-memory only without touching the disk by passing in a File on a
tmpfs as the io object.
|
|
The expiration for bogomips.org is coming up and I'm not
keen on paying or supporting extortionists.
Not wanting to be beholden to ICANN or any powerful
organizations, .onion sites are available to Tor users:
http://raindrops.ou63pmih66umazou.onion/
http://ou63pmih66umazou.onion/raindrops.git/
http://ou63pmih66umazou.onion/raindrops-public/
(the demo is not yet available via .onion, yet, could be a bit)
|
|
Newer rubies have more warnings
|
|
Correct method definition according to Ruby documentation (https://ruby-doc.org/core-2.4.1/Object.html#method-i-respond_to-3F) is:
respond_to?(string, include_all=false) → true or false
Rack started using second argument starting from version 2:
https://github.com/rack/rack/blob/master/lib/rack/body_proxy.rb#L14
If raindrops is used in Rack 2+ applications, an exception is raised:
ArgumentError: wrong number of arguments (2 for 1)
<ROOT>/gems/raindrops-0.18.0/lib/raindrops/middleware/proxy.rb:30:in `respond_to?'
<ROOT>/gems/rack-2.0.3/lib/rack/body_proxy.rb:14:in `respond_to?'
|
|
Linux is in the 4.x and Ruby is into the 2.x range, by now,
so try to get with the times.
|
|
File#size is available in modern Rubies so the extra syscall
is avoided.
|
|
IO.copy_stream is standard in 1.9+ and can use pread when
given an offset. We do not need to use pwrite with fcntl
locking, actually.
|
|
And rely on frozen string optimizations in Ruby while we're at it.
|
|
While raindrops.bogomips.org exists, having extra subjectAltName
entries is bloating the certificate. This will make it easier
to mirror the homepage on Tor hidden services.
|
|
rack 2.0 removes this method, but we actually don't need it
since any strings we generate are binary and Aggregate#to_s
output is 7-bit clean.
|
|
The "defineclass" VM instruction takes more operands
and uses more space than "setconstant". Since we have no
methods or subclasses/constants to define under the
"Raindrops::Middleware::Stats" class,
|
|
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.
|
|
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
|
|
Since Ruby 2.2, frozen string literals are implied for Hash#[]
lookups. Constant lookups have inline caching since Ruby 1.9
(from YARV).
|
|
Existing subscribers on librelist will need to resubscribe since
there's no published subscriber lists anywhere.
The public-inbox + mlmmj setup on bogomips.org allows posting
without subscription and offers downloadable archives via git.
The lack of rsyncable archives on librelist nowadays and
subscription-required nature of librelist are points against it.
Repliers should Cc: all recipients (using the reply-all
function of their mail client) since many readers are not
subscribed.
This project has never accepted or encouraged HTML email, but
librelist accepted it. The bogomips.org mail server is
configured to treat HTML mail as spam, so do not send HTML mail
if you expect a response.
Users who wish to subscribe may send a message to:
raindrops-public+subscribe@bogomips.org
Similarly, they may unsubscribe via:
raindrops-public+unsubscribe@bogomips.org
HTTP archives are available via:
http://bogomips.org/raindrops-public/
ssoma users may also use: git://bogomips.org/raindrops-public
(see README change)
Old messages to the librelist addresses will continue to
get routed to the new mailing list.
ref: http://public-inbox.org/
|
|
Some projects may load parts of Unicorn and not others.
|
|
Relying on String#replace to set Content-Type stopped working
with rack commit 3623d04526b953a63bfb3e72de2d6920a042563f
This fixes compatibility with the Rack 1.5.x series.
|
|
When I mount Raindrops::Watcher like so:
map "/_raindrops" do
run Raindrops::Watcher.new
end
Then in the HTML output links use an absolute path instead of relative
to the path /_raindrops/
Cheers,
Lawrence
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
Rack webservers are not guaranteed to include Rack::Head in the
middleware stack. Watcher is a standalone app, so it cannot
rely on a framework which automatically includes Rack::Head.
|
|
For hosts with many listeners, it should be easier to read the
index page if the results are shown in a consistent order.
Requested privately via email to raindrops@bogomips.org
|
|
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.
|
|
"send" is more likely to be overridden in subclasses whereas
the Ruby runtime (at least 1.9.3) will warn loudly if any user
code (re)defines the "__send__" method.
For example, BasicSocket#send and UDPSocket#send in the Ruby
stdlib are wrappers for the send(2)/sendto(2) system calls,
and it's entirely possible an application could return a
Socket-subclass as a Rack response body.
|
|
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"]
|
|
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>
|
|
Noted, but not fixed in the previous commit
commit abc6dd47ede5b96ada1ff8f37dfba73cd5fd586a
(Add method_missing to Raindrops::Middleware::Proxy)
|
|
This enables it to behave more like a Rack
BodyProxy would, delegating methods to its body
object when it does not implement them itself.
(Also includes a minor grammar fix to a comment.)
[ew: minor comment/whitespace fix]
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
Signed-off-by: Aman Gupta <aman@tmm1.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
|
|
Signed-off-by: Aman Gupta <aman@tmm1.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
|
|
Math.sqrt on 1.8.7 does not give NaN for certain errors.
We'll also fix our Errno::EDOM retry loop to avoid resetting
the "retried" flag.
|
|
Just in case somebody tries to scan all addresses, we
won't run out of memory as easily.
|
|
These names are not finalized, yet.
|
|
It could be useful to know when the first and last peak time of
a maximum was.
|
|
It can be useful to some to see that info all at once
without hitting the HTML index page.
|
|
This was always supported via the HTML (browser) interface
but there was no documented way of hitting it without a
browser, before.
|
|
A non-profit TLD makes more sense for a Free Software project.
|
|
Found in the check-warnings target in pkg.mk
|
|
formatting is hard :<
|
|
I copied and pasted off the Raindrops::LastDataRecv
documentation. While the headers and mathematical meanings are
identical, they measure different things (but for the same
purpose)
Noticed-by: Troex Nevelin
|
|
No need to duplicate code
|
|
It can help navigation, we think...
|
|
No need to waste bandwidth of example.com when
we have a meaningful demo site :)
|
|
We know exactly when to invalidate based on the delay :)
|
|
Set "Cache-Control: no-transform" to prevent frontend proxies
from flushing data.
|
|
Hopefully people can learn to use the REST API
this way.
|
|
|
|
Those will cause Aggregate to raise Errno::EDOM
|
|
|