1
%% ``The contents of this file are subject to the Erlang Public License,
4
%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
2
7
%% Version 1.1, (the "License"); you may not use this file except in
3
8
%% compliance with the License. You should have received a copy of the
4
9
%% Erlang Public License along with this software. If not, it can be
5
%% retrieved via the world wide web at http://www.erlang.org/.
10
%% retrieved online at http://www.erlang.org/.
7
12
%% Software distributed under the License is distributed on an "AS IS"
8
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
14
%% the License for the specific language governing rights and limitations
10
15
%% under the License.
12
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
%% AB. All Rights Reserved.''
58
59
-export([init/1,handle_call/3,handle_cast/2,handle_info/2,
59
60
terminate/2, code_change/3]).
61
%%------------------------------------------------------------------------
63
-type(node() :: atom()).
64
-type(timeout() :: 'infinity' | non_neg_integer()).
63
-export([proxy_user_flush/0]).
66
65
%%------------------------------------------------------------------------
68
67
%% Remote execution and broadcasting facility
70
70
start() -> gen_server:start({local,?NAME},?MODULE,[],[]).
71
71
start_link() -> gen_server:start_link({local,?NAME},?MODULE,[],[]).
184
184
group_leader(Gleader, self());
185
185
set_group_leader(user) ->
186
186
%% For example, hidden C nodes doesn't want any I/O.
187
Gleader = case whereis(user) of
188
Pid when is_pid(Pid) -> Pid;
189
undefined -> proxy_user()
191
group_leader(Gleader, self()).
194
%% The 'rex_proxy_user' process serve as group leader for early rpc's that
195
%% may do IO before the real group leader 'user' has been started (OTP-7903).
197
case whereis(rex_proxy_user) of
198
Pid when is_pid(Pid) -> Pid;
200
Pid = spawn(fun()-> proxy_user_loop() end),
201
try register(rex_proxy_user,Pid) of
203
catch error:_ -> % spawn race, kill and try again
210
%% Wait for the real 'user' to start
187
212
case whereis(user) of
188
Pid when is_pid(Pid) -> group_leader(Pid, self());
213
Pid when is_pid(Pid) -> proxy_user_flush();
214
undefined -> proxy_user_loop()
217
proxy_user_flush() ->
218
%% Forward all received messages to 'user'
222
%% Hibernate but live for ever, as it's not easy to know
223
%% when no more messages will arrive.
224
erlang:hibernate(?MODULE, proxy_user_flush, [])
193
230
%% THE rpc client interface
497
534
parallel_eval(ArgL) ->
498
535
Nodes = [node() | nodes()],
499
536
Keys = map_nodes(ArgL,Nodes,Nodes),
500
lists:map(fun yield/1,Keys).
537
[yield(K) || K <- Keys].
502
539
map_nodes([],_,_) -> [];
503
540
map_nodes(ArgL,[],Original) ->