aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorZandra <[email protected]>2016-04-22 15:37:50 +0200
committerZandra <[email protected]>2016-05-02 14:43:32 +0200
commitfe1fe6b2ca2ebefd0b7e82b6651e35f6388a06d0 (patch)
tree8a6dbb09c47642aa040e2b980d9472ad178d97b3 /lib
parent42a1166b47721cd444dbe8c70a04125d842a27c9 (diff)
downloadotp-fe1fe6b2ca2ebefd0b7e82b6651e35f6388a06d0.tar.gz
otp-fe1fe6b2ca2ebefd0b7e82b6651e35f6388a06d0.tar.bz2
otp-fe1fe6b2ca2ebefd0b7e82b6651e35f6388a06d0.zip
let the spawned processes handle rpc replies
This decreases the load on the rex server.
Diffstat (limited to 'lib')
-rw-r--r--lib/kernel/src/rpc.erl25
-rw-r--r--lib/runtime_tools/test/dbg_SUITE.erl4
2 files changed, 7 insertions, 22 deletions
diff --git a/lib/kernel/src/rpc.erl b/lib/kernel/src/rpc.erl
index 6f9ce17c0c..ee71d39253 100644
--- a/lib/kernel/src/rpc.erl
+++ b/lib/kernel/src/rpc.erl
@@ -130,30 +130,16 @@ handle_cast(_, S) ->
-spec handle_info(term(), state()) -> {'noreply', state()}.
+handle_info({'DOWN', _, process, Caller, normal}, S) ->
+ {noreply, gb_trees:delete(Caller, S)};
handle_info({'DOWN', _, process, Caller, Reason}, S) ->
case gb_trees:lookup(Caller, S) of
- {value, To} ->
- receive
- {Caller, {reply, Reply}} ->
- gen_server:reply(To, Reply)
- after 0 ->
- gen_server:reply(To, {badrpc, {'EXIT', Reason}})
- end,
+ {value, To} ->
+ gen_server:reply(To, {badrpc, {'EXIT', Reason}}),
{noreply, gb_trees:delete(Caller, S)};
none ->
{noreply, S}
end;
-handle_info({Caller, {reply, Reply}}, S) ->
- case gb_trees:lookup(Caller, S) of
- {value, To} ->
- receive
- {'DOWN', _, process, Caller, _} ->
- gen_server:reply(To, Reply),
- {noreply, gb_trees:delete(Caller, S)}
- end;
- none ->
- {noreply, S}
- end;
handle_info({From, {sbcast, Name, Msg}}, S) ->
_ = case catch Name ! Msg of %% use catch to get the printout
{'EXIT', _} ->
@@ -190,7 +176,6 @@ code_change(_, S, _) ->
%% Auxiliary function to avoid a false dialyzer warning -- do not inline
%%
handle_call_call(Mod, Fun, Args, Gleader, To, S) ->
- RpcServer = self(),
%% Spawn not to block the rpc server.
{Caller,_} =
erlang:spawn_monitor(
@@ -205,7 +190,7 @@ handle_call_call(Mod, Fun, Args, Gleader, To, S) ->
Result ->
Result
end,
- RpcServer ! {self(), {reply, Reply}}
+ gen_server:reply(To, Reply)
end),
{noreply, gb_trees:insert(Caller, To, S)}.
diff --git a/lib/runtime_tools/test/dbg_SUITE.erl b/lib/runtime_tools/test/dbg_SUITE.erl
index 17c04c0ed4..04430263b4 100644
--- a/lib/runtime_tools/test/dbg_SUITE.erl
+++ b/lib/runtime_tools/test/dbg_SUITE.erl
@@ -202,8 +202,8 @@ distributed(Config) when is_list(Config) ->
?line {value, {matched, Node, 1}} = lists:keysearch(Node, 2, Z),
?line dbg:cn(Node),
?line dbg:tp(dbg,ln,[]),
- ?line ok = rpc:call(Node, dbg, ltp, []),
- ?line ok = rpc:call(Node, dbg, ln, []),
+ ?line ok = rpc:block_call(Node, dbg, ltp, []),
+ ?line ok = rpc:block_call(Node, dbg, ln, []),
?line ok = dbg:ln(),
?line S = self(),
?line {TraceSend, TraceCall} =