Files | Admin

Notes:

Release Name: 2.0.0pre1

Notes:
Unicorn is an HTTP server for Rack applications designed to only serve
fast clients on low-latency, high-bandwidth connections and take
advantage of features in Unix/Unix-like kernels.  Slow clients should
only be served by placing a reverse proxy capable of fully buffering
both the the request and response in between Unicorn and slow clients.

* http://unicorn.bogomips.org/
* mongrel-unicorn@rubyforge.org
* git://git.bogomips.org/unicorn.git

Changes:

Mostly internal cleanups for future versions of Rainbows! and
people trying out Rubinius.  There are tiny performance
improvements for Ruby 1.9.2 users which may only be noticeable
with Rainbows!.

There is a new dependency on the "kgio" library for kinder,
gentler I/O :)  Please report any bugs and portability issues
with kgio to the Unicorn mailing list[1].

Unicorn 1.1.x users are NOT required nor even encouraged to
upgrade yet.  Unicorn 1.1.x will be maintained for the
forseeable future.

[1] - mongrel-unicorn@rubyforge.org



Changes: GIT-VERSION-GEN | 2 +- GNUmakefile | 17 +- Rakefile | 37 +- TODO | 7 + bin/unicorn | 22 +- bin/unicorn_rails | 26 +- ext/unicorn_http/global_variables.h | 4 +- ext/unicorn_http/unicorn_http.rl | 21 +- lib/unicorn.rb | 889 ++------------------- lib/unicorn/app/exec_cgi.rb | 4 +- lib/unicorn/configurator.rb | 27 +- lib/unicorn/const.rb | 51 +- lib/unicorn/http_request.rb | 121 ++-- lib/unicorn/http_response.rb | 50 +- lib/unicorn/http_server.rb | 700 ++++++++++++++++ lib/unicorn/launcher.rb | 7 +- lib/unicorn/socket_helper.rb | 8 +- lib/unicorn/tee_input.rb | 44 +- lib/unicorn/tmpio.rb | 29 + lib/unicorn/util.rb | 136 ++-- lib/unicorn/worker.rb | 40 + local.mk.sample | 9 - script/isolate_for_tests | 43 + t/GNUmakefile | 9 +- t/t0003-working_directory.sh | 5 - t/t0010-reap-logging.sh | 55 ++ t/t0303-rails3-alt-working_directory_config.ru.sh | 5 - t/test-rails3.sh | 2 +- test/exec/test_exec.rb | 2 +- test/unit/test_http_parser_ng.rb | 11 + test/unit/test_request.rb | 12 + test/unit/test_response.rb | 23 +- test/unit/test_signals.rb | 2 +- test/unit/test_tee_input.rb | 40 +- unicorn.gemspec | 3 +- 35 files changed, 1269 insertions(+), 1194 deletions(-) commit cb48b1bc7231db7f53bec6e88e696dc53153750d Author: Eric Wong Date: Wed Oct 6 01:08:36 2010 +0000 unicorn 2.0.0pre1 - a boring "major" release Mostly internal cleanups for future versions of Rainbows! and people trying out Rubinius. There are tiny performance improvements for Ruby 1.9.2 users which may only be noticeable with Rainbows! Unicorn 1.1.x users are NOT required to upgrade. commit 4c59a4861bf3f8d25335696c1f8cbce3cd5db902 Author: Eric Wong Date: Wed Oct 6 01:07:49 2010 +0000 gemspec: depend on newer isolate We use the latest and greatest whenever possible. commit cb233696be73873f6f8c367f4b977ade1815b265 Author: Eric Wong Date: Tue Oct 5 23:59:45 2010 +0000 various cleanups and reduce indentation This also affects some constant scoping rules, but hopefully makes things easier to follow. Accessing ivars (not via accessor methods) are also slightly faster, so use them in the criticial process_client code path. commit d4c898a4adc6cb6c3a20a648ae6b9b6a226066a6 Author: Eric Wong Date: Tue Oct 5 23:34:39 2010 +0000 upgrade to kgio 1.2.0 This provides the kgio_read! method which is like readpartial, only significantly cheaper when a client disconnects on us. commit 80f9987581014d694b8eb67bba0d5c408b7d0f98 Author: Eric Wong Date: Tue Oct 5 23:34:19 2010 +0000 GNUmakefile: fix isolate invocation again :x commit fd6b47cf1690cb45f2144cd92e0fe1f301c7c37b Author: Eric Wong Date: Tue Oct 5 22:09:20 2010 +0000 tee_input: use kgio to avoid stack traces on EOF TeeInput methods may be invoked deep in the stack, so avoid giving them more work to do if a client disconnects due to a bad upload. commit 350e8fa3a94838bcc936782315b3472615fe6517 Author: Eric Wong Date: Tue Oct 5 22:01:19 2010 +0000 http: raise empty backtrace for HttpParserError It's expensive to generate a backtrace and this exception is only triggered by bad clients. So make it harder for them to DoS us by sending bad requests. commit c2975b85b9378797631d3ab133cac371f9fadf54 Author: Eric Wong Date: Tue Oct 5 21:38:47 2010 +0000 tests: do not invoke isolate in test install dest We don't want to waste time and bandwidth. commit ec1315c9e9175d755dfd7b4acb8398fa7c7a924e Author: Eric Wong Date: Tue Oct 5 21:29:51 2010 +0000 test_tee_input: use a socketpair() It's a much closer representation of what we'd expect in the real server than a mono-directional UNIX pipe. commit c639eef6b9c8d793c7f72fa5ac03adb5cf4d1e14 Author: Eric Wong Date: Tue Oct 5 19:22:09 2010 +0000 test_signals: enable test under Rubinius The bugs from signal handling were fixed in the Rubinius 1.1.0 release. commit 72dee9e4a8234af762b058a38132268d202c17bf Author: Eric Wong Date: Tue Oct 5 19:20:39 2010 +0000 tmpio: use super instead of an explicit method This is for compatibility with Ruby implementations such as Rubinius that use "IO.new" internally inside "IO.open" commit 7ca92025ececb4b71ec4420e03d5725f13c39cc4 Author: Eric Wong Date: Tue Oct 5 18:48:53 2010 +0000 update comment about non-blocking accept() Thanks to kgio, we no longer use accept_nonblock. commit fc820598da30509269ec84eeca598085ca296e38 Author: Eric Wong Date: Tue Oct 5 08:00:34 2010 +0000 util: uindent use less ambiguous constant scoping This hopefully makes things easier to read and follow. commit 3d147e9bcd8f99c94900a00181692c2a09c3c3c9 Author: Eric Wong Date: Tue Oct 5 07:54:13 2010 +0000 Unicorn::Util.tmpio => Unicorn::TmpIO.new This is slightly shorter and hopefully easier to find. commit e184b9d0fb45b31d80645475e22f0bbbecd195f9 Author: Eric Wong Date: Tue Oct 5 01:27:00 2010 +0000 doc: update TODO This gives us some things to think about. commit 29946368c45dce5da116adb426362ee93c507c4e Author: Eric Wong Date: Tue Oct 5 00:13:02 2010 +0000 start using kgio, the kinder, gentler I/O library This should hopefully make the non-blocking accept() situation more tolerable under Ruby 1.9.2. commit 9ef6b6f551a34922cfd831e2521495e89afe2f94 Author: Eric Wong Date: Mon Oct 4 23:55:31 2010 +0000 split out isolate usage/logic We'll be using more of Isolate in development. commit 018a9deff4bd9273e053f369d746256e5b3ac99b Author: Eric Wong Date: Mon Oct 4 21:06:41 2010 +0000 http_request: reformat and small reorg This hides more HTTP request logic inside our object. commit dfc5f5a5e4aec4578b79de68c91906da75472a5a Author: Eric Wong Date: Wed Sep 29 23:57:57 2010 -0700 tee_input: update interface to use HttpRequest This should ensure we have less typing to do. commit fe94d80cb37ee441762ad2a8f5c25092f8eb57a8 Author: Eric Wong Date: Mon Sep 27 22:39:02 2010 -0700 http_request: avoid globals Rainbows! will be able to reuse this. commit 5b6a97ff54d029d433b79eee1549e6f99464c48b Author: Eric Wong Date: Fri Aug 27 21:45:33 2010 +0000 split out worker to a separate file This hopefully makes things easier to read, follow, and find since it's mostly documentation... commit 50c11036dd4898ccfed8b3e0552e88c67b6c63a9 Author: Eric Wong Date: Fri Aug 27 20:29:55 2010 +0000 http_response: avoid singleton method There's no need for a response class or object since Rack just uses an array as the response. So use a procedural style which allows for easier understanding. We shall also support keepalive/pipelining in the future, too. commit 7a3efe8a03f85c1f2957130986c24ef7931ff44a Merge: 1a2363b 6151686 Author: Eric Wong Date: Mon Oct 4 20:34:29 2010 +0000 Merge commit 'v1.1.4' * commit 'v1.1.4': unicorn 1.1.4 - small bug fix and doc updates update Rails 3 tests to use Rails 3 final avoid unlinking actively listening sockets doc: update HACKING for documentation contributions doc: update Sandbox document for Bundler TUNING: more on socket buffer sizes commit 1a2363b17b1d06be6b35d347ebcaed6a0c940200 Author: Eric Wong Date: Mon Oct 4 04:17:31 2010 +0000 avoid unlinking actively listening sockets While we've always unlinked dead sockets from nuked/leftover processes, blindly unlinking them can cause unnecessary failures when an active process is already listening on them. We now make a simple connect(2) check to ensure the socket is not in use before unlinking it. Thanks to Jordan Ritter for the detailed bug report leading to this fix. ref: http://mid.gmane.org/8D95A44B-A098-43BE-B532-7D74BD957F31@darkridge.com commit 505a9e72d320fe3ae521ceb0f381c1c0f5ae4389 Author: Eric Wong Date: Wed Sep 15 14:57:27 2010 -0700 doc: update HACKING for documentation contributions We switched to RDoc 2.5.x long ago and this should clarify some documentation preferences I have. commit 1a75966a5d1a1f6307ed3386e2f91a28bbb72ca0 Author: Eric Wong Date: Wed Sep 15 14:42:54 2010 -0700 doc: update Sandbox document for Bundler Thanks to Lawrence Pit, Jamie Wilkinson, and Eirik Dentz Sinclair. ref: mid.gmane.org/4C8986DA.7090603@gmail.com ref: mid.gmane.org/5F1A02DB-CBDA-4302-9E26-8050C2D72433@efficiency20.com commit f9a7a19a361fd674bab4e2df7e0897015528bba7 Author: Eric Wong Date: Mon Aug 30 23:25:59 2010 -0700 TUNING: more on socket buffer sizes Large buffers can hurt as well as help. And the difference in real apps that do a lot of things other than I/O often makes it not worth it. commit da272fc48ffaa808456fe94dd7a3e01bc9799832 Author: Eric Wong Date: Mon Aug 30 08:11:44 2010 +0000 update Rails 3 tests to use Rails 3 final Rails 3 is out, and requires no code changes on our end to work (as far as our tests show :) commit 0aaa0afa49a2953b7c26c1596a284621e23d5fc4 Author: Eric Wong Date: Mon Aug 30 07:59:01 2010 +0000 remove nasty ugly hacks at startup These nasty hacks were breaking Rubinius compatibility. This can be further cleaned up, too. commit f3e1653b900596e054297675becd01d9985ad482 Merge: feab35f d634b06 Author: Eric Wong Date: Sun Aug 29 23:38:13 2010 +0000 Merge branch '1.1.x-stable' * 1.1.x-stable: unicorn 1.1.3 - small bug fixes make log reopens even more robust in threaded apps update Rails3 tests to use 3.0.0rc2 make log reopens more robust in multithreaded apps bin/*: more consistent --help output SIGTTIN works after SIGWINCH commit feab35fe531843066db3418598874cf9f9419614 Author: Eric Wong Date: Sat Aug 28 18:52:48 2010 +0000 make log reopens even more robust in threaded apps A follow-up to 4b23693b9082a84433a9e6c1f358b58420176b27 If multithreaded programming can be compared to juggling chainsaws, then multithreaded programming with signal handlers in play is akin to juggling chainsaws on a tightrope over shark-infested waters. commit 18968f6aff2fa5ba5a7e3e3d47c9cc05cd6c260d Author: Eric Wong Date: Sat Aug 28 07:07:14 2010 +0000 update Rails3 tests to use 3.0.0rc2 No code changes needed, thankfully. commit 4b23693b9082a84433a9e6c1f358b58420176b27 Author: Eric Wong Date: Sat Aug 28 05:30:46 2010 +0000 make log reopens more robust in multithreaded apps IOError may occur due to race conditions as another thread may close the file immediately after we call File#closed? to check. Errno::EBADF may occur in some applications that close a file descriptor without notifying Ruby (or if two IO objects refer to the same descriptor, possibly one of them using IO#for_fd). commit 096afc1a8e958cc09b4ce8b3bfe76ce056c7ed69 Author: Eric Wong Date: Tue Aug 24 06:21:00 2010 +0000 bin/*: more consistent --help output This fixes a long-standing bug in the output of "unicorn_rails" where the program name was missing. commit bdc79712e5ac53d39c51e80dfe50aff950e5053f Author: Eric Wong Date: Sat Aug 7 03:27:50 2010 +0000 miscellaneous loop and begin cleanups These are minor changes to remove unnecessary loop nesting and begin usage to reduce our code size and hopefully simplify flow for readers. commit e4d0b226391948ef433f1d0135814315e4c48535 Author: Eric Wong Date: Sat Aug 7 04:25:51 2010 +0000 log ERROR messages if workers exit with failure Something is wrong if workers exit with a non-zero status, so we'll increase the log level to help prevent people from missing it. commit f1d33c80dd6c5650f960f7087f4e08f809754d34 Author: Eric Wong Date: Fri Jul 16 08:25:32 2010 +0000 SIGTTIN works after SIGWINCH In addition to SIGHUP, it should be possible to gradually bring workers back up (to avoid overloading the machine) when rolling back upgrades after SIGWINCH. Noticed-by: Lawrence Pit ref: http://mid.gmane.org/4C3F8C9F.2090903@gmail.com commit 78ba3899eb24d6893e34984b9f1c479c7e6c9be3 Merge: c13bec3 d1818d2 Author: Eric Wong Date: Tue Jul 13 13:04:53 2010 -0700 Merge branch '1.1.x-stable' * 1.1.x-stable: (27 commits) unicorn 1.1.2 - fixing upgrade rollbacks unicorn 1.0.1 - bugfixes only SIGHUP deals w/ dual master pid path scenario launcher: do not re-daemonize when USR2 upgrading SIGHUP deals w/ dual master pid path scenario launcher: do not re-daemonize when USR2 upgrading unicorn 1.1.1 - fixing cleanups gone bad :x tee_input: fix constant resolution for client EOF unicorn 1.1.0 - small changes and cleanups cleanup "stringio" require tee_input: safer record separator ($/) handling prefer "[]" to "first"/"last" where possible tee_input: safer record separator ($/) handling socket_helper: disable documentation socket_helper: cleanup FreeBSD accf_* detection socket_helper: no reason to check for logger method configurator: cleanup RDoc, un-indent configurator: documentation for new accept options socket_helper: move defaults to the DEFAULTS constant doc: recommend absolute paths for -c/--config-file ... commit c13bec3449396b21795966101367838161612d61 Author: Eric Wong Date: Tue Jul 13 08:57:37 2010 +0000 SIGHUP deals w/ dual master pid path scenario As described in our SIGNALS documentation, sending SIGHUP to the old master (to respawn SIGWINCH-ed children) while the new master (spawned from SIGUSR2) is active is useful for backing out of an upgrade before sending SIGQUIT to the new master. Unfortunately, the SIGHUP signal to the old master will cause the ".oldbin" pid file to be reset to the non-".oldbin" version and thus attempt to clobber the pid file in use by the to-be-terminated new master process. Thanks to the previous commit to prevent redaemonization in the new master, the old master can reliably detect if the new master is active while it is reloading the config file. Thanks to Lawrence Pit for discovering this bug. ref: http://mid.gmane.org/4C3BEACF.7040301@gmail.com commit 3f0f9d6d72cf17b34c130b86eb933bbc513b24b3 Author: Eric Wong Date: Tue Jul 13 08:53:48 2010 +0000 launcher: do not re-daemonize when USR2 upgrading This was accidentally enabled when ready_pipe was developed. While re-daemonizing appears harmless in most cases this makes detecting backed-out upgrades from the original master process impossible. commit ac15513bb81a345cd12c67702a81a585b8b0514e Author: Eric Wong Date: Sun Jul 11 02:05:01 2010 +0000 tee_input: fix constant resolution for client EOF Noticed while hacking on a Zbatery-using application commit 0fea004ab093ec4f59d919915a505a136326bd8a Author: Eric Wong Date: Thu Jul 8 05:54:25 2010 +0000 cleanup "stringio" require "stringio" is part of the Ruby distro and we use it in multiple places, so avoid re-requiring it. commit 5ece8c1c33f10e6496dfe5ae1d0d368293278d2d Author: Eric Wong Date: Thu Jul 8 05:33:49 2010 +0000 prefer "[]" to "first"/"last" where possible "[]" is slightly faster under Ruby 1.9 (but slightly slower under 1.8). commit 1cd698f8c7938b1f19e9ba091708cb4515187939 Author: Eric Wong Date: Thu Jul 8 05:14:55 2010 +0000 tee_input: safer record separator ($/) handling Different threads may change $/ during execution, so cache it at function entry to a local variable for safety. $/ may also be of a non-binary encoding, so rely on Rack::Utils.bytesize to portably capture the correct size. Our string slicing is always safe from 1.9 encoding: both our socket and backing temporary file are opened in binary mode, so we'll always be dealing with binary strings in this class (in accordance to the Rack spec). commit 98c51edf8b6f031a655a93b52808c9f9b78fb6fa Author: Eric Wong Date: Tue Jul 6 14:17:02 2010 -0700 socket_helper: disable documentation for internals commit 2b4b15cf513f66dc7a5aabaae4491c17895c288c Author: Eric Wong Date: Tue Jul 6 12:59:45 2010 -0700 socket_helper: cleanup FreeBSD accf_* detection Instead of detecting at startup if filters may be used, just try anyways and log the error. It is better to ask for forgiveness than permission :) commit e0ea1e1548a807d152c0ffc175915e98addfe1f2 Author: Eric Wong Date: Tue Jul 6 12:51:24 2010 -0700 socket_helper: no reason to check for logger method We only use this module in HttpServer and our unit test mocks it properly. commit e4d2c7c302e96ee504d82376885ac6b1897c666a Author: Eric Wong Date: Tue Jul 6 12:49:48 2010 -0700 configurator: cleanup RDoc, un-indent No point in redeclaring the Unicorn module in here. commit 686281a90a9b47bac4dfd32a72a97e6e8d26afa1 Author: Eric Wong Date: Tue Jul 6 12:39:36 2010 -0700 configurator: documentation for new accept options The defaults should be reasonable, but there may be folks who want to experiment. commit ef8f888ba1bacc759156f7336d39ba9b947e3f9d Author: Eric Wong Date: Tue Jul 6 12:35:45 2010 -0700 socket_helper: move defaults to the DEFAULTS constant This is to allow Rainbows! to override the defaults. commit d7695c25c5e3b1c90e63bf15a5c5fdf68bfd0c34 Author: Eric Wong Date: Mon Jul 5 23:14:40 2010 +0000 doc: recommend absolute paths for -c/--config-file Suggested-by: Jeremy Evans ref: http://mid.gmane.org/AANLkTintT4vHGEdueuG45_RwJqFCToHi5pm2-WKDSUMz@mail.gmail.com commit 646cc762cc9297510102fc094f3af8a5a9e296c7 Author: Eric Wong Date: Sat Jul 3 09:30:57 2010 +0000 socket_helper: tunables for tcp_defer_accept/accept_filter Under Linux, this allows users to tune the time (in seconds) to defer connections before allowing them to be accepted. The behavior of TCP_DEFER_ACCEPT changed with Linux 2.6.32 and idle connections may still be accept()-ed after the specified value in seconds. A small value of '1' remains the default for Unicorn as Unicorn does not worry about slow clients. Higher values provide better DoS protection for Rainbows! but also increases kernel memory usage. Allowing "dataready" for FreeBSD accept filters will allow SSL sockets to be used in the future for HTTPS, too. commit 5769f313793ca84100f089b1911f2e22d0a31e9d Author: Eric Wong Date: Mon Jun 28 04:45:16 2010 +0000 http_response: this should be a module, not a class This affects Rainbows!, but Rainbows! is still using the Unicorn 1.x branch. While we're at it, avoid redeclaring the "Unicorn" module, it makes documentation noisier. commit cf63db66bca9acfd3416ab8fc8a7fd4f07927342 Author: Eric Wong Date: Fri Jun 25 11:29:13 2010 -0700 test-exec: prefer ENV['PWD'] in working_directory tests We do an extra check in the application dispatch to ensure ENV['PWD'] is set correctly to match Dir.pwd (even if the string path is different) as this is required for Capistrano deployments. These tests should now pass under OSX where /var is apparently a symlink to /private/var. commit e2503a78150f4be113ee2a19404ba6aec401c696 Author: Eric Wong Date: Thu Jun 24 05:47:27 2010 +0000 const: bump UNICORN_VERSION to 2.0.0pre commit b8b979d75519be1c84818f32b83d85f8ec5f6072 Author: Eric Wong Date: Thu Jun 24 04:31:37 2010 +0000 http: avoid (re-)declaring the Unicorn module It makes for messy documentation. commit 6f720afd95d8131a2657c643b97cb18c750ed9f8 Author: Eric Wong Date: Thu Jun 24 04:24:34 2010 +0000 tee_input: undent, avoid (re)-declaring "module Unicorn" It makes RDoc look better and cleaner, since we don't do anything in the Unicorn namespace. commit 9f48be69bfe579dab02b5fe8d6e728ae63fd24fc Author: Eric Wong Date: Thu Jun 24 04:11:35 2010 +0000 tee_input: allow tuning of client_body_buffer_size/io_size Some folks may require more fine-grained control of buffering and I/O chunk sizes, so we'll support them (unofficially, for now). commit 1a49a8295054a2e931f5288540acb858be8edcc8 Author: Eric Wong Date: Thu Jun 24 03:54:40 2010 +0000 tee_input: (nitpick) use IO#rewind instead of IO#seek(0) no need to pass an extra argument