about summary refs log tree commit homepage
path: root/lib/raindrops/middleware.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
2024-01-15middleware: reuse inet_diag netlink socket
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.
2020-01-06replace bogomips.org with yhbt.net
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)
2016-07-29use HTTPS and move homepage to https://bogomips.org/raindrops/
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.
2016-02-24middleware: minor bytecode size reduction
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,
2016-02-02remove optimizations which made sense for older rubies
Since Ruby 2.2, frozen string literals are implied for Hash#[] lookups. Constant lookups have inline caching since Ruby 1.9 (from YARV).
2012-01-07avoid calling tcp_listener_stats when it is not available
Signed-off-by: Aman Gupta <aman@tmm1.net> Acked-by: Eric Wong <normalperson@yhbt.net>
2011-03-17rdoc: document the demo URLs
2011-03-10rdoc: 100% documentation coverage!
Of course, RDoc doesn't know quantity vs quality :)
2011-03-08preliminary Rack app to track last_data_recv
Seems to basically work
2011-02-26middleware: split out proxy class
It's easier to find this way.
2011-02-26middleware: avoid double decrement when reading stats
Oops!
2011-02-25proxy +to_path+ calls in the response body
We need to do this for apps that depend on things like the sendfile() optimizations in Rainbows!
2011-02-15middleware: add ipv6 address detection for Unicorn
Since Unicorn and Rainbows! support IPv6 now, it makes sense to support the rfc2732-style addresses it returns.
2011-02-15middleware: switch to ivars
These are slightly faster than regular method dispatch
2011-02-15middleware: avoid capturing block variable
It's a needless allocation
2011-02-15unindent modules
No need to clutter/confuse namespace lookups
2010-05-04cleanup a few typos
2010-05-04middleware: no need to ensure in #close
If stats.decr_writing never fails, really (or something is seriously wrong (like memory corruption) and the ensure block wouldn't fire anyways).
2010-05-04use Unicorn.listener_names method if available
This allows easier configuration when used with Unicorn and derived servers (Rainbows! and Zbatery).
2010-04-07initial