Re: Question about connecting to a node and proposed patch
Bill Clementson <[email protected]> Wed, 27 Jun 2007 12:17:36 -0700
| Newsgroups | gmane.comp.lang.erlang.distel.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Matthias, Matthias Radestock <[email protected]> writes: > Bill Clementson <[email protected]> writes: > >>> Do you have distel in your erlang load path, e.g. did you add it to >>> ~/.erlang? I do, but there is a recent enhancement where that supposedly >>> is no longer necessary. Perhaps you are using that new feature. However, >>> it doesn't work for me at all - I just get a "badrpc" error all the >>> time - so I have continued using the established way. >> >> Aha! This is the problem and the explanation for why you and I get >> such different behavior for the same test cases. > > That's great news. At least we now know which area to investigate, > namely the new distel module loading code. > >> If you try the test cases that I outlined in my previous messages with >> a remote node, you should see the same behaviour that I was seeing >> locally (before I added the path to my .erlang file). > > I am not seeing the same behaviour. As I mentioned previously (see quote > at top), the new distel loading feature does not work for me at > all. That could be because I am running XEmacs. So, how do you work with remote nodes? Do you manually load the distel modules in them (or have a .erlang file or remote script set up on the remote machine)? Is that what you are referring to above as "the established way" or was there something else that people used to do before Luke added the distel loading feature? >> Therefore, there is probably still a case for doing the initial >> erl-spawn in erl-choose-nodename. > > No. erl-choose-nodename is not supposed to anything other than selecting > the node name for subsequent interactions. It should not initiate any > interactions itself. So, for example, it should make no difference > whether you first start a node and then use "C-c C-d C-n" to select it > for subsequent communication, or vice versa. Why would you want to use "C-c C-d n" to select a node that hasn't been started? >>> Looking at the code, I believe the distel module loading happens via the >>> following hook: >>> (add-hook 'erl-nodeup-hook 'erl-check-backend) >>> I wonder whether there is a race condition which results in this hook >>> being invoked too late when you first connect. >> >> In stepping through the code, I noticed that the hook was only being >> called when the first communication occured with the node (not as a >> result of erl-choose-nodename). > > That is how it is supposed to work. > > The question we need to answer is *why* does executing erl-check-backend > on erl-nodeup not have the desired result? I suspect the answer may be > some race condition, e.g. distel ends up calling distel functions on the > node before the distel code has been fully loaded onto it. If it is a race condition, loading the distel modules into the node when erl-choose-nodename is run will avoid this. For example, the following patch will load distel into remote nodes (or display a message "Successfully communicated with remote node: %S" if distel has already been loaded into the node). - Bill Index: elisp/erl-service.el =================================================================== --- elisp/erl-service.el (revision 23) +++ elisp/erl-service.el (working copy) @@ -50,7 +50,17 @@ (error "No node name given")) (setq erl-nodename-cache name) (setq distel-modeline-node name-string) - (force-mode-line-update)) + (force-mode-line-update) + (when (string-match "^.*@\\(.*\\)" name-string) + (let ((hostname (match-string 1 name-string)) + (localhost (erl-determine-hostname))) + (when (not (string= hostname localhost)) + (erl-spawn + (erl-send-rpc erl-nodename-cache 'erlang 'node nil) + (erl-receive () + ((['rex node] + (when (string= erl-nodename-cache node) + (message "Successfully communicated with remote node: %S" node)))))))))) erl-nodename-cache) ;;;;; Call MFA lookup ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/