Forum: Ruby Thread dead lock/fatal

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
555c1193071e97926fa67c038244c047?d=identicon&s=25 Phy Prabab (Guest)
on 2007-02-01 00:05
(Received via mailing list)
Hello,

I am using 1.8.5p20 (Dec 2006) of ruby using the pickaxe book example of
extending GServer and I have come across a fatal that is perhaps my
fault.  I run the example code (below) on RHEE30 x86_64 (ruby is 32b)
connecting to the server instance on the same machine through a repeat
command, as in:

repeat 100 telnet localhost 2000

I eventually get this:

[Wed Jan 31 14:52:05 2007] TimeServer 127.0.0.1:2000 client:50838
disconnect
deadlock 0x2a95ceafa8: sleep:J(0x2a95e514c8) (main) -
/lan/rc/tools/1.4/lnx64b24c23/ruby185/lib/ruby/1.8/gserver.rb:128
deadlock 0x2a95e514c8: sleep:-  -
/lan/rc/tools/1.4/lnx64b24c23/ruby185/lib/ruby/1.8/thread.rb:203
[Wed Jan 31 14:52:05 2007] TimeServer 127.0.0.1:2000 stop
/lan/rc/tools/1.4/lnx64b24c23/ruby185/lib/ruby/1.8/gserver.rb:208:in
`join': Thread(0x2a95e1f298): deadlock (fatal)
        from ./testserv.rb:22


Does this look like I am doing something wrong?

Here is the code:

cat testserv.rb
#!/usr/bin/env ruby

require 'gserver'
require 'time'

class TimeServer < GServer
  def initialize
    super(2000)
    @count = 3
  end
  def server(client)
    client.puts Time.now.to_s
    @count -=1
    stop if @count.zero?
  end
end

server = TimeServer.new

server.audit = true
server.start
server.join


Thanks for the help!
Phy
This topic is locked and can not be replied to.