From normalperson at yhbt.net Thu Dec 3 03:22:51 2009 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 3 Dec 2009 00:22:51 -0800 Subject: [Rev-talk] [PATCH/RFC] timer_watcher_spec: ensure interval has passed before running In-Reply-To: <20091019023837.GA17116@dcvr.yhbt.net> References: <20091019023837.GA17116@dcvr.yhbt.net> Message-ID: <20091203082251.GA17596@dcvr.yhbt.net> Eric Wong wrote: > There was a timer_watcher event_callback defined for the > IOWatcher class in the timer_watcher.rb file. I assume this is > a copy-and-paste error and a grep of the source shows no > "timer_watcher" methods ever being dispatched. So change this > to allow the "on_timer" method to be overidden when given a > block. > > Also added a spec to show it works. > --- Actually, I think the spec I added at the time was always broken under 1.9... Or I'm understanding Rev::Loop.run_once incorrectly. I thought this was broken by my recent changes to make Rev::Loop.run_once work better under 1.8, but reverting back[1] to the original commit that introduced this spec reveals it was always broken under 1.9. I've pushed this out to git://yhbt.net/rev , but please take this with a grain of salt since it's probably too late for me at night to be thinking clearly. [1] - that means "git clean -f -d -x" in my working copy and any gem installations purged. I even tried it on a clean box that's never seen rev.git before. >From ccb25d3f2a97c234ebf613757f2ee59179dda249 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 2 Dec 2009 23:58:23 -0800 Subject: [PATCH] timer_watcher_spec: ensure interval has passed before running Otherwise Rev::Loop.run_once may not have fired --- spec/timer_watcher_spec.rb | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/spec/timer_watcher_spec.rb b/spec/timer_watcher_spec.rb index dde994c..b7305cd 100644 --- a/spec/timer_watcher_spec.rb +++ b/spec/timer_watcher_spec.rb @@ -2,12 +2,15 @@ require File.dirname(__FILE__) + '/../lib/rev' describe Rev::TimerWatcher do + interval = 0.010 + it "can have the on_timer callback defined after creation" do - @watcher = Rev::TimerWatcher.new(0.01, true) + @watcher = Rev::TimerWatcher.new(interval, true) nr = '0' @watcher.on_timer { nr.succ! }.should == nil @watcher.attach(Rev::Loop.default).should == @watcher nr.should == '0' + sleep interval Rev::Loop.default.run_once nr.should == '1' end @@ -20,25 +23,28 @@ describe Rev::TimerWatcher do TMP.succ! end end - @watcher = MyTimerWatcher.new(0.01, true) + @watcher = MyTimerWatcher.new(interval, true) @watcher.attach(Rev::Loop.default).should == @watcher MyTimerWatcher::TMP.should == '0' + sleep interval Rev::Loop.default.run_once MyTimerWatcher::TMP.should == '1' end it "can have the on_timer callback redefined between runs" do - @watcher = Rev::TimerWatcher.new(0.01, true) + @watcher = Rev::TimerWatcher.new(interval, true) nr = '0' @watcher.on_timer { nr.succ! }.should == nil @watcher.attach(Rev::Loop.default).should == @watcher nr.should == '0' + sleep interval Rev::Loop.default.run_once nr.should == '1' @watcher.detach @watcher.on_timer { nr = :foo }.should == nil @watcher.attach(Rev::Loop.default).should == @watcher nr.should == '1' + sleep interval Rev::Loop.default.run_once nr.should == :foo end -- Eric Wong From normalperson at yhbt.net Fri Dec 4 04:21:34 2009 From: normalperson at yhbt.net (Eric Wong) Date: Fri, 4 Dec 2009 01:21:34 -0800 Subject: [Rev-talk] [PATCH (trivial)] build: use "install" for copying shared objects Message-ID: <20091204092134.GA11390@dcvr.yhbt.net> Unlike "cp", "install" will unlink the destination before copying the file over so an already running process can continue using the previous extension (instead of segfaulting a running process because a shared object is being overwritten). --- I pushed this out to the "buildfix" branch on git://yhbt.net/rev since my master branch there has a commit for the timer_watcher spec still awaiting a second set of eyes... Rakefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Rakefile b/Rakefile index 3229fb6..60fbb27 100644 --- a/Rakefile +++ b/Rakefile @@ -67,7 +67,7 @@ def setup_extension(dir, extension) file ext_so => ext_files do make "#{ext}" - cp ext_so, "lib" + install ext_so, "lib" end end -- Eric Wong From youngh at caida.org Fri Dec 4 20:08:11 2009 From: youngh at caida.org (Young Hyun) Date: Fri, 4 Dec 2009 17:08:11 -0800 Subject: [Rev-talk] [PATCH] make openssl-nonblock more compatible with Ruby 1.9.2 preview 2 Message-ID: <254C2C4E-8B16-443E-9D50-28E795666038@caida.org> Here's a small patch to make openssl-nonblock more compatible with Ruby 1.9.2 preview 2. Specifically, ReadAgain and WriteAgain now include IO::WaitReadable and IO::WaitWritable, respectively. This change allows a single code base to work with either Ruby 1.9.2 preview 2 or with openssl-nonblock on older Ruby versions. I've only tested this on ruby 1.8.7-p174. Rather than directly rescuing ReadAgain, one should rescue IO::WaitReadable (etc.) as described in the Ruby 1.9.2 preview 2 RDoc. --Young -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Changed-to-be-more-compatible-with-Ruby-1.9.2-previe.patch Type: application/octet-stream Size: 1859 bytes Desc: not available URL: -------------- next part -------------- From tony at medioh.com Fri Dec 4 20:45:22 2009 From: tony at medioh.com (Tony Arcieri) Date: Fri, 4 Dec 2009 18:45:22 -0700 Subject: [Rev-talk] [PATCH] make openssl-nonblock more compatible with Ruby 1.9.2 preview 2 In-Reply-To: <254C2C4E-8B16-443E-9D50-28E795666038@caida.org> References: <254C2C4E-8B16-443E-9D50-28E795666038@caida.org> Message-ID: Thanks! Awhile ago I was asking Ruby Core about what the final names for these would be. Guess they're decided now. I actually spun Rev's OpenSSL nonblocking support off into its own gem: http://github.com/tarcieri/openssl-nonblock I've been meaning to switch Rev to depend on the openssl-nonblock gem (much in the way I spun off iobuffer into its own gem), and in fact the names of these exceptions were one of the things I was waiting on. This gem "monkeypatches" (in C code!) the Ruby SSL classes with nonblocking support. If I adjust the names of these exceptions in this gem, it should present an API which is fully compatible with Ruby 1.9.2 and is available to any application running on any other version of Ruby. I can make the same changes to this gem, or you can submit another patch, if you like. Given this development, I'd really like to switch Rev to use the openssl-nonblock gem. On Fri, Dec 4, 2009 at 6:08 PM, Young Hyun wrote: > Here's a small patch to make openssl-nonblock more compatible with Ruby > 1.9.2 preview 2. Specifically, ReadAgain and WriteAgain now include > IO::WaitReadable and IO::WaitWritable, > respectively. This change allows a single code base to work with either > Ruby 1.9.2 preview 2 or with openssl-nonblock on older Ruby versions. I've > only tested this on ruby 1.8.7-p174. > > Rather than directly rescuing ReadAgain, one should rescue IO::WaitReadable > (etc.) as described in the Ruby 1.9.2 preview 2 RDoc. > -- Tony Arcieri Medioh/Nagravision -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony at medioh.com Wed Dec 16 00:12:36 2009 From: tony at medioh.com (Tony Arcieri) Date: Tue, 15 Dec 2009 22:12:36 -0700 Subject: [Rev-talk] [PATCH] make openssl-nonblock more compatible with Ruby 1.9.2 preview 2 In-Reply-To: References: <254C2C4E-8B16-443E-9D50-28E795666038@caida.org> Message-ID: Hi, I pushed your patch to github. I'll try to release a new openssl-nonblock gem soon, but for now I'm having issues with Gemcutter. On Fri, Dec 4, 2009 at 6:45 PM, Tony Arcieri wrote: > Thanks! Awhile ago I was asking Ruby Core about what the final names for > these would be. Guess they're decided now. > > I actually spun Rev's OpenSSL nonblocking support off into its own gem: > > http://github.com/tarcieri/openssl-nonblock > > I've been meaning to switch Rev to depend on the openssl-nonblock gem (much > in the way I spun off iobuffer into its own gem), and in fact the names of > these exceptions were one of the things I was waiting on. This gem > "monkeypatches" (in C code!) the Ruby SSL classes with nonblocking support. > If I adjust the names of these exceptions in this gem, it should present an > API which is fully compatible with Ruby 1.9.2 and is available to any > application running on any other version of Ruby. > > I can make the same changes to this gem, or you can submit another patch, > if you like. Given this development, I'd really like to switch Rev to use > the openssl-nonblock gem. > > > On Fri, Dec 4, 2009 at 6:08 PM, Young Hyun wrote: > >> Here's a small patch to make openssl-nonblock more compatible with Ruby >> 1.9.2 preview 2. Specifically, ReadAgain and WriteAgain now include >> IO::WaitReadable and IO::WaitWritable, >> respectively. This change allows a single code base to work with either >> Ruby 1.9.2 preview 2 or with openssl-nonblock on older Ruby versions. I've >> only tested this on ruby 1.8.7-p174. >> >> Rather than directly rescuing ReadAgain, one should rescue >> IO::WaitReadable (etc.) as described in the Ruby 1.9.2 preview 2 RDoc. >> > > -- > Tony Arcieri > Medioh/Nagravision > -- Tony Arcieri Medioh! A Kudelski Brand -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony at medioh.com Wed Dec 16 00:21:50 2009 From: tony at medioh.com (Tony Arcieri) Date: Tue, 15 Dec 2009 22:21:50 -0700 Subject: [Rev-talk] [PATCH/RFC] timer_watcher_spec: ensure interval has passed before running In-Reply-To: <20091203082251.GA17596@dcvr.yhbt.net> References: <20091019023837.GA17116@dcvr.yhbt.net> <20091203082251.GA17596@dcvr.yhbt.net> Message-ID: Sorry about the belated reply... I've been busy with other stuff, especially Reia :) On Thu, Dec 3, 2009 at 1:22 AM, Eric Wong wrote: > Eric Wong wrote: > > There was a timer_watcher event_callback defined for the > > IOWatcher class in the timer_watcher.rb file. I assume this is > > a copy-and-paste error and a grep of the source shows no > > "timer_watcher" methods ever being dispatched. So change this > > to allow the "on_timer" method to be overidden when given a > > block. > > > > Also added a spec to show it works. > > --- > > Actually, I think the spec I added at the time was always > broken under 1.9... > > Or I'm understanding Rev::Loop.run_once incorrectly. > Can you better clarify the behavior your were expecting with Rev::Loop.run_once and timers? Rev::Loop.run_once will perform a single pass through libev's event loop. Your spec sleeps until the timer interval should've passed, and checks if it receives an event, which it does, at least when I run the spec. So I'm confused... what's the problem? > I thought this was broken by my recent changes to make > Rev::Loop.run_once work better under 1.8, but reverting back[1] to the > original commit that introduced this spec reveals it was always broken > under 1.9. > > I've pushed this out to git://yhbt.net/rev , but please take > this with a grain of salt since it's probably too late for > me at night to be thinking clearly. > Is this spec failing for you? Anyway, merged and pushed... -- Tony Arcieri Medioh! A Kudelski Brand -------------- next part -------------- An HTML attachment was scrubbed... URL: From normalperson at yhbt.net Wed Dec 16 01:23:52 2009 From: normalperson at yhbt.net (Eric Wong) Date: Wed, 16 Dec 2009 06:23:52 +0000 Subject: [Rev-talk] [PATCH/RFC] timer_watcher_spec: ensure interval has passed before running In-Reply-To: References: <20091019023837.GA17116@dcvr.yhbt.net> <20091203082251.GA17596@dcvr.yhbt.net> Message-ID: <20091216062352.GC1654@dcvr.yhbt.net> Tony Arcieri wrote: > On Thu, Dec 3, 2009 at 1:22 AM, Eric Wong wrote: > > Eric Wong wrote: > > > There was a timer_watcher event_callback defined for the > > > IOWatcher class in the timer_watcher.rb file. I assume this is > > > a copy-and-paste error and a grep of the source shows no > > > "timer_watcher" methods ever being dispatched. So change this > > > to allow the "on_timer" method to be overidden when given a > > > block. > > > > > > Also added a spec to show it works. > > > --- > > > > Actually, I think the spec I added at the time was always > > broken under 1.9... > > > > Or I'm understanding Rev::Loop.run_once incorrectly. > > Can you better clarify the behavior your were expecting with > Rev::Loop.run_once and timers? > > Rev::Loop.run_once will perform a single pass through libev's event loop. > Your spec sleeps until the timer interval should've passed, and checks if it > receives an event, which it does, at least when I run the spec. So I'm > confused... what's the problem? I was mistaken and thought Rev::Loop.run_once would sleep the calling thread on its own, but now that I think about it, it makes sense: run_once may run in a different thread under 1.9. > > I thought this was broken by my recent changes to make > > Rev::Loop.run_once work better under 1.8, but reverting back[1] to the > > original commit that introduced this spec reveals it was always broken > > under 1.9. > > I've pushed this out to git://yhbt.net/rev , but please take > > this with a grain of salt since it's probably too late for > > me at night to be thinking clearly. > > Is this spec failing for you? > > Anyway, merged and pushed... Without the patch, yes it was failing under 1.9. All good now, thanks! -- Eric Wong From tony at medioh.com Wed Dec 16 01:29:11 2009 From: tony at medioh.com (Tony Arcieri) Date: Tue, 15 Dec 2009 23:29:11 -0700 Subject: [Rev-talk] [PATCH/RFC] timer_watcher_spec: ensure interval has passed before running In-Reply-To: <20091216062352.GC1654@dcvr.yhbt.net> References: <20091019023837.GA17116@dcvr.yhbt.net> <20091203082251.GA17596@dcvr.yhbt.net> <20091216062352.GC1654@dcvr.yhbt.net> Message-ID: On Tue, Dec 15, 2009 at 11:23 PM, Eric Wong wrote: > I was mistaken and thought Rev::Loop.run_once would sleep the calling > thread on its own, but now that I think about it, it makes sense: > run_once may run in a different thread under 1.9. > run_once does not sleep. It performs a single pass through the event loop and dispatches any pending events, then immediately returns control back to the caller once all pending events are processed. It's the "non-blocking" alternative to run. > Without the patch, yes it was failing under 1.9. All good now, thanks! > Great. Hopefully I can do a new release soon. -- Tony Arcieri Medioh! A Kudelski Brand -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony at medioh.com Thu Dec 17 00:20:50 2009 From: tony at medioh.com (Tony Arcieri) Date: Wed, 16 Dec 2009 22:20:50 -0700 Subject: [Rev-talk] [PATCH/RFC] timer_watcher_spec: ensure interval has passed before running In-Reply-To: References: <20091019023837.GA17116@dcvr.yhbt.net> <20091203082251.GA17596@dcvr.yhbt.net> <20091216062352.GC1654@dcvr.yhbt.net> Message-ID: On Wed, Dec 16, 2009 at 10:16 PM, Roger Pack wrote: > Hooray for rev--the only evented ruby architecture with an > on_write_complete LOL. > -r > Honestly, this is the single most important event which is missing from the EventMachine contract. Perhaps I should've spent my time simply adding this callback to EventMachine, but I preferred to build a true OO event API on top of Ruby. -- Tony Arcieri Medioh! A Kudelski Brand -------------- next part -------------- An HTML attachment was scrubbed... URL: