From ac6b83ea1c277cd798e2f627fa5eee605efab4fe Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 26 Feb 2011 20:59:00 +0000 Subject: middleware: avoid double decrement when reading stats Oops! --- lib/raindrops/middleware.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/raindrops/middleware.rb b/lib/raindrops/middleware.rb index ea19ffc..af3442c 100644 --- a/lib/raindrops/middleware.rb +++ b/lib/raindrops/middleware.rb @@ -32,17 +32,18 @@ class Raindrops::Middleware # standard Rack endpoint def call(env) env[PATH_INFO] == @path and return stats_response + begin + @stats.incr_calling - @stats.incr_calling + status, headers, body = @app.call(env) + rv = [ status, headers, Proxy.new(body, @stats) ] - status, headers, body = @app.call(env) - rv = [ status, headers, Proxy.new(body, @stats) ] - - # the Rack server will start writing headers soon after this method - @stats.incr_writing - rv + # the Rack server will start writing headers soon after this method + @stats.incr_writing + rv ensure @stats.decr_calling + end end class Proxy -- cgit v1.2.3-24-ge0c7