aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base/diameter_peer_fsm.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2016-05-09 16:13:24 +0200
committerAnders Svensson <[email protected]>2016-05-09 16:13:24 +0200
commitf46d8a7f862a3f634b16c90426cb8601001c9de4 (patch)
tree2ddcec874fcd2fcab770f742b8b21ce12279cf37 /lib/diameter/src/base/diameter_peer_fsm.erl
parenta3f49cfc599bc3edda886cc6e895b442506ee6cc (diff)
parent18449b6bd35be4ad66ea7874a397029c8c920629 (diff)
downloadotp-f46d8a7f862a3f634b16c90426cb8601001c9de4.tar.gz
otp-f46d8a7f862a3f634b16c90426cb8601001c9de4.tar.bz2
otp-f46d8a7f862a3f634b16c90426cb8601001c9de4.zip
Merge branch 'anders/diameter/info/OTP-13508'
* anders/diameter/info/OTP-13508: Add diameter:peer_find/1 Add diameter:peer_info/1
Diffstat (limited to 'lib/diameter/src/base/diameter_peer_fsm.erl')
-rw-r--r--lib/diameter/src/base/diameter_peer_fsm.erl24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/diameter/src/base/diameter_peer_fsm.erl b/lib/diameter/src/base/diameter_peer_fsm.erl
index deb9404216..996e75a8d3 100644
--- a/lib/diameter/src/base/diameter_peer_fsm.erl
+++ b/lib/diameter/src/base/diameter_peer_fsm.erl
@@ -32,6 +32,9 @@
-export([start/3,
result_code/2]).
+%% Interface towards diameter.
+-export([find/1]).
+
%% gen_server callbacks
-export([init/1,
handle_call/3,
@@ -185,6 +188,25 @@ start_link(T) ->
infinity,
diameter_lib:spawn_opts(server, [])).
+%% find/1
+%%
+%% Identify both pids of a peer_fsm/transport pair.
+
+find(Pid) ->
+ findl([{?MODULE, '_', Pid}, {?MODULE, Pid, '_'}]).
+
+findl([]) ->
+ false;
+
+findl([Pat | Rest]) ->
+ try
+ [{{_, Pid, TPid}, Pid}] = diameter_reg:match(Pat),
+ {Pid, TPid}
+ catch
+ error:_ ->
+ findl(Rest)
+ end.
+
%% ---------------------------------------------------------------------------
%% ---------------------------------------------------------------------------
@@ -215,6 +237,8 @@ i({Ack, WPid, {M, Ref} = T, Opts, {SvcOpts, Nodes, Dict0, Svc}}) ->
{TPid, Addrs} = start_transport(T, Rest, Svc),
+ diameter_reg:add({?MODULE, self(), TPid}), %% lets pairs be discovered
+
#state{state = {'Wait-Conn-Ack', Tmo},
parent = WPid,
transport = TPid,