about summary refs log tree commit homepage
path: root/lib
DateCommit message (Collapse)
2010-04-19unicorn 0.97.1 - fix HTTP parser for Rainbows!/Zbatery v0.97.1
This release fixes a denial-of-service vector for derived servers exposed directly to untrusted clients. This bug does not affect most Unicorn deployments as Unicorn is only supported with trusted clients (such as nginx) on a LAN. nginx is known to reject clients that send invalid Content-Length headers, so any deployments on a trusted LAN and/or behind nginx are safe. Servers affected by this bug include (but are not limited to) Rainbows! and Zbatery. This bug does not affect Thin nor Mongrel, as neither got the request body filtering treatment that the Unicorn HTTP parser got in August 2009. The bug fixed in this release could result in a denial-of-service as it would trigger a process-wide assertion instead of raising an exception. For servers such as Rainbows!/Zbatery that serve multiple clients per worker process, this could abort all clients connected to the particular worker process that hit the assertion.
2010-03-01unicorn 0.97.0 - polishing and cleaning up v0.97.0
A bunch of small fixes related to startup/configuration and hot reload issues with HUP: * Variables in the user-generated config.ru files no longer risk clobbering variables used in laucher scripts. * signal handlers are initialized before the pid file is dropped, so over-eager firing of init scripts won't mysteriously nuke a process. * SIGHUP will return app to original state if an updated config.ru fails to load due to {Syntax,Load}Error. * unicorn_rails should be Rails 3 compatible out-of-the-box ('unicorn' works as always, and is recommended for Rails 3) * unicorn_rails is finally "working_directory"-aware when generating default temporary paths and pid file * config.ru encoding is the application's default in 1.9, not forced to binary like many parts of Unicorn. * configurator learned to handle the "user" directive outside of after_fork hook (which will always remain supported). There are also various internal cleanups and possible speedups.
2010-03-01load the Etc module up front
It's part of the standard Ruby library and will always be loaded by various modules (Rack::Utils, Tmpdir) so there's no point in deferring it.
2010-03-01configurator "user" directive outside of after_fork
Allowing the "user" directive outside of after_fork reduces the cognitive overhead for folks that do not need the complexity of *_fork hooks. Using Worker#user remains supported as it offers fine-grained control of user switching.
2010-02-28respect user's encoding in config.ru in 1.9
Do not assume the user wants config.ru to be Encoding::BINARY for 1.9.
2010-02-28put switch parsing for config.ru into Unicorn.builder
This lets us reuse code for Zbatery and Rainbows!, too.
2010-02-27tee_input: do not #dup string buffers
It's a waste of memory bandwidth to do memcpy() when we know Unicorn::HttpParser (via rb_str_resize()) will allocate new memory for the string for us. An empty String is "free", as we've already paid the Object cost regardless.
2010-02-26tee_input: avoid instance variables, it's a struct
We'll use struct members exclusively from now on instead of throwing ivars into the mix. This allows us to _unofficially_ support direct access to more members easily. Unofficial extensions may include the ability to splice(2)/tee(2) for better performance. This also makes our object size smaller across all Ruby implementations as well, too (helps Rainbows! out).
2010-02-25unicorn_rails: make this "working_directory"-aware
The temporary paths we create to mimic script/server-emulation did not work when working_directory was used. Now we defer path creation until after working_directory is bound.
2010-02-22util: simplify chown_logs
no point in using "next" here
2010-02-22avoid needlessly preallocating read buffer
Copy-on-write will always invalidate it regardless, and the first request is likely to be slow for any app.
2010-02-18Unicorn::builder to wrap our Rack::Builder usage
This should make it easier to reuse code in derivative servers like Rainbows! and Zbatery. Unfortunately, we can't depend on Rack::Builder/Rack::Server yet since Rack 1.1 just got them and notable frameworks (like Rails 2.3.x) do not fully work with Rack 1.1 yet). This also fixes subtle issue with config.ru files that could have variables that conflict with the Unicorn-specific namespace (this bug still affects "unicorn_rails", which could use some reworking as well).
2010-02-18graceful handling of bad config.ru + HUP w/ preload_app
If preload_app is true and Unicorn is HUP-ed with a bad config.ru, then it would be possible to have Unicorn in a bad state and constantly throw 500 errors. We now detect syntax and load errors since they're likely to appear in modified Rackup files, and will restore the original app if reloading failed.
2010-02-09reorder commonly accessed HttpServer struct members
Earlier elements of a Struct (in both Ruby and C) are faster to access, so put more-often accessed elements like :app first. This does not noticeably affect most applications, but may matter to some micro benchmarks somewhere...
2010-01-19initialize signal handlers before writing pid file
This prevents trigger-happy init scripts from reading the pid file (and thus sending signals) to a not-fully initialized master process to handle them. This does NOT fix anything if other processes are sending signals prematurely without relying on the presence of the pid file. It's not possible to prevent all cases of this in one process, even in a purely C application, so we won't bother trying. We continue to always defer signal handling to the main loop anyways, and signals sent to the master process will be deferred/ignored until Unicorn::HttpServer#join is run.
2010-01-19remove unused MAX_HEADER constant
This constant hasn't been in active use in our Ruby code for ages now. All HTTP header constraints are defined in the C/Ragel HTTP parser and we have tests for them, so there's no need to repeat ourselves.
2010-01-19bump version to 0.97.0pre
There may be some large-ish internal changes for 0.97.0
2010-01-07unicorn 0.96.0 - Rack 1.1 bump v0.96.0
This release includes small changes for things allowed by Rack 1.1. It is also now easier to detect if daemonized process fails to start. Manpages received some minor updates as well. Rack 1.1 allowed us to make the following environment changes: * "rack.logger" is now set to the "logger" specified in the Unicorn config file. This defaults to a Logger instance pointing to $stderr. * "rack.version" is now at [1,1]. Unicorn remains compatible with previous Rack versions if your app depends on it. While only specified since Rack 1.1, Unicorn has always exposed "rack.input" in binary mode (and has ridiculous integration tests that go outside of Ruby to prove it!).
2010-01-07Merge branch 'rack-1.1'
* rack-1.1: http_response: disallow blank, multi-value headers local.mk.sample: use rack-1.1.0 bump "rack.version" env to [1,1] set env["rack.logger"] for applications
2010-01-05http_response: disallow blank, multi-value headers
The HeaderHash optimizations in Rack 1.1 interact badly with Rails 2.3.5 (and possibly other frameworks/apps) which set multi-value "Set-Cookie" headers without relying on the proper methods provided by Rack::Utils. While this is an issue with Rails not using properly, there may be similar apps that make this mistake and Rack::Lint does not guard against it. Rack-ML-Ref: <20100105235845.GB3377@dcvr.yhbt.net>
2009-12-29launcher: no point in sync-ing $stdin
Inspection of the MRI source reveals that IO#sync=true only appears to only apply for writes. Though it could eventually make sense to disable read buffering by setting IO#sync=true, it does not appear to happen. Of course we never read from $stdin anyways....
2009-12-29launcher: fix compatibility with other servers
Rainbows! does not yet know about ready_pipe, and will probably not know about it until Unicorn 0.97.0
2009-12-28clarify errors when listeners fail to bind
When using multiple listeners, the log messages can be potentially misleading as to which listener fails to bind: Before: INFO -- : unlinking existing socket=/tmp/unicorn.sock INFO -- : listening on addr=/tmp/unicorn.sock fd=3 unicorn/socket_helper.rb:110:in `initialize': Permission denied - bind(2) (Errno::EACCES) After: INFO -- : unlinking existing socket=/tmp/openxdms.sock INFO -- : listening on addr=/tmp/openxdms.sock fd=3 FATAL -- : error adding listener addr=0.0.0.0:84 unicorn/socket_helper.rb:110:in `initialize': Permission denied - bind(2) (Errno::EACCES)
2009-12-28launcher: descriptive error message on startup failure
Rather than erroring out with a non-descript EOFError, show a warning message telling users to check the logs instead. Reported-by: Iñaki Baz Castillo mid=200912281350.44760.ibc@aliax.net
2009-12-27Avoid leaking ready pipe file descriptor to workers
Otherwise the original spawner process may not notice the close as it's still being shared by workers. While we're at it, avoid confusing the original spawner by using readpartial instead of sysread.
2009-12-26exit with failure if master dies when daemonized
This behavior change also means our grandparent (launched from a controlling terminal or script) will wait until the master process is ready before returning. Thanks to Iñaki Baz Castillo for the initial implementations and inspiration.
2009-12-26bump "rack.version" env to [1,1]
This will match what's in Rack the 1.1.0 release.
2009-12-21unicorn 0.95.3 v0.95.3
The HTTP parser now allows (but does not parse) the userinfo component in the very rare requests that send absoluteURIs. Thanks to Scott Chacon for reporting and submitting a test case for this fix. There are also minor documentation updates and tiny cleanups.
2009-12-21tee_input: rdoc for all public methods
2009-12-14set env["rack.logger"] for applications
rack.git upstream has it, so it will likely be in Rack 1.1
2009-12-13simplify pid assignment
Durr....
2009-12-07unicorn 0.95.2 v0.95.2
Small fixes to our HTTP parser to allows semicolons in PATH_INFO as allowed by RFC 2396, section 3.3. This is low impact for existing apps as semicolons are rarely seen in URIs. Our HTTP parser runs properly under Rubinius 0.13.0 and 1.0.0-rc1 again (though not yet the rest of the server since we rely heavily on signals). Another round of small documentation tweaks and minor cleanups.
2009-12-07http_request: small cleanup/code reduction
No point in bloating code for an unlikely path (and the memcpy() vs malloc() tradeoff is debatable...)
2009-12-06http: PATH_INFO/REQUEST_PATH includes semi-colons
This is allowed according to RFC 2396, section 3.3 and matches the behavior of URI.parse, as well.
2009-11-23configurator: shorten rdoc, link to examples instead
No point in repeating ourselves and having to deal with nested comments + indentation in RDoc. It's also easier for users to just download the file than to copy-and-paste out of a typical web browser.
2009-11-21cleanup: remove needless returns
A minor nit, and some folks I know hate needless returns as MRI does not optimize them away.
2009-11-21unicorn 0.95.1 v0.95.1
Configuration files paths given on the command-line are no longer expanded. This should make configuration reloads possible when a non-absolute path is specified for --config-file and Unicorn was deployed to a symlink directories (as with Capistrano). Since deployments have always been strongly encouraged to use absolute paths in the config file, this change does not affect them. This is our first gem release using gemcutter. Eric Wong (3): SIGNALS: HUP + preload_app cannot reload app code Do not expand paths given on the shell GNUmakefile: prep release process for gemcutter
2009-11-18Do not expand paths given on the shell
Shells already expand '~' before the executables see it, and relative paths inside symlinks can get set incorrectly to the actual directory name, and not the (usually desired) symlink name for things like Capistrano. Since our paths are now unexpanded, we must now check the "working_directory" directive and raise an error if the user specifies the config file in a way that makes the config file unreloadable.
2009-11-15unicorn 0.95.0 v0.95.0
Mostly internal cleanups and documentation updates. Irrelevant stacktraces from client disconnects/errors while reading "rack.input" are now cleared to avoid unnecessary noise. If user switching in workers is used, ownership of logs is now preserved when reopening worker logs (send USR1 only to the the master in this case). The timeout config no longer affects long after_fork hooks or application startups. New features include the addition of the :umask option for the "listen" config directive and error reporting for non-portable socket options. No ponies have ever been harmed in our development. Eric Wong (28): unicorn.1: document RACK_ENV changes in 0.94.0 HACKING: update with "gmake" in examples don't nuke children for long after_fork and app loads local.mk.sample: steal some updates from Rainbows! Load Unicorn constants when building app tee_input: fix RDoc argument definition for tee Add FAQ FAQ: fix links to Configurator docs tee_input: better premature disconnect handling tee_input: don't shadow struct members raise Unicorn::ClientShutdown if client aborts in TeeInput tee_input: fix comment from an intermediate commit FAQ: additional notes on getting HTTPS redirects right configurator: update RDoc and comments in examples bump version to 0.95.0pre configurator: listen :umask parameter for UNIX sockets preserve user/group ownership when reopening logs old_rails/static: avoid freezing strings old_rails: autoload Static const: no need to freeze HTTP_EXPECT test_server: ensure stderr is written to before reading tee_input: expand client error handling replace "rescue => e" with "rescue Object => e" socket_helper: do not hide errors when setting socket options socket_helper: RDoc for constants ClientShutdown: RDoc Rakefile: add raa_update task tee_input: client_error always raises
2009-11-15tee_input: client_error always raises
We do not hide unforseen exceptions, as that could cause us to waste precious time attempting to continue processing after errors.
2009-11-15ClientShutdown: RDoc
2009-11-15socket_helper: RDoc for constants
2009-11-15socket_helper: do not hide errors when setting socket options
Since they're all optional, make them non-fatal, but make sure we log them so we can diagnose what (if anything) is going wrong.
2009-11-15replace "rescue => e" with "rescue Object => e"
"Object" is needless noise and some folks are annoyed by seeing it.
2009-11-15tee_input: expand client error handling
First move it to a separate method, this allows subclasses to reuse our error handler. Additionally, capture HttpParserError as well since backtraces are worthless when a client sends us a bad request, too.
2009-11-14const: no need to freeze HTTP_EXPECT
We never set this as a hash key, so there's no performance gain from having a frozen string.
2009-11-14old_rails: autoload Static
It makes life easier for people writing config.ru files for use with Rails.
2009-11-14old_rails/static: avoid freezing strings
No need to freeze them unless we're assigning new hash values (PATH_INFO is already hashed when we assign it).
2009-11-14preserve user/group ownership when reopening logs
This is only supported when SIGUSR1 is sent only to the master process (which then resends SIGUSR1 to the workers). Since we only added support for user/group switching in the workers, we now chown any log files upon switching users so the master can pick up and chown the log files later on. Thus we can avoid having to restart workers because they fail to rotate log files on their own.
2009-11-14configurator: listen :umask parameter for UNIX sockets
Typically UNIX domain sockets are created with more liberal file permissions than the rest of the application. By default, we create UNIX domain sockets to be readable and writable by all local users to give them the same accessibility as locally-bound TCP listeners. This only has an effect on UNIX domain sockets. This was inspired by Suraj Kurapati in cfbcd2f00911121536rd0582b8u961f7f2a8c6e546a@mail.gmail.com