diff options
author | Anders Svensson <[email protected]> | 2016-05-04 23:27:02 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2016-05-04 23:46:38 +0200 |
commit | 18449b6bd35be4ad66ea7874a397029c8c920629 (patch) | |
tree | 6e716a900d5ee1d72f1a1fdac9874afed8dd6421 /lib/diameter/src/base/diameter_peer_fsm.erl | |
parent | 2adc2c2385e849c5f5b55240cbf7b0e66d364e5c (diff) | |
download | otp-18449b6bd35be4ad66ea7874a397029c8c920629.tar.gz otp-18449b6bd35be4ad66ea7874a397029c8c920629.tar.bz2 otp-18449b6bd35be4ad66ea7874a397029c8c920629.zip |
Add diameter:peer_find/1
To return a peer_fsm/transport pair given one of them.
Diffstat (limited to 'lib/diameter/src/base/diameter_peer_fsm.erl')
-rw-r--r-- | lib/diameter/src/base/diameter_peer_fsm.erl | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/diameter/src/base/diameter_peer_fsm.erl b/lib/diameter/src/base/diameter_peer_fsm.erl index 2b23183d18..cdc97775eb 100644 --- a/lib/diameter/src/base/diameter_peer_fsm.erl +++ b/lib/diameter/src/base/diameter_peer_fsm.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2010-2015. All Rights Reserved. +%% Copyright Ericsson AB 2010-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -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, |