In Files

  • webrick/httpservlet/cgi_runner.rb
  • webrick/utils.rb

Parent

Methods

Class/Module Index [+]

Quicksearch

Object

Public Instance Methods

sysread(io, size) click to toggle source

frozen_string_literal: false

cgi_runner.rb – CGI launcher.

Author: IPR – Internet Programming with Ruby – writers Copyright © 2000 TAKAHASHI Masayoshi, GOTOU YUUZOU Copyright © 2002 Internet Programming with Ruby writers. All rights reserved.

$IPR: cgi_runner.rb,v 1.9 2002/09/25 11:33:15 gotoyuzo Exp $

 
               # File webrick/httpservlet/cgi_runner.rb, line 12
def sysread(io, size)
  buf = ""
  while size > 0
    tmp = io.sysread(size)
    buf << tmp
    size -= tmp.bytesize
  end
  return buf
end
            
timeout(seconds, exception=Timeout::Error) click to toggle source

Executes the passed block and raises exception if execution takes more than seconds.

If seconds is zero or nil, simply executes the block

 
               # File webrick/utils.rb, line 258
def timeout(seconds, exception=Timeout::Error)
  return yield if seconds.nil? or seconds.zero?
  # raise ThreadError, "timeout within critical session" if Thread.critical
  id = TimeoutHandler.register(seconds, exception)
  begin
    yield(seconds)
  ensure
    TimeoutHandler.cancel(id)
  end
end