about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-03-25 16:32:58 -0700
committerEric Wong <normalperson@yhbt.net>2009-03-25 16:32:58 -0700
commit63209531722311896ac448d9170adb0766fa3eff (patch)
treefd8aa66b87ac9e14de855562f9998887032a5420
parent1bf10b3a73509f3fc72fb7f267e767c0e2fa9376 (diff)
parent9c338507225446cb5c477a91c5e5da0bfe305949 (diff)
downloadunicorn-63209531722311896ac448d9170adb0766fa3eff.tar.gz
* commit 'v0.2.3':
  unicorn 0.2.3
  Ensure Tempfiles are unlinked after every request
  Don't bother unlinking UNIX sockets

Conflicts:
	lib/unicorn/socket.rb
-rw-r--r--CHANGELOG1
-rw-r--r--lib/unicorn/const.rb2
-rw-r--r--lib/unicorn/http_request.rb1
-rw-r--r--test/unit/test_upload.rb26
4 files changed, 29 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index eb16ceb..c4d1289 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,4 @@
+v0.2.3 - Unlink Tempfiles after use (they were closed, just not unlinked)
 v0.2.2 - small bug fixes, fix Rack multi-value headers (Set-Cookie:)
 v0.2.1 - Fix broken Manifest that cause unicorn_rails to not be bundled
 v0.2.0 - unicorn_rails launcher script.
diff --git a/lib/unicorn/const.rb b/lib/unicorn/const.rb
index f3dabec..4e78171 100644
--- a/lib/unicorn/const.rb
+++ b/lib/unicorn/const.rb
@@ -61,7 +61,7 @@ module Unicorn
     REQUEST_URI='REQUEST_URI'.freeze
     REQUEST_PATH='REQUEST_PATH'.freeze
     
-    UNICORN_VERSION="0.2.2".freeze
+    UNICORN_VERSION="0.2.3".freeze
 
     UNICORN_TMP_BASE="unicorn".freeze
 
diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb
index 04386fc..7106f62 100644
--- a/lib/unicorn/http_request.rb
+++ b/lib/unicorn/http_request.rb
@@ -39,6 +39,7 @@ module Unicorn
       @parser.reset
       @params.clear
       @body.close rescue nil
+      @body.close! rescue nil
       @body = nil
     end
 
diff --git a/test/unit/test_upload.rb b/test/unit/test_upload.rb
index 41fc473..8246f65 100644
--- a/test/unit/test_upload.rb
+++ b/test/unit/test_upload.rb
@@ -50,6 +50,32 @@ class UploadTest < Test::Unit::TestCase
     assert_equal @sha1.hexdigest, resp[:sha1]
   end
 
+  def test_tempfile_unlinked
+    spew_path = lambda do |env|
+      if orig = env['HTTP_X_OLD_PATH']
+        assert orig != env['rack.input'].path
+      end
+      assert_equal length, env['rack.input'].size
+      [ 200, @hdr.merge('X-Tempfile-Path' => env['rack.input'].path), [] ]
+    end
+    start_server(spew_path)
+    sock = TCPSocket.new(@addr, @port)
+    sock.syswrite("PUT / HTTP/1.0\r\nContent-Length: #{length}\r\n\r\n")
+    @count.times { sock.syswrite(' ' * @bs) }
+    path = sock.read[/^X-Tempfile-Path: (\S+)/, 1]
+    sock.close
+
+    # send another request to ensure we hit the next request
+    sock = TCPSocket.new(@addr, @port)
+    sock.syswrite("PUT / HTTP/1.0\r\nX-Old-Path: #{path}\r\n" \
+                  "Content-Length: #{length}\r\n\r\n")
+    @count.times { sock.syswrite(' ' * @bs) }
+    path2 = sock.read[/^X-Tempfile-Path: (\S+)/, 1]
+    sock.close
+    assert path != path2
+
+    assert ! File.exist?(path)
+  end
 
   def test_put_keepalive_truncates_small_overwrite
     start_server(@sha1_app)