LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File gen_rpc-2.1.0-git.patch of Package gen_rpc (Project home:Ledest:erlang:20)

diff --git a/.travis.yml b/.travis.yml
index 697727f..3ebe762 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,9 +2,11 @@ sudo: false
 language: erlang
 otp_release:
   - "19.1"
+  - "19.2"
 cache:
   directories:
   - $HOME/otp/19.1
+  - $HOME/otp/19.2
   - $HOME/.cache/rebar3
   - _plt
 install: "true"
diff --git a/src/gen_rpc_acceptor.erl b/src/gen_rpc_acceptor.erl
index 22296fd..4cc0bd0 100644
--- a/src/gen_rpc_acceptor.erl
+++ b/src/gen_rpc_acceptor.erl
@@ -157,17 +157,30 @@ waiting_for_data(info, {Driver,Socket,Data},
             ok = DriverMod:activate_socket(Socket),
             {keep_state_and_data, gen_rpc_helper:get_inactivity_timeout(?MODULE)};
         {abcast, Name, Msg} ->
-            ?log(debug, "event=abcast_received driver=~s socket=\"~s\" peer=\"~s\" process=~s message=\"~p\"",
-                 [Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer), Name, Msg]),
-            Msg = erlang:send(Name, Msg),
+            _Result = case check_if_module_allowed(erlang, Control, List) of
+                true ->
+                    ?log(debug, "event=abcast_received driver=~s socket=\"~s\" peer=\"~s\" process=~s message=\"~p\"",
+                         [Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer), Name, Msg]),
+                    Msg = erlang:send(Name, Msg);
+                false ->
+                    ?log(debug, "event=request_not_allowed driver=~s socket=\"~s\" control=~s method=~s",
+                         [Driver, gen_rpc_helper:socket_to_string(Socket), Control, abcast])
+                end,
             ok = DriverMod:activate_socket(Socket),
             {keep_state_and_data, gen_rpc_helper:get_inactivity_timeout(?MODULE)};
         {sbcast, Name, Msg, Caller} ->
-            ?log(debug, "event=sbcast_received driver=~s socket=\"~s\" peer=\"~s\" process=~s message=\"~p\"",
-                 [Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer), Name, Msg]),
-            Reply = case erlang:whereis(Name) of
-                undefined -> error;
-                Pid -> Msg = erlang:send(Pid, Msg), success
+            Reply = case check_if_module_allowed(erlang, Control, List) of
+                true ->
+                    ?log(debug, "event=sbcast_received driver=~s socket=\"~s\" peer=\"~s\" process=~s message=\"~p\"",
+                         [Driver, gen_rpc_helper:socket_to_string(Socket), gen_rpc_helper:peer_to_string(Peer), Name, Msg]),
+                    case erlang:whereis(Name) of
+                        undefined -> error;
+                        Pid -> Msg = erlang:send(Pid, Msg), success
+                    end;
+                false ->
+                    ?log(debug, "event=request_not_allowed driver=~s socket=\"~s\" control=~s method=~s",
+                         [Driver, gen_rpc_helper:socket_to_string(Socket), Control, sbcast]),
+                     error
             end,
             ok = DriverMod:activate_socket(Socket),
             waiting_for_data(info, {sbcast, Caller, Reply}, State);
diff --git a/src/gen_rpc_server.erl b/src/gen_rpc_server.erl
index 3e6a0ac..e97ea70 100644
--- a/src/gen_rpc_server.erl
+++ b/src/gen_rpc_server.erl
@@ -51,6 +51,7 @@ stop(Driver) when is_atom(Driver) ->
 %%% ===================================================
 init({Driver}) ->
     ok = gen_rpc_helper:set_optimal_process_flags(),
+    _ = erlang:process_flag(trap_exit, false),
     {DriverMod, DriverPort, _ClosedMsg, _ErrorMsg} = gen_rpc_helper:get_server_driver_options(Driver),
     case DriverMod:listen(DriverPort) of
         {ok, Socket} ->
diff --git a/test/ct/local_SUITE.erl b/test/ct/local_SUITE.erl
index 314ac0f..faaa84f 100644
--- a/test/ct/local_SUITE.erl
+++ b/test/ct/local_SUITE.erl
@@ -316,6 +316,8 @@ rpc_module_whitelist(_Config) ->
 rpc_module_blacklist(_Config) ->
     {badrpc, unauthorized} = gen_rpc:call(?MASTER, os, timestamp),
     {badrpc, unauthorized} = gen_rpc:call(?MASTER, erlang, node),
+    abcast = gen_rpc:abcast([?MASTER], init, {stop, stop}),
+    {[], [?MASTER]} = gen_rpc:sbcast([?MASTER], init, {stop, stop}),
     60000 = gen_rpc:call(?MASTER, timer, seconds, [60]).
 
 driver_stub(_Config) ->