Permalink
Browse files

Merge branch 'anders/diameter/peer_mapping/OTP-10470' into maint

* anders/diameter/peer_mapping/OTP-10470:
  Document peer_ref() service_info
  Use peer_ref() service_info in traffic suite
  Add service_info for a peer_ref()
  • Loading branch information...
Anders Svensson
Anders Svensson committed Nov 8, 2012
2 parents cedda10 + e18806d commit 3a86578f9750b27ab8a42eb8880cef082e9fcec7
@@ -1212,6 +1212,12 @@ DPA or timeout.</p>
<desc>
<p>
Return information about a started service.
+Requesting info for an unknown service causes <c>undefined</c> to be
+returned.
+Requesting a list of items causes a tagged list to be
+returned.</p>
+
+<p>
<c>Item</c> can be one of the following.</p>
<taglist>
@@ -1482,13 +1488,27 @@ The Diameter-level statistics returned by <c>transport</c> and
<c>connections</c> info are based upon these entries.</p>
</item>
-</taglist>
-
+<tag><c><seealso marker="diameter_app#peer_ref">diameter_app:peer_ref()</seealso></c></tag>
+<item>
<p>
-Requesting info for an unknown service causes <c>undefined</c> to be
-returned.
-Requesting a list of items causes a tagged list to be
-returned.</p>
+Return transport configuration associated with a single peer, as
+passed to <seealso marker="#add_transport">add_transport/2</seealso>.
+The returned list is empty if the peer is unknown.
+Otherwise it contains the <c>ref</c>, <c>type</c> and <c>options</c>
+tuples as in <c>transport</c> and <c>connections</c> info above.
+For example:</p>
+
+<code>
+[{ref,#Ref&lt;0.0.0.61>},
+ {type,accept},
+ {options,[{transport_module,diameter_tcp},
+ {transport_config,[{reuseaddr,true},
+ {ip,{127,0,0,1}},
+ {port,3868}]}]}]
+</code>
+</item>
+
+</taglist>
<marker id="services"/>
</desc>
@@ -3051,6 +3051,19 @@ tagged_info(Item, S)
undefined
end;
+tagged_info(TPid, #state{peerT = PT, connT = CT})
+ when is_pid(TPid) ->
+ try
+ [#conn{peer = Pid}] = ets:lookup(CT, TPid),
+ [#peer{ref = Ref, type = Type, options = Opts}] = ets:lookup(PT, Pid),
+ [{ref, Ref},
+ {type, Type},
+ {options, Opts}]
+ catch
+ error:_ ->
+ []
+ end;
+
tagged_info(Items, S)
when is_list(Items) ->
[T || I <- Items, T <- [tagged_info(I,S)], T /= undefined, T /= []];
@@ -626,22 +626,13 @@ pick_peer(Peers, _, ?CLIENT, _State, send_detach, Id, {_,_}) ->
find(Id, Peers).
find(Id, Peers) ->
- [P] = lists:flatmap(fun(C) -> peer(Id, C) end,
- diameter:service_info(?CLIENT, transport)),
- case lists:keyfind(P, 1, Peers) of %% OTP-10470 will provide a better way.
- {_,_} = TC ->
- {ok, TC};
- false = No ->
- No
- end.
+ [P] = [P || P <- Peers, id(Id, P)],
+ {ok, P}.
-peer(Id, [{ref, _},
- {type, connect},
- {options, Opts},
- {watchdog, _},
- {peer, {PeerRef, _}}
- | _]) ->
- [PeerRef || lists:member({id, Id}, Opts)].
+id(Id, {Pid, _Caps}) ->
+ [{ref, _}, {type, _}, {options, Opts} | _]
+ = diameter:service_info(?CLIENT, Pid),
+ lists:member({id, Id}, Opts).
%% prepare_request/5-6

0 comments on commit 3a86578

Please sign in to comment.