Question about connecting to a node and proposed patch

Bill Clementson <[email protected]> Tue, 26 Jun 2007 15:23:49 -0700
Newsgroups gmane.comp.lang.erlang.distel.devel
Message-ID <[email protected]>
Hi all,

One of the things that tends to bug me a bit is that, when I connect
to a node for the first time, the distel modules aren't loaded into
that node until you actually attempt to communicate with the node
(e.g. - display processes with "C-c C-d l" or reload a module with
"C-c C-d L"). At that point, the distel modules are loaded into the
node and you get a message stating "(Successfully uploaded backend
modules into node)". However, the action that you attempted (e.g. - if
you pressed "C-c C-d l" to display processes) is not actually executed
because the distel modules hadn't been previously loaded. Obviously,
this issue has bugged a number of other people in the past too as
there are a couple of similar messages on the mailing list and an
enhancement request on the google code distel web site
(http://code.google.com/p/distel/issues/list).

Is there some reason why the uploading of distel modules to a node
shouldn't occur when you first connect to a node? I couldn't think of
any good reasons not to, so I've made a patch to
erl-choose-nodename. If the node that you're connecting to does not
have the distel code loaded into it, the code will be loaded into the
node and you'll get the message "(Successfully uploaded backend
modules into node)" after you connect to the node with "C-c C-d
n". However, if you have already connected to the node previously and
the distel modules are already loaded in the node, you'll get a
message "Successfully communicated with node: xxx@yyy".

Please try out the attached patch and let me know if you think it's ok
to commit or whether there are reasons this change shouldn't be made.

--
Bill Clementson


Index: elisp/erl-service.el
===================================================================
--- elisp/erl-service.el	(revision 23)
+++ elisp/erl-service.el	(working copy)
@@ -50,7 +50,13 @@
       (error "No node name given"))
     (setq erl-nodename-cache name)
     (setq distel-modeline-node name-string)
-    (force-mode-line-update))
+    (force-mode-line-update)
+    (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 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/