# Two issues with webrick - both threading & OS related

**URL:** <https://rubytalk.org/t/two-issues-with-webrick-both-threading-os-related/13350>\
**Category:** ruby-talk\
**Created:** [31 August 2004 18:54 UTC](https://rubytalk.org/t/two-issues-with-webrick-both-threading-os-related/13350 "2004-08-31T18:54:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rdlugosz\_1044583](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@Rdlugosz\_1044583](https://rubytalk.org/u/Rdlugosz_1044583)\
**Post date:** [31 August 2004 18:54 UTC](https://rubytalk.org/t/two-issues-with-webrick-both-threading-os-related/13350/1 "2004-08-31T18:54:21Z")

</div>

--- 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? 🙂 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  
&nbsp;&nbsp;def do\_GET(req,resp)

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

class  
GreetServer \< HTTPServlet::AbstractServlet  
&nbsp;&nbsp;def do\_GET(req, resp)  
&nbsp;&nbsp;&nbsp;&nbsp;resp.body="Hi,  
now is: #{Time.new}\n"  
&nbsp;&nbsp;&nbsp;&nbsp;resp['content-type']='text/plain'  
&nbsp;&nbsp;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(  
&nbsp;&nbsp;:Port =\> $port,  
&nbsp;&nbsp;:DocumentRoot =\>  
Dir::pwd  
)

p $s[:MaxClients]

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

---

<div class="post-metadata">

**Author:** ![Yohanes\_Santoso1](https://avatars.discourse-cdn.com/v4/letter/y/ccd318/32.png) [@Yohanes\_Santoso1](https://rubytalk.org/u/Yohanes_Santoso1)\
**Post date:** [31 August 2004 20:18 UTC](https://rubytalk.org/t/two-issues-with-webrick-both-threading-os-related/13350/2 "2004-08-31T20:18:56Z")

</div>

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.
