~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to lib/timeout.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum, Daigo Moriwaki, Lucas Nussbaum
  • Date: 2011-07-25 20:27:20 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20110725202720-9qfs7iam0ml7e1kc
Tags: 1.9.2.290-1
[ Daigo Moriwaki ]
* New upstream release.
* Removed debian/patches/110411_disable_osslv2.patch, which has been applied
  by the upstream.
* Added a patch: debian/patches/debian/patches/110716-bigdecimal,
  which was backported from the upstream (r30993)
  (CVE-2011-0188; Closes: 628450)

[ Lucas Nussbaum ]
* Build-depend on tcl-dev and tk-dev instead of {tcl,tk}8.4-dev.
* Update Lucas' email address.
* Add 110825-ossl-config.diff: backport changes to the OpenSSL
  extension to fix test failure.
* Add patch 110720_tcltk_disable_rpath.diff: disable rpath in tcltk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    return yield(sec) if sec == nil or sec.zero?
45
45
    exception = klass || Class.new(ExitException)
46
46
    begin
47
 
      x = Thread.current
48
 
      y = Thread.start {
49
 
        begin
50
 
          sleep sec
51
 
        rescue => e
52
 
          x.raise e
53
 
        else
54
 
          x.raise exception, "execution expired" if x.alive?
 
47
      begin
 
48
        x = Thread.current
 
49
        y = Thread.start {
 
50
          begin
 
51
            sleep sec
 
52
          rescue => e
 
53
            x.raise e
 
54
          else
 
55
            x.raise exception, "execution expired"
 
56
          end
 
57
        }
 
58
        return yield(sec)
 
59
      ensure
 
60
        if y
 
61
          y.kill
 
62
          y.join # make sure y is dead.
55
63
        end
56
 
      }
57
 
      return yield(sec)
 
64
      end
58
65
    rescue exception => e
59
66
      rej = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-4}\z/o
60
67
      (bt = e.backtrace).reject! {|m| rej =~ m}
66
73
      raise if klass            # if exception class is specified, it
67
74
                                # would be expected outside.
68
75
      raise Error, e.message, e.backtrace
69
 
    ensure
70
 
      if y and y.alive?
71
 
        y.kill
72
 
        y.join # make sure y is dead.
73
 
      end
74
76
    end
75
77
  end
76
78