From daef00084d0eae3a9d1492ccd17a98cc7ec4e7c0 Mon Sep 17 00:00:00 2001
From: Eric Wong <normalperson@yhbt.net>
Date: Tue, 5 Apr 2011 15:20:48 -0700
Subject: [PATCH] timeout.rb: avoid introducing new class for every timeout

This is expensive because of clearing the method cache upon GC.

As a side effect, it also seems to pass the deadlock_test.rb[1]
for Bug #4266[2] and also the JRuby load_timeout.rb[3] test.
However, DO NOT consider this a fix for Bug #4266 or other
timeout-related issues.  I believe this patch merely hides the
real bug and makes it hard to trigger from Ruby standard library.

[1] http://redmine.ruby-lang.org/attachments/download/1404/deadlock_test.rb
[2] http://redmine.ruby-lang.org/issues/4266
[3] https://github.com/jruby/jruby/raw/master/test/load/load_timeout.rb
---
 lib/timeout.rb |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/timeout.rb b/lib/timeout.rb
index 297b769..106722a 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -42,7 +42,7 @@ module Timeout
   # so you can call it directly as Timeout.timeout().
   def timeout(sec, klass = nil)   #:yield: +sec+
     return yield(sec) if sec == nil or sec.zero?
-    exception = klass || Class.new(ExitException)
+    exception = klass || ExitException
     begin
       x = Thread.current
       y = Thread.start {
-- 
1.7.5.rc0.117.gd2742

