Permalink
Browse files

Rack::Server#start passes any given block through to Handler#run.

Utilize this in the Rack::Server start test to avoid race condition on jruby
  • Loading branch information...
raggi committed Dec 21, 2011
1 parent a46b05e commit 2f060084a4cd46259c3e97b5fe023d07d8bcdf02
Showing with 4 additions and 4 deletions.
  1. +2 −2 lib/rack/server.rb
  2. +2 −2 test/spec_server.rb
View
@@ -226,7 +226,7 @@ def middleware
self.class.middleware
end
- def start
+ def start &blk
if options[:warn]
$-w = true
end
@@ -262,7 +262,7 @@ def start
end
end
- server.run wrapped_app, options
+ server.run wrapped_app, options, &blk
end
def server
View
@@ -61,8 +61,8 @@ def app
:daemonize => false,
:server => 'webrick'
)
- t = Thread.new { server.start }
- until t.status == 'sleep'; t.join(0.01) end
+ t = Thread.new { server.start { |s| Thread.current[:server] = s } }
+ t.join(0.01) until t[:server] && t[:server].status != :Stop
body = open("http://127.0.0.1:#{server.options[:Port]}/") { |f| f.read }
body.should.eql('success')

0 comments on commit 2f06008

Please sign in to comment.