Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rolled back rev 93, which broke everything...

git-svn-id: https://distel.googlecode.com/svn/trunk@94 d5f8e727-742a-0410-b67d-dd739a6cc792
  • Loading branch information...
commit 52f06d1656fe513f2bd66b5a82cd0ea1a0b10e50 1 parent 2ceeaff
@massemanet authored
View
12 ChangeLog
@@ -1,15 +1,3 @@
-2009-08-02 Luke Gorrie <luke@bup.co.nz>
-
- * elisp/erl-service.el (erl-rpc): Ensure that the backend distel
- module is loaded before issuing the RPC request. Upload the BEAM
- files directly if necessary. This feature already existed, but
- used to execute asynchronously, and not happen in time for the
- initial RPC (which would fail).
-
- * elisp/derl.el (derl-distel-available): Buffer-local variable to
- keep track of whether the Distel backend code is available on the
- remote node.
-
2008-12-18 Mats Cronqvist <masse@kreditor.se>
* *: tagged and uploaded 4.03
View
25 elisp/derl.el
@@ -53,14 +53,6 @@ handshake, 4 when connected."))
"Messages waiting to be sent to node."))
(make-variable-buffer-local
- (defvar derl-backend-available nil
- "True when the Distel backend erlang modules are available."))
-
-(make-variable-buffer-local
- (defvar derl-distel-rpc-queue nil
- "Messages waiting to be sent to node after backend code is loaded."))
-
-(make-variable-buffer-local
(defvar derl-remote-links '()
"List of (LOCAL-PID . REMOTE-PID) for all distributed links (per-node.)
Used for sending exit signals when the node goes down."))
@@ -350,10 +342,6 @@ modified."
(defun derl-eat-msg ()
(delete-region (point-min) (derl-msg-end)))
-(defun derl-connected-p (node)
- (let ((buffer (get-buffer (derl-buffer-name node))))
- (and buffer (with-current-buffer buffer derl-alive))))
-
;; ------------------------------------------------------------
;; Distributed erlang protocol requests
;; ------------------------------------------------------------
@@ -411,19 +399,6 @@ initiated if necessary and the request is queued."
(fsm-insert ctl)
(fsm-insert msg)))))
-(defun derl-distel-available (node)
- (let ((buffer (get-buffer (derl-buffer-name node))))
- (when buffer
- (with-current-buffer buffer
- (setq derl-backend-available t)))))
-
-(defun derl-distel-available-p (node)
- (let ((buffer (get-buffer (derl-buffer-name node))))
- (when buffer
- (with-current-buffer buffer
- (setq derl-backend-available t)))))
-
-
;; Tracing
(defface derl-trace-output-face
View
41 elisp/erl-service.el
@@ -156,19 +156,21 @@ Should be called with point directly before the opening ( or /."
;;;; Backend code checking
-(defun erl-load-backend (node &optional rpc)
- "Load the backend Erlang modules on NODE and then issue RPC.
-RPC is an apply'able argument list for `erl-rpc'."
+(add-hook 'erl-nodeup-hook 'erl-check-backend)
+
+(defun erl-check-backend (node _fsm)
+ "Check if we have the 'distel' module available on `node'.
+If not then try to send the module over as a binary and load it in."
(unless distel-inhibit-backend-check
(erl-spawn
(erl-send `[rex ,node]
`[,erl-self [call
code ensure_loaded (distel)
,(erl-group-leader)]])
- (erl-receive (node rpc)
+ (erl-receive (node)
((['rex ['error _]]
- (&erl-load-backend node rpc))
- (_ (erl-backend-loaded node rpc)))))))
+ (&erl-load-backend node))
+ (_ t))))))
(defvar distel-ebin-directory
(file-truename
@@ -176,7 +178,7 @@ RPC is an apply'able argument list for `erl-rpc'."
(or (locate-library "distel") load-file-name)) "../ebin"))
"Directory where beam files are located.")
-(defun &erl-load-backend (node rpc)
+(defun &erl-load-backend (node)
(let ((modules '()))
(dolist (file (directory-files distel-ebin-directory))
(when (string-match "^\\(.*\\)\\.beam$" file)
@@ -185,12 +187,12 @@ RPC is an apply'able argument list for `erl-rpc'."
(push (list module filename) modules))))
(if (null modules)
(erl-warn-backend-problem "don't have beam files")
- (&erl-load-backend-modules node modules rpc))))
+ (&erl-load-backend-modules node modules))))
-(defun &erl-load-backend-modules (node modules rpc)
+(defun &erl-load-backend-modules (node modules)
+ (message "loading = %S" (car modules))
(if (null modules)
- (progn (message "(Successfully uploaded backend modules into node)")
- (erl-backend-loaded node rpc))
+ (message "(Successfully uploaded backend modules into node)")
(let* ((module (caar modules))
(filename (cadar modules))
(content (erl-file-to-string filename))
@@ -199,15 +201,11 @@ RPC is an apply'able argument list for `erl-rpc'."
`[,erl-self [call
code load_binary ,(list module filename binary)
,(erl-group-leader)]])
- (erl-receive (node modules rpc)
+ (erl-receive (node modules)
((['rex ['error reason]]
(erl-warn-backend-problem reason))
(['rex _]
- (&erl-load-backend-modules node (rest modules) rpc)))))))
-
-(defun erl-backend-loaded (node rpc)
- (derl-distel-available node)
- (when rpc (apply 'erl-rpc rpc)))
+ (&erl-load-backend-modules node (rest modules))))))))
(defun erl-warn-backend-problem (reason)
(with-current-buffer (get-buffer-create "*Distel Warning*")
@@ -245,12 +243,9 @@ To disable this warning in future, set `distel-inhibit-backend-check' to t.
"Call {M,F,A} on NODE and deliver the result to the function K.
The first argument to K is the result from the RPC, followed by the
elements of KARGS."
- (if (or (derl-distel-available-p node) distel-inhibit-backend-check)
- (erl-spawn
- (erl-send-rpc node m f a)
- (erl-rpc-receive k kargs))
- (let ((rpc (list k kargs node m f a)))
- (erl-load-backend node rpc))))
+ (erl-spawn
+ (erl-send-rpc node m f a)
+ (erl-rpc-receive k kargs)))
(defun erl-send-rpc (node mod fun args)
"Send an RPC request on NODE to apply(MOD, FUN, ARGS).
View
20 src/distel.erl
@@ -361,11 +361,11 @@ fprof_process_info({initial_calls, Calls}) ->
fprof_process_info(Info) ->
fmt(" ???: ~p~n", [Info]).
-fprof_tag({M,F,A}) when integer(A) ->
+fprof_tag({M,F,A}) when is_integer(A) ->
to_atom(fmt("~p:~p/~p", [M,F,A]));
-fprof_tag({M,F,A}) when list(A) ->
+fprof_tag({M,F,A}) when is_list(A) ->
fprof_tag({M,F,length(A)});
-fprof_tag(Name) when atom(Name) ->
+fprof_tag(Name) when is_atom(Name) ->
Name.
fprof_mfa({M,F,A}) -> [M,F,A];
@@ -381,14 +381,14 @@ fprof_tags(C) -> [fprof_tag(Name) || {Name,_,_,_} <- C].
fprof_beamfile({M,_,_}) ->
case code:which(M) of
- Fname when list(Fname) ->
+ Fname when is_list(Fname) ->
to_bin(Fname);
_ ->
undefined
end;
fprof_beamfile(_) -> undefined.
-pad(X, A) when atom(A) ->
+pad(X, A) when is_atom(A) ->
pad(X, to_list(A));
pad(X, S) when length(S) < X ->
S ++ duplicate(X - length(S), $ );
@@ -586,7 +586,7 @@ attach_loop(Att = #attach{emacs=Emacs, meta=Meta}) ->
where={Mod, Line},
stack={Pos, Pos}},
?MODULE:attach_loop(attach_goto(Att1,Att1#attach.where));
- {Meta, Status} when atom(Status) ->
+ {Meta, Status} when is_atom(Status) ->
Emacs ! {status, Status},
?MODULE:attach_loop(Att#attach{status=Status,where=undefined});
{NewMeta, {exit_at,null,_R,Pos}} when is_pid(NewMeta) ->
@@ -801,7 +801,7 @@ fdoc_binaryify(Other) -> Other.
%% Get the argument lists for a function in a module.
%% Return: [Arglist]
%% Arglist = [string()]
-get_arglists(ModName, FunName) when list(ModName), list(FunName) ->
+get_arglists(ModName, FunName) when is_list(ModName), is_list(FunName) ->
arglists(to_atom(ModName), FunName).
arglists(Mod, Fun) ->
@@ -867,7 +867,7 @@ get_forms_from_src(Mod) ->
%% Return the name of the beamfile for Mod.
beamfile(Mod) ->
case code:which(Mod) of
- File when list(File) ->
+ File when is_list(File) ->
{ok, File};
_ ->
error
@@ -919,13 +919,13 @@ best_arg(Args) ->
%% 'unknown' useless, type description is better, variable name is best.
best_arg(unknown, A2) -> A2;
best_arg(A1, unknown) -> A1;
-best_arg(A1, A2) when atom(A1),atom(A2) ->
+best_arg(A1, A2) when is_atom(A1),is_atom(A2) ->
%% ... and the longer the variable name the better
case length(to_list(A2)) > length(to_list(A1)) of
true -> A2;
false -> A1
end;
-best_arg(A1, _A2) when atom(A1) -> A1;
+best_arg(A1, _A2) when is_atom(A1) -> A1;
best_arg(_A1, A2) -> A2.
%% transpose([[1,2],[3,4],[5,6]]) -> [[1,3,5],[2,4,6]]
View
2  src/distel_ie.erl
@@ -222,7 +222,7 @@ add_remote_call_info([{tuple, L, Values} | Rs], Defs) ->
[{tuple, L, lists:map(F, Values)} | add_remote_call_info(Rs, Defs)] ;
-add_remote_call_info([{Type, L, Hdr, Body} | Rs], Defs) when list(Body) ->
+add_remote_call_info([{Type, L, Hdr, Body} | Rs], Defs) when is_list(Body) ->
B = add_remote_call_info(Body, Defs),
[{Type, L, Hdr, B} | add_remote_call_info(Rs, Defs)] ;
Please sign in to comment.
Something went wrong with that request. Please try again.