Drb session problem

I’m using DRb for my CGI session store class, as described on the Ruby
Garden wiki here:

http://www.rubygarden.org/ruby?FCGIRubySessionHandling

I’ve created the session DRbStore class pretty much exactly as it is
there. Just to be precise, here is my DRbStore class:

···

require 'cgi/session’
require ‘drb’

class CGI
class Session
class DRbStore
DRb.start_service
@@session_data = DRbObject.new(nil, ‘druby://localhost:9192’)

   def initialize(session, option=nil)
     @session_id = session.session_id
   end

   def restore
     @h = @@session_data[@session_id] || {}
   end

   def update
     @@session_data[@session_id] = @h
   end

   def close
   end

   def delete
     @@session_data.delete(@session_id)
   end
 end

end
end


And here is the DRb daemon that the DRbStore class accesses:


This is a session storage daemon which can be shared by multiple FCGI

processes. It’s just a hash which is enabled for DRb access.

require ‘drb’

session_data = Hash.new
DRb.start_service(“druby://127.0.0.1:9192”, session_data)
DRb.thread.join


And here is how I’m instantiating it:


@sess = CGI::Session.new(@cgi, ‘database_manager’ => CGI::Session::DRbStore)


That seems to succeed just fine, as long as I have the session daemon
running, of course. And then when I try to access a session variable
like this:

somevar = @sess[‘data’]

I get the following error (with stack trace):


/usr/local/lib/ruby/1.8/cgi/session.rb:80:in []' /usr/local/lib/ruby/1.8/drb/drb.rb:407:inmethod_missing’
/usr/local/lib/ruby/1.8/drb/drb.rb:451:in open' /usr/local/lib/ruby/1.8/drb/drb.rb:451:innew’
/usr/local/lib/ruby/1.8/drb/drb.rb:468:in initialize' /usr/local/lib/ruby/1.8/drb/drb.rb:163:inopen’
/usr/local/lib/ruby/1.8/drb/drb.rb:163:in each' /usr/local/lib/ruby/1.8/drb/drb.rb:170:inopen’
druby://linux:35269 - #

It’s like the daemon is returning an instance of DRbStore, instead of
the hash it is supposed to contain.

Does anybody have any idea of what might be going wrong?

Thanks,
Carl Youngblood