Closed leonlee2013 closed 1 year ago
I found that there was also a problem with erpc:cast/4, I fixed it
I used otp_24.1.6 for testing
$ erl -name erl-go_node1@127.0.0.1 -setcookie go_erlang_cookie
Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]
Eshell V12.1.5 (abort with ^G)
(erl-go_node1@127.0.0.1)1> erpc:cast('go_node1@127.0.0.1', testMod, testFun, [1,23,4545]).
ok
erlang lib:
%%otp_24.1.6 kernel-8.1.3/src/rpc.erl
%%call
-ifdef(SERVER_SIDE_ERPC_IS_MANDATORY).
call(N,M,F,A,T) ->
?RPCIFY(erpc:call(N, M, F, A, T)).
-else. %% ! defined SERVER_SIDE_ERPC_IS_MANDATORY
call(N,M,F,A,T) ->
DL = try
deadline(T)
catch
error:_ ->
error(badarg)
end,
case ?RPCIFY(erpc:call(N, M, F, A, T)) of
{badrpc, notsup} ->
case time_left(DL) of
0 ->
{badrpc, timeout};
Timeout ->
do_srv_call(N, {call,M,F,A,group_leader()}, Timeout)
end;
Res ->
Res
end.
-endif. %% ! defined SERVER_SIDE_ERPC_IS_MANDATORY
%%cast
-ifdef(SERVER_SIDE_ERPC_IS_MANDATORY).
cast(Node, Mod, Fun, Args) ->
try
ok = erpc:cast(Node, Mod, Fun, Args)
catch
error:{erpc, badarg} ->
error(badarg)
end,
true.
-else.
cast(Node, Mod, Fun, Args) when is_atom(Node),
is_atom(Mod),
is_atom(Fun),
is_list(Args) ->
_ = case node_has_feature(Node, erpc) of
false ->
gen_server:cast({?NAME,Node},
{cast,Mod,Fun,Args,group_leader()});
true ->
try
ok = erpc:cast(Node, Mod, Fun, Args)
catch
error:{erpc, badarg} ->
error(badarg)
end
end,
true;
cast(_, _, _, _) ->
error(badarg).
-endif.
erpc/rpc
rpc:call/4 = erpc:call/4 -> dist: dist:distProtoSPAWN_REQUEST
rpc:cast/4 -> dist:distProtoREG_SEND
erpc:cast/4 -> dist:distProtoSPAWN_REQUEST
Erlang project has rpc:call/4, rpc:cast/4, need ergo to be compatible。 I tried to fix the bug that rpc:call/4, rpc:cast/4 from Erlang to Ergo does not work. https://github.com/leonlee2013/ergo/commit/a98e83493f99f4682ce93e19a5e3674d43e02936 https://github.com/leonlee2013/ergo/commit/d9db4bc2ed7677767f91622d98967b211151f5ad
Here is the test code:
Erlang input and output:
Log output of Go
Looking forward to your review and merge!!!