Two issues with webrick - both threading & OS related

--- Yohanes Santoso wrote:

Funny, I do not observe that behaviour:

On my XP system here, with:
WEBrick 1.3.1
ruby 1.8.2 (2004-06-29) [i386-mswin32]

I get the following from your script (slightly modified; i'll post below
for completeness) from three requests started as close to the same time as
I could manage:

Req1:
Start: Tue Aug 31 14:50:30 Eastern Daylight Time
2004
End: Tue Aug 31 14:50:40 Eastern Daylight Time 2004

Req2:
Start:
Tue Aug 31 14:50:40 Eastern Daylight Time 2004
End: Tue Aug 31 14:50:50 Eastern
Daylight Time 2004

Req3:
Start: Tue Aug 31 14:50:50 Eastern Daylight Time
2004
End: Tue Aug 31 14:51:00 Eastern Daylight Time 2004

Looks like they're
blocking each other pretty perfectly, eh? :slight_smile: I've also added output of the
server's :MaxClients just to be sure... but it returns "100", as it should
by default.

Any Ideas? I'll post the script below just to ensure I didn't
break anything in making it run...

-Ryan

PS - Sorry about the poor formatting
on my emails, I'm reading the list through Bloglines lately... maybe I should
switch back to receiving all the messages...

require 'webrick'
include
WEBrick

class SleepServer < HTTPServlet::AbstractServlet
  def do_GET(req,resp)

    resp.body="Start: #{Time.new}\n"
    sleep(10)
    resp.body << "End:
#{Time.new}\n"
    resp['content-type'] = 'text/plain'
  end
end

class
GreetServer < HTTPServlet::AbstractServlet
  def do_GET(req, resp)
    resp.body="Hi,
now is: #{Time.new}\n"
    resp['content-type']='text/plain'
  end
end

default_port = (12301 + (Dir.pwd.hash % 1000)).to_s

$port = (ARGV[0]

default_port).to_i

puts "URL: http://#{Socket.gethostname}:#$port"

$s = HTTPServer.new(
  :Port => $port,
  :DocumentRoot =>
Dir::pwd
)

p $s[:MaxClients]

$s.mount('/sleep', SleepServer)
$s.mount('/greet',
GreetServer)
trap("INT"){ $s.shutdown }
$s.start

rdlugosz.1044583@bloglines.com writes:

--- Yohanes Santoso wrote:

Funny, I do not observe that behaviour:

On my XP system here, with:
WEBrick 1.3.1
ruby 1.8.2 (2004-06-29) [i386-mswin32]

Hm.. I tested the problem on linux because you mentioned that you and
Jim have confirmed that the problem was on all OS. Now it seems it is
limited to at least XP (probably win32 too).

So, how about it, list, which ruby build for win32 should he be using?
cygwin or mscv or something else?

Also his second problem is about select() on win32 does not operate on
the return of pipe(). This should not be a problem with the cygwin
version, but iirc, lots of people do not use the cygwin version. Does
the msvc version allow select() on pipe() (or whatever IO.pipe()
returns)?

YS.