unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: Paul Sponagl <paul@sponagl.de>
Cc: mongrel-unicorn@rubyforge.org
Subject: Re: Unicorn
Date: Tue, 7 Jul 2009 13:48:39 -0700	[thread overview]
Message-ID: <20090707204839.GA2650@dcvr.yhbt.net> (raw)
In-Reply-To: <D6447D3F-F17A-4DDC-B79E-524418594095@sponagl.de>

Paul Sponagl <paul@sponagl.de> wrote:
> Hi Eric,
>
> unicorn does not close the connection on osx after sending the content.
> (It acts as the client would send a Connection: Keep-Alive)
> The connection will be aborted by nginx after about 60
> secs and the content will be send out.
>
> Macintosh:~> telnet 127.0.0.1 3001
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> GET / HTTP/1.1
>
> HTTP/1.1 200 OK
> Date: Tue, 07 Jul 2009 08:11:17 GMT
> Status: 200 OK
> Connection: close
> X-Runtime: 293
> ETag: "2659d611050f70fc65c6c052687e5a13"
> Content-Type: text/html; charset=utf-8
> Cache-Control: private, max-age=0, must-revalidate
> Content-Length: 24328
> ...
> the rest of the content

Hi Paul,

This is strange.  Can you tell that you're getting all 24328 bytes of
the content?  And no exception is thrown to stderr, either?  Unicorn
should've closed the socket even on an exception.  Which version of OSX
and Ruby are you running?  Is there anything special/weird about the
Rack response body you're sending?   Does Rack::Lint complain about
anything?  Unicorn is fairly strict about Rack::Lint compatibility.

Does the following patch help?

diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb
index bfaa33d..acf4d04 100644
--- a/lib/unicorn/http_response.rb
+++ b/lib/unicorn/http_response.rb
@@ -60,6 +60,7 @@ module Unicorn
                    "Connection: close\r\n" \
                    "#{OUT.join(Z)}\r\n")
       body.each { |chunk| socket.write(chunk) }
+      socket.flush
       socket.close # flushes and uncorks the socket immediately
       ensure
         body.respond_to?(:close) and body.close rescue nil
------------------------------------------------------------------------

Or you can replace the "socket.close" with "exit!(0)" and really
force it to close :)

Thanks again for trying this!

-- 
Eric Wong

  reply	other threads:[~2009-07-07 20:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-06  8:21 Unicorn Paul Sponagl
2009-07-06 23:16 ` Unicorn Eric Wong
2009-07-07  8:23   ` Unicorn Paul Sponagl
2009-07-07 20:48     ` Eric Wong [this message]
     [not found]       ` <CE7F2AC4-4088-44ED-A5FF-2A41FE2B61EF@sponagl.de>
     [not found]         ` <20090708220413.GA32416@dcvr.yhbt.net>
2009-07-09  8:06           ` Unicorn Paul Sponagl
2009-07-09 10:10             ` Unicorn Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090707204839.GA2650@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=mongrel-unicorn@rubyforge.org \
    --cc=paul@sponagl.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).