Hi Jos,

> I am trying to write a simple remote execution framework, and am running
into a

Interesting ... keep us posted.

> DRb problem I can't seem to figure out. The system consists of a
controller and
> a number of clients; the controller sends commands to the clients (these
> commands in turn will eventually talk to a server).

Looking at the code makes me feel that the controller is a DRb client
and your client is actually a DRb server. Not a big issue at all ... just
tripped
me initially.

> The problem is that when I
> make the same method call twice in a row I see the following error on the
> controller side:
>
> Terminal A: running the client:
>
> lizzy:~/public_html/ruby/webrun% ./webrun-client.rb
> Starting WebRun service on localhost:12345
> WebRunClient.add(u1)
> users=[u1]
> cmd=load_file
>
> Terminal B: running the controller:
>
> lizzy:~/public_html/ruby/webrun% ./webrun-control.rb
> assigning proxy for localhost
> #<UserPool:0x8174ba8 @userlist={"u1"=>#<User:0x8174b30
@client_class="Client_u1", @name="u1", @filename=nil, @thread=nil>}>
> #<UserPool:0x8174234 @userlist={"u1"=>#<User:0x81741bc
@client_class="Client_u1", @name="u1", @filename=nil, @thread=nil>}>
> user u1 -> client localhost:12345
> execute cmd load_file on client localhost:12345 for users [u1]
>
> 2nd call fails:
> #<DRb::DRbUnknown:0x8172d44
@buf="\004\010o:\rUserPool\006:\016@userlist{\006
                ^^^^^^^^^^^^^^^
I tried hard to track down the source of this object ... but was not very
successful :-(

> /webrun.rb:29:in `has_user?': undefined method `has_user?' for
#<DRb::DRbUnknown:0x81719d0>

This was my starting point of investigation

> NoMethodError)
>         from ./webrun.rb:82:in `where_is_user'
>         from ./webrun.rb:80:in `each'
>         from ./webrun.rb:75:in `each'
>         from ./webrun.rb:75:in `each'
>         from ./webrun.rb:87:in `where_is_user'
>         from ./webrun.rb:138:in `execute_each_user'
>         from ./webrun.rb:137:in `each'
>         from ./webrun.rb:137:in `execute_each_user'
>         from ./webrun-control.rb:17

<snip>

> Does anybody have any idea what I could be doing wrong or how to debug
this
> problem?

Well, I can point you to some obvious typos (see line 15 in webrun.rb):

      @proxy = DRbObject.new(nil, "druby://#@name:#@port")
                                                                  ^^^^
^^^^
Don't you want this to be:

     @proxy = DRbObject.new(nil, "druby://#{@name}:#{@port}")

Search for #@ in your code and you will find few more occurances

And line 17:

     yield @proxy if block_given? and @proxy

I would rewrite as:

    yield @proxy if (block_given? and @proxy)

just to be on the safe side...."and" has very low precedence.

Unfortunately, even after changing this and using ruby 1.8.1 on Win XP,
I got the same errors as before. I tried running in the debugger mode (with
-rdebug option) and I got even more errors, even for the first call.

All I can suggest is: try single-threaded, non-distributed version first, if
possible
and slowly introduce the more advanced features. Best of luck !

-- shanko