|
@ -81,7 +81,7 @@ |
|
|
%%%========================================================================== |
|
|
%%%========================================================================== |
|
|
%%% Interface functions. |
|
|
%%% Interface functions. |
|
|
%%%========================================================================== |
|
|
%%%========================================================================== |
|
|
%% gen:call 发送消息来源进程格式类型 |
|
|
|
|
|
|
|
|
%% gen_call:call 发送消息来源进程格式类型 |
|
|
-type from() :: {To :: pid(), Tag :: term()}. |
|
|
-type from() :: {To :: pid(), Tag :: term()}. |
|
|
-type requestId() :: term(). |
|
|
-type requestId() :: term(). |
|
|
|
|
|
|
|
@ -504,63 +504,20 @@ format_status(Opt, [PDict, SysStatus, Parent, Debug, {Parent, Name, Module, Hibe |
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% API helpers start %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% API helpers start %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
|
-spec call(ServerRef :: serverRef(), Request :: term()) -> Reply :: term(). |
|
|
-spec call(ServerRef :: serverRef(), Request :: term()) -> Reply :: term(). |
|
|
call(ServerRef, Request) -> |
|
|
call(ServerRef, Request) -> |
|
|
try gen:call(ServerRef, '$gen_call', Request) of |
|
|
|
|
|
|
|
|
try gen_call:call(ServerRef, '$gen_call', Request) of |
|
|
{ok, Reply} -> |
|
|
{ok, Reply} -> |
|
|
Reply |
|
|
Reply |
|
|
catch Class:Reason -> |
|
|
catch Class:Reason -> |
|
|
erlang:raise(Class, {Reason, {?MODULE, call, [ServerRef, Request]}}, ?STACKTRACE()) |
|
|
erlang:raise(Class, {Reason, {?MODULE, call, [ServerRef, Request]}}, ?STACKTRACE()) |
|
|
end. |
|
|
end. |
|
|
|
|
|
|
|
|
-spec call(ServerRef :: serverRef(), Request :: term(), Timeout :: timeout() |{'clean_timeout', T :: timeout()} | {'dirty_timeout', T :: timeout()}) -> Reply :: term(). |
|
|
|
|
|
call(ServerRef, Request, infinity) -> |
|
|
|
|
|
try gen:call(ServerRef, '$gen_call', Request, infinity) of |
|
|
|
|
|
{ok, Reply} -> |
|
|
|
|
|
Reply |
|
|
|
|
|
catch Class:Reason -> |
|
|
|
|
|
erlang:raise(Class, {Reason, {?MODULE, call, [ServerRef, Request, infinity]}}, ?STACKTRACE()) |
|
|
|
|
|
end; |
|
|
|
|
|
call(ServerRef, Request, {dirty_timeout, T} = Timeout) -> |
|
|
|
|
|
try gen:call(ServerRef, '$gen_call', Request, T) of |
|
|
|
|
|
|
|
|
-spec call(ServerRef :: serverRef(), Request :: term(), Timeout :: timeout()) -> Reply :: term(). |
|
|
|
|
|
call(ServerRef, Request, Timeout) -> |
|
|
|
|
|
try gen_call:call(ServerRef, '$gen_call', Request, Timeout) of |
|
|
{ok, Reply} -> |
|
|
{ok, Reply} -> |
|
|
Reply |
|
|
Reply |
|
|
catch Class:Reason -> |
|
|
catch Class:Reason -> |
|
|
erlang:raise(Class, {Reason, {?MODULE, call, [ServerRef, Request, Timeout]}}, ?STACKTRACE()) |
|
|
|
|
|
end; |
|
|
|
|
|
call(ServerRef, Request, {clean_timeout, T} = Timeout) -> |
|
|
|
|
|
callClean(ServerRef, Request, Timeout, T); |
|
|
|
|
|
call(ServerRef, Request, {_, _} = Timeout) -> |
|
|
|
|
|
erlang:error(badarg, [ServerRef, Request, Timeout]); |
|
|
|
|
|
call(ServerRef, Request, Timeout) -> |
|
|
|
|
|
callClean(ServerRef, Request, Timeout, Timeout). |
|
|
|
|
|
|
|
|
|
|
|
callClean(ServerRef, Request, Timeout, T) -> |
|
|
|
|
|
%% 通过代理过程呼叫服务器以躲避任何较晚的答复 |
|
|
|
|
|
Ref = make_ref(), |
|
|
|
|
|
Self = self(), |
|
|
|
|
|
Pid = spawn( |
|
|
|
|
|
fun() -> |
|
|
|
|
|
Self ! |
|
|
|
|
|
try gen:call(ServerRef, '$gen_call', Request, T) of |
|
|
|
|
|
Result -> |
|
|
|
|
|
{Ref, Result} |
|
|
|
|
|
catch Class:Reason -> |
|
|
|
|
|
{Ref, Class, Reason, ?STACKTRACE()} |
|
|
|
|
|
end |
|
|
|
|
|
end), |
|
|
|
|
|
Mref = monitor(process, Pid), |
|
|
|
|
|
receive |
|
|
|
|
|
{Ref, Result} -> |
|
|
|
|
|
demonitor(Mref, [flush]), |
|
|
|
|
|
case Result of |
|
|
|
|
|
{ok, Reply} -> |
|
|
|
|
|
Reply |
|
|
|
|
|
end; |
|
|
|
|
|
{Ref, Class, Reason, Stacktrace} -> |
|
|
|
|
|
demonitor(Mref, [flush]), |
|
|
|
|
|
erlang:raise(Class, {Reason, {?MODULE, call, [ServerRef, Request, Timeout]}}, Stacktrace); |
|
|
|
|
|
{'DOWN', Mref, _, _, Reason} -> |
|
|
|
|
|
%% 从理论上讲,有可能在try-of和!之间杀死代理进程。因此,在这种情况下 |
|
|
|
|
|
exit(Reason) |
|
|
|
|
|
|
|
|
erlang:raise(Class, {Reason, {?MODULE, call, [ServerRef, Request]}}, ?STACKTRACE()) |
|
|
end. |
|
|
end. |
|
|
|
|
|
|
|
|
multi_call(Name, Request) when is_atom(Name) -> |
|
|
multi_call(Name, Request) when is_atom(Name) -> |
|
@ -577,9 +534,9 @@ multi_call(Nodes, Name, Request, Timeout) when is_list(Nodes), is_atom(Name), is |
|
|
do_multi_call([Node], Name, Req, infinity) when Node =:= node() -> |
|
|
do_multi_call([Node], Name, Req, infinity) when Node =:= node() -> |
|
|
% Special case when multi_call is used with local node only. |
|
|
% Special case when multi_call is used with local node only. |
|
|
% In that case we can leverage the benefit of recv_mark optimisation |
|
|
% In that case we can leverage the benefit of recv_mark optimisation |
|
|
% existing in simple gen:call. |
|
|
|
|
|
try gen:call(Name, '$gen_call', Req, infinity) of |
|
|
|
|
|
{ok, Res} -> {[{Node, Res}],[]} |
|
|
|
|
|
|
|
|
% existing in simple gen_call:call. |
|
|
|
|
|
try gen_call:call(Name, '$gen_call', Req, infinity) of |
|
|
|
|
|
{ok, Res} -> {[{Node, Res}], []} |
|
|
catch exit:_ -> |
|
|
catch exit:_ -> |
|
|
{[], [Node]} |
|
|
{[], [Node]} |
|
|
end; |
|
|
end; |
|
@ -881,7 +838,7 @@ info_notify(EpmSrv, Event) -> |
|
|
epmRequest(EpmSrv, {'$epm_info', '$infoNotify', Event}). |
|
|
epmRequest(EpmSrv, {'$epm_info', '$infoNotify', Event}). |
|
|
|
|
|
|
|
|
epmRpc(EpmSrv, Cmd) -> |
|
|
epmRpc(EpmSrv, Cmd) -> |
|
|
try gen:call(EpmSrv, '$epm_call', Cmd, infinity) of |
|
|
|
|
|
|
|
|
try gen_call:call(EpmSrv, '$epm_call', Cmd, infinity) of |
|
|
{ok, Reply} -> |
|
|
{ok, Reply} -> |
|
|
Reply |
|
|
Reply |
|
|
catch Class:Reason -> |
|
|
catch Class:Reason -> |
|
@ -889,7 +846,7 @@ epmRpc(EpmSrv, Cmd) -> |
|
|
end. |
|
|
end. |
|
|
|
|
|
|
|
|
epmRpc(EpmSrv, Cmd, Timeout) -> |
|
|
epmRpc(EpmSrv, Cmd, Timeout) -> |
|
|
try gen:call(EpmSrv, '$epm_call', Cmd, Timeout) of |
|
|
|
|
|
|
|
|
try gen_call:call(EpmSrv, '$epm_call', Cmd, Timeout) of |
|
|
{ok, Reply} -> |
|
|
{ok, Reply} -> |
|
|
Reply |
|
|
Reply |
|
|
catch Class:Reason -> |
|
|
catch Class:Reason -> |
|
|