>>>>> "Y" == Yukihiro Matsumoto <matz / ruby-lang.org> writes:

Y> LinuxThread has something bad with signal handling, I guess.  This
Y> patch may solve the blocking problem at the cost of potential
Y> performance slow down.  Can you try (with --enable-pthread)?

 If I've well understood it receive a signal when it's in setcontext().

 One way to see it, is with this script (well if you have svg, which must
 be a stupid PC because it can see problem with ruby :-))

svg% cat s.rb
   require 'webrick'
   include WEBrick

   s = HTTPServer.new(
     :Port => 2000,
     :Logger => BasicLog::new('/dev/null'),
     :AccessLog => []
   )

   class HelloServlet < HTTPServlet::AbstractServlet
     def do_GET(req, res)
        $stderr.print "|"
       res.body = "<HTML>hello, world.</HTML>"
       res['Content-Type'] = "text/html"
     end
   end
   s.mount("/hello", HelloServlet)

   trap("INT"){ s.shutdown }
   s.start
svg% 

svg% cat c.rb
require 'thread'
require 'net/http'

threads = []

200.times do
   threads << Thread.new do
      begin
         h = Net::HTTP::new('localhost', 2000)
         loop do
            $stderr.print "- #{threads.size}"
            h.get('/hello')
         end
      rescue Exception
         p $!
         sleep 5
      end
   end
end

threads.each{|t| t.join}
$stderr.puts "========================================"
sleep(60 * 10)
svg% 

svg% ruby s.rb &
[5] 6897
svg%
 
svg% ruby c.rb
- 0- 1- 2- 3- 4- 5- 6- 7- 8- 9- 10- 11- 12- 13- 14||||||||- 15- 15- 15- 15-
15- 15- 15- 15- 15- 16- 17|- 18- 19|||||||||- 20|- 20- 21|- 22|- 22- 22-
22- 22- 22- 22- 22- 22- 22- 23|- 23- 24|- 24- 25- 25- 26- 26- 27- 27- 28-
29- 30- 31- 32- 33- 34- 35- 36- 37- 38- 39- 40- 41||||||||||||||||||- 42-
42- 42- 42- 42- 42- 42- 42- 42- 42- 42- 42- 42- 42- 42- 43- 42- 43- 43- 44-
45- 46- 47- 48- 49- 50- 51- 52- 53|||||||- 55- 55- 55- 55- 55- 55- 55- 55-
56- 56- 57- 57- 58|- 59|||||||- 60||- 61||- 61- 62|- 62|- 62- 63- 63- 63-
64|- 64- 64- 64- 64- 65||- 65|- 65- 65- 66|- 66- 66||- 67||- 68|- 68|||||-
69- 69|||- 70|- 70- 70||- 70- 70- 70- 70- 71||- 71- 72|- 72|- 72- 72- 72-
72- 73||- 73- 73- 73- 74|||- 74- 74|||- 75- 75- 75- 75- 75- 76|- 76|-
76||||||||- 77||- 77|- 77||||- 78- 78- 78- 78||- 78- 78- 78- 79||||- 80||-
80||| 




 it's blocked (sometimes it seems to work)

 Do like rb_trap_immediate for rb_thread_critical ???


Guy Decoux