Hi all,
I'm busy experimenting with DRb and I've hit some strange behaviour
which I can't get seem to find the cause of. I think it might be
something to do with DRb and forks but I'm unsure. The process I'm
trying to achieve is to have a Server process running as a DRb
service. It can spawn client processes (the create_client method)
which also run using a DRb service.
Upon spawning the clients create DRb proxy objects to the server and
register using the register_client method passing through their client
process pid and url. The server then creates DRb proxy objects with
the information it receives and stores it in a hash with the client
pid as the key. We can retrieve an array of client pid using the
client_pids method on the server.
I have encountered the following problem. When I start the server
process and then start the client process independent from the server
process everything seems to work fine. I can retrieve from the server
the array of client pids and everything exits gracefully.
However when I create the client from within the server process using
the create_client method (like it hopefully would normally do) the
server registers the client pid and stores it in the hash but on
subsequent calls to get the array of pids it comes back empty(!) and a
ruby process hangs around afterwards. I've attached some files showing
this behaviour. Both tests in theory should be doing the same thing;
registering a client with a server and then retrieving the array of
client pids.
farrel@nicodemus ~/Desktop $ ruby server.rb -n test_register_client
Loaded suite server
Started
Registered client druby://localhost:41362, 1 clients registered
.
Finished in 0.310428 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
farrel@nicodemus ~/Desktop ps
PID TTY TIME CMD
5404 pts/4 00:00:00 bash
5920 pts/4 00:00:00 ps
farrel@nicodemus \~/Desktop ruby server.rb -n test_create_client
Loaded suite server
Started
Registered client druby://localhost:2276, 1 clients registered
F
Finished in 0.315975 seconds.
1) Failure:
test_create_client(TestServer) [server.rb:68]:
<[5923]> expected but was
<[]>.
1 tests, 1 assertions, 1 failures, 0 errors
farrel@nicodemus ~/Desktop $ ps
PID TTY TIME CMD
5404 pts/4 00:00:00 bash
5923 pts/4 00:00:00 ruby
5924 pts/4 00:00:00 ps
As you can see the pid array comes back empty despite the server
printing out the message that it has registered the client and for
some reason there's a ruby process still hanging around.
Any DRb experts out there who can help?
Thanks
Farrel
base.rb (377 Bytes)
client.rb (240 Bytes)
server.rb (1.58 KB)