From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: * X-Spam-ASN: AS33070 50.56.128.0/17 X-Spam-Status: No, score=1.0 required=3.0 tests=AWL,HK_RANDOM_FROM, MSGID_FROM_MTA_HEADER,TVD_RCVD_IP shortcircuit=no autolearn=no version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.rainbows.general Subject: Re: [PATCH] close_connection_after_writing only if not deferred, as in cool.io Date: Tue, 18 Dec 2012 23:59:54 +0000 Message-ID: <20121218235954.GA14404@dcvr.yhbt.net> References: <20121218214538.GA12275@dcvr.yhbt.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1355875205 11130 80.91.229.3 (19 Dec 2012 00:00:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 19 Dec 2012 00:00:05 +0000 (UTC) To: Rainbows! list Original-X-From: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Wed Dec 19 01:00:20 2012 Return-path: Envelope-to: gclrrg-rainbows-talk@m.gmane.org X-Original-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Delivered-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-BeenThere: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.rainbows.general:425 Archived-At: Received: from 50-56-192-79.static.cloud-ips.com ([50.56.192.79] helo=rubyforge.org) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tl756-0000t5-QZ for gclrrg-rainbows-talk@m.gmane.org; Wed, 19 Dec 2012 01:00:17 +0100 Received: from localhost.localdomain (localhost [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id B50662E07C; Wed, 19 Dec 2012 00:00:03 +0000 (UTC) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by rubyforge.org (Postfix) with ESMTP id 52DF12E076 for ; Tue, 18 Dec 2012 23:59:57 +0000 (UTC) Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E4A261F42E; Tue, 18 Dec 2012 23:59:54 +0000 (UTC) "Lin Jen-Shin (godfat)" wrote: > On Wed, Dec 19, 2012 at 5:45 AM, Eric Wong wrote: > > Heh, I gave that a shot way back in the day but never got it working > > to my satisfaction. Perhaps your fix is what is needed... > > Glad to know that. Hope this time we could reach your satisfaction :P > I have some hard time running the test suites though :( > I can't even pass all tests without any of my patches with: > > make EventMachine > > This works better, but still cannot pass everything: > > make -j8 EventMachine > > My linux crashed at the moment, and I am too lazy to fix it right now, > thus running tests on my mac. I'll try to make sure that both EventMachine > and EventMachineThreadSpawn fail on the same tests before sending > the patch. Hope this would be good enough. I've had no trouble running tests with various Linux distros. It's been a long time since I've tested on FreeBSD, and I've not tested on any other *BSD. I cannot support non-Free OSes. Anything in the *err logs? The tests should leave them around on failure. > I'll continue to work on EventMachineThreadPool and EventMachineFiberSpawn > only if EventMachineThreadSpawn works. > > >> would need this to properly pass the tests. > >> > >> I think this would be needed while using > >> `throw :async' as well? > > > > I don't think so, you just need to set @deferred=nil in a few places > > before calling quit. > > I am not sure if we read it the same way, but what I mean is that > if the application is using `throw :async', we still need the check in > this patch to avoid dropping connections while receiving SIGQUIT. > Thus even if EventMachineThreadSpawn is not included, we still > need that check for regular EventMachine to quit gracefully for > applications use `throw :async' > > But anyway, I still don't really understand all the details in Rainbows, > so of course it's very likely that I am simply wrong :P The catch :async will set @deferred=true (obfuscated :x) I'll commit this to clarify the code: --- a/lib/rainbows/event_machine/client.rb +++ b/lib/rainbows/event_machine/client.rb @@ -38,14 +38,17 @@ class Rainbows::EventMachine::Client < EM::Connection @env[ASYNC_CALLBACK] = method(:write_async_response) @env[ASYNC_CLOSE] = EM::DefaultDeferrable.new status, headers, body = catch(:async) { APP.call(@env.merge!(RACK_DEFAULTS)) } - (nil == status || -1 == status) ? @deferred = true : + if (nil == status || -1 == status) + @deferred = true + else ev_write_response(status, headers, body, @hp.next?) + end end def deferred_errback(orig_body) @deferred.errback do orig_body.close if orig_body.respond_to?(:close) @deferred = nil > > I've updated the patch and commit message. Will apply unless > > you have objections: > > Thank you for the corrections and more explanation in the commit log. > I am all for improving it, so credits don't really matter :) You could also > change all the codes and logs in the patch, like fixing my broken English > as well :P Your actual fix was more important than my cleanups :) _______________________________________________ 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