Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>
To: Rainbows! list <rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org>
Subject: Re: Sinatra stream(:keep_open) not holding connections open
Date: Wed, 5 Dec 2012 03:18:48 +0000	[thread overview]
Message-ID: <20121205031848.GA32757@dcvr.yhbt.net> (raw)
In-Reply-To: <CA+-9oNd1EFqsniPkkPTwu5opTCinbM7-2KHoXov7+y3LE4s4Tg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

"W. Andrew Loe III" <andrew-4trK/3dDa6Nl57MIdRCFDg@public.gmane.org> wrote:
> I've pushed a very very stripped down example that just echos the time.
> https://github.com/loe/sinatra-sse

Thanks for the test case, I've just pushed out the following fix
to "master" of git://bogomips.org/rainbows.git

I've pushed a rainbows 4.4.1.1.gd5c8c prerelease to RubyGems.org
It should be installable with: gem install --pre rainbows

I expect this to work for you, but be sure to let me know if it doesn't :x

Since this is a pretty small fix, I think I'll push 4.4.2 final
very soon.

>From d5c8cc8b51619f0d33f75036c53e3936ad2749b2 Mon Sep 17 00:00:00 2001
From: Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>
Date: Wed, 5 Dec 2012 03:08:19 +0000
Subject: [PATCH] event_machine: properly defer body.close for async

Calling body.close in the normal write_response() code path
is incorrect, and only worked out of sheer luck with
Cramp and async_sinata.

This change allows stream(:keep_open) in Sinatra to work
properly.

Thanks to W. Andrew Loe III for the informative bug report
and reproducible test case.

ref: http://mid.gmane.org/CA+-9oNd1EFqsniPkkPTwu5opTCinbM7-2KHoXov7+y3LE4s4Tg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
---
 lib/rainbows/event_machine/client.rb | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/rainbows/event_machine/client.rb b/lib/rainbows/event_machine/client.rb
index e56931f..fc0dfe3 100644
--- a/lib/rainbows/event_machine/client.rb
+++ b/lib/rainbows/event_machine/client.rb
@@ -64,8 +64,11 @@ class Rainbows::EventMachine::Client < EM::Connection
     @state = :headers if alive
     if body.respond_to?(:errback) && body.respond_to?(:callback)
       @deferred = body
+      write_headers(status, headers, alive)
+      write_body_each(body)
       deferred_errback(body)
       deferred_callback(body, alive)
+      return
     elsif body.respond_to?(:to_path)
       st = File.stat(path = body.to_path)
 
-- 
Eric Wong
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


  parent reply	other threads:[~2012-12-05  3:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-05  1:19 Sinatra stream(:keep_open) not holding connections open W. Andrew Loe III
     [not found] ` <CA+-9oNeKevgZOvKUPs-3VF7qstn8BcNw3_Py0M50h-j5-GzvOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-12-05  1:44   ` Eric Wong
     [not found]     ` <20121205014454.GA24401-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2012-12-05  2:16       ` W. Andrew Loe III
     [not found]         ` <CA+-9oNd1EFqsniPkkPTwu5opTCinbM7-2KHoXov7+y3LE4s4Tg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-12-05  3:18           ` Eric Wong [this message]
     [not found]             ` <20121205031848.GA32757-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2012-12-05  6:09               ` W. Andrew Loe III
     [not found]                 ` <CA+-9oNfR9zM4phTShBsyjweAZBBYWF5egHw7MU8gcBf3f=fAJw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-01-19  0:21                   ` W. Andrew Loe III
     [not found]                     ` <CA+-9oNdXyYrnyu3dfMuu7ULE7rhT_Rm48BCU_KaJUwsrmcj9-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-01-19  1:01                       ` W. Andrew Loe III
     [not found]                         ` <CA+-9oNedbb17X=6Eum0bOG3zEryrhnurvXui4Ye7TcRLrAFcUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-01-19  1:09                           ` 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/rainbows/

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

  git send-email \
    --in-reply-to=20121205031848.GA32757@dcvr.yhbt.net \
    --to=normalperson-rmlxzr9ms24@public.gmane.org \
    --cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org \
    /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/rainbows.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).