about summary refs log tree commit homepage
path: root/lib/rainbows/base.rb
DateCommit message (Collapse)
2011-01-20merge rack_input into process_client
It turns out to be less-used than previous anticipated, so there's no point in having yet another module.
2011-01-06eliminate G constant and just use the Rainbows! module
Code organization is hard :<
2011-01-04globally refactor Range handling for responses
Rack::Utils::HeaderHash is still very expensive in Rack 1.2, especially for simple things that we want to run as fast as possible with minimal interference. HeaderHash is unnecessary for most requests that do not send Content-Range in responses.
2010-12-08respect "rewindable_input false" in Unicorn config
This was completely overlooked for the Rainbows 2.0.x releases.
2010-10-22code shuffling for kgio
Despite the large number of changes, most of it is code movement here.
2010-10-21unicorn 2.x updates + kgio
We get basic internal API changes from Unicorn, code simplifications coming next.
2010-09-28start using kgio library
It removes the burden of byte slicing and setting file descriptor flags. In some cases, we can remove unnecessary peeraddr calls, too.
2010-08-10doc: it's always "Rainbows!" with a bang(!)
That is the official name of the project and we will not lead people to believe differently.
2010-07-23rename parse_range => make_range!
It's a destructive method, and it does more than just parsing.
2010-07-22enable Range: responses for static files for most models
The FileStreamer class of EventMachine (and by extension NeverBlock) unfortunately doesn't handle this. It's possible to do with Revactor (since it uses Rev under the covers), but we'll support what we can easily for now.
2010-07-20rely on autoload for Base and TeeInput
Its conceivable that we can avoid loading TeeInput for EventMachine and Rev concurrency models in the future since it's unused there.
2010-07-19refactor response handling for each concurrency model
This will give each concurrency model more control over particular code paths and serving static files.
2010-07-10doc: avoid documenting internals on RDoc website
Since we suck at building websites, we just rely on RDoc as a website builder. And since Rainbows! is an application server (and not a programming library), our internal API should be of little interest to end users. Anybody interested in Rainbows! (or any other project) internals should be reading the source.
2010-07-08restore Rainbows::HttpResponse.write for Cramp
Cramp monkey patches Rainbows internals for WebSockets support and we forgot about it. Add a new integration test to ensure this continues to work in the future (and force us to update the test for newer Cramp).
2010-07-04refactor response body handling for sendfile(2)
This hopefully allows the "sendfile" gem to be required anywhere in the Rainbows!/Unicorn config file, and not have to be required via RUBYOPT or the '-r' command-line switch. We also modularize HttpResponse and avoids singleton methods in the response path. This (hopefully) makes it easier for individual concurrency models to share code and override individual methods.
2010-06-28add preliminary sendfile (1.0.0) gem support
This still needs work and lots of cleanup, but the basics are there. The sendfile 1.0.0 RubyGem is now safe to use under MRI 1.8, and is superior to current (1.9.2-preview3) versions of IO.copy_stream for static files in that it supports more platforms and doesn't truncate large files on 32-bit platforms.
2010-06-28fiber/base: reuse process_client logic in base
This fleshes out Rainbows::Fiber::IO with a few more methods for people using it.
2010-06-28(style) prefer "until" instead of "while !"
2010-06-28base: constant/namespace cleanup
2010-06-11update test infrastructure to support Rubinius
Rubinius still has a few issues that prevent 100% support, but it basically works if log rotation or USR2 upgrades aren't required. Tickets for all known issues for Rubinius have been filed on the project's issue tracker. * rbx does not support -i/-p yet, so rely on MRI for that * "io/nonblock" is missing * avoiding any optional Gems for now (EM, Rev, etc..)
2010-06-06centralize body => IO conversion logic
Since EventMachine and Rev shared the same logic for optimizing and avoiding extra file opens for IO/File-ish response bodies, so centralize that. For Ruby 1.9 users, we've also enabled this logic so ThreadPool, ThreadSpawn, WriterThreadPool, and WriterThreadSpawn can take advantage of Rainbows::DevFdResponse-generated bodies while proxying sockets.
2010-05-26add WriterThreadSpawn concurrency model
2010-05-03cleanup request size limiting for TeeInput users
WAvoid mucking with Unicorn::TeeInput, since other apps may depend on that class, so we subclass it as Rainbows::TeeInput and modify as necessary in worker processes. For Revactor, remove the special-cased Rainbows::Revactor::TeeInput class and instead emulate readpartial for Revactor sockets instead.
2010-05-03add client_max_body_size config directive
Since Rainbows! is supported when exposed directly to the Internet, administrators may want to limit the amount of data a user may upload in a single request body to prevent a denial-of-service via disk space exhaustion. This amount may be specified in bytes, the default limit being 1024*1024 bytes (1 megabyte). To override this default, a user may specify `client_max_body_size' in the Rainbows! block of their server config file: Rainbows! do client_max_body_size 10 * 1024 * 1024 end Clients that exceed the limit will get a "413 Request Entity Too Large" response if the request body is too large and the connection will close. For chunked requests, we have no choice but to interrupt during the client upload since we have no prior knowledge of the request body size.
2010-04-27base: status == 100 check needs to_i conversion
Rack allows anything as the status, as long as it returns a valid status integer on status.to_i.
2010-04-19use IO.copy_stream for Thread{Spawn,Pool} under 1.9
This should be faster for serving static files and proxying IO objects such as sockets/pipes. Unfortunately we cannot use this reliably with non-blocking frameworks since IO.copy_stream will release the GVL to block on I/O (rather than yielding a fiber or returning from a callback). Can't do HTTP/1.1 Range support, though :/
2010-03-28cleanup: avoid redundant REMOTE_ADDR logic
Every concurrency model does this the same way. This removes the Rainbows::Const::LOCALHOST constant and may break some existing apps that rely on it.
2009-12-22base: fix constant resolution under 1.8 for 1.8 bugfix
2009-12-22fix Ruby 1.8 detection for (possible) green thread fix
Thanks to Ben Sandofsky for the extra set of eyes
2009-12-21possible MRI 1.8 thread fix to avoid blocking accept()
Under MRI 1.8, listen sockets do not appear to have the nonblocking I/O flag on by default, nor does it set the nonblocking I/O flag when calling #accept (but it does when using #accept_nonblock, of course). Normally this is not a problem even when using green threads since MRI will internally select(2) on the file descriptor before attempting a blocking (and immediately successful) accept(2). However, when sharing a listen descriptor across multiple processes, spurious wakeups are likely to occur, causing multiple processes may be woken up when a single client connects. This causes a problem because accept(2)-ing on multiple threads/processes for a single connection causes blocking accepts in multiple processes, leading to stalled green threads. This is not an issue under 1.9 where a blocking accept() call unlocks the GVL to let other threads run.
2009-12-19Thread*: avoid double close of client socket
TeeInput may explicitly close on client disconnects to avoid error messages being written to the socket, likewise with "hack.io" users.
2009-12-16join_threads method is exclusive to ThreadPool
2009-12-16cleanup: consolidate write_nonblock error handling
2009-12-11env["hack.io"] for Fiber*, Revactor, Thread* models
This exposes a client IO object directly to the underlying application.
2009-12-01more consistent code for worker timeout/exits
We now correctly exit!(2) if our master can't kill us.
2009-11-30ThreadPool: no need to exit!
Just die naturally here if threads don't die on their own.
2009-11-29refactor threaded models to use blocking accept() if possible
It's a tad faster for non-keepalive connections and should do better on large SMP machines with many workers AND threads. That means the ActorSpawn model in Rubinius is nothing more than ThreadSpawn underneath (for now).
2009-11-26cleanup and refactor error handling
Make sure app errors get logged correctly, and we no longer return a 500 response when a client EOFs the write end (but not the read end) of a connection.
2009-11-18make keepalive_timeout configurable
And change the default to 2 seconds, most clients can render the page and load all URLs within 2 seconds.
2009-11-18Thread*: start implementing keepalive timeout
If the Revactor implementation using lightweight Actors/Fibers needs it, then thread implementations do, too.
2009-11-13gracefully exit workers if reopening logs fails
Permissions for the logs could've been badly set by the master. So we we'll let the master reopen them and refork children to get around this problem. We have to be more careful when reopening logs because we can reopen them in the middle of client requests (we have to) whereas Unicorn has the luxury of _knowing_ it has no active clients when it does the reopen.
2009-11-11cleanup error handling pieces
Unicorn 0.94.0 got a more generic handle_error function that's useful in the Thread* models. The Revactor one is a little different but similar to be worth refactoring to match our standard pieces.
2009-11-07remove unnecessary class variable
It's already global...
2009-11-06cleanup worker heartbeat and master deathwatch
It turns out neither the EventMachine and Rev classes checked for master death in its heartbeat mechanism. Since we managed to forget the same thing twice, we now have a test case for it and also centralized the code to remove duplication.
2009-10-26thread*: fix MRI 1.8.6 compatibility
Array#count is not available until MRI 1.8.7
2009-10-17refactor graceful shutdowns again, harder
We use the "G" global constant from the Rev model everywhere to simplify things a little. Test cases are more consistent now, too.
2009-10-17use timeout correctly to join threads on SIGQUIT
Subtraction is a difficult concept for some folks (like myself) to grasp and implement.
2009-10-17Fix graceful shutdown handling of Thread* models harder
I need better tests for graceful shutdown...
2009-10-11SIGINT/SIGTERM shuts down instantly in workers
Just like in Unicorn...
2009-10-11Fix graceful shutdowns for threaded models
They were completely broken in the refactoring :x