diff options
author | Anders Svensson <[email protected]> | 2012-07-11 02:19:25 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2012-08-26 13:54:42 +0200 |
commit | 4b6328306abd9fd55c1d83169350c0fbd35a8e3b (patch) | |
tree | 4d8ba97f21498a88e8c20b58f6901959681b9786 /lib/diameter/src/base | |
parent | f430c8c706de300122d10c64b316d18917e176b3 (diff) | |
download | otp-4b6328306abd9fd55c1d83169350c0fbd35a8e3b.tar.gz otp-4b6328306abd9fd55c1d83169350c0fbd35a8e3b.tar.bz2 otp-4b6328306abd9fd55c1d83169350c0fbd35a8e3b.zip |
Don't let peer_up/peer_down take down the service process
This would previously have resulted in all of a service's connections
going down, especially bad for a server.
Diffstat (limited to 'lib/diameter/src/base')
-rw-r--r-- | lib/diameter/src/base/diameter_service.erl | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/diameter/src/base/diameter_service.erl b/lib/diameter/src/base/diameter_service.erl index c7b216c6f7..77f7c6dd8e 100644 --- a/lib/diameter/src/base/diameter_service.erl +++ b/lib/diameter/src/base/diameter_service.erl @@ -945,12 +945,15 @@ ilp({Id, Alias}, {TC, SA}, LDict) -> init_conn(Id, Alias, TC, SA), ?Dict:append(Alias, TC, LDict). -init_conn(Id, Alias, TC, {SvcName, Apps}) -> +init_conn(Id, Alias, {TPid, _} = TC, {SvcName, Apps}) -> #diameter_app{module = ModX, id = Id} %% assert = find_app(Alias, Apps), - peer_cb({ModX, peer_up, [SvcName, TC]}, Alias). + peer_cb({ModX, peer_up, [SvcName, TC]}, Alias) + orelse exit(TPid, kill). %% fake transport failure + +%% find_app/2 find_app(Alias, Apps) -> case lists:keyfind(Alias, #diameter_app.alias, Apps) of @@ -960,17 +963,17 @@ find_app(Alias, Apps) -> A end. -%% A failing peer callback brings down the service. In the case of -%% peer_up we could just kill the transport and emit an error but for -%% peer_down we have no way to cleanup any state change that peer_up -%% may have introduced. +%% Don't bring down the service (and all associated connections) +%% regardless of what happens. peer_cb(MFA, Alias) -> try state_cb(MFA, Alias) of ModS -> - mod_state(Alias, ModS) + mod_state(Alias, ModS), + true catch - E: Reason -> - ?ERROR({E, Reason, MFA, ?STACK}) + E:R -> + diameter_lib:error_report({failure, {E, R, Alias, ?STACK}}, MFA), + false end. %%% --------------------------------------------------------------------------- |