diff options
author | Anders Svensson <[email protected]> | 2012-08-26 02:55:41 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2012-08-26 11:30:24 +0200 |
commit | 158d95e6b8575be8983ae6024ffa85c639ecdfda (patch) | |
tree | 24b86fd8dfabbe9a6be20fad915adde6e98f14ea /lib | |
parent | 2c6efd882cb748abbd7f4bea696d8d6211ea5ffa (diff) | |
download | otp-158d95e6b8575be8983ae6024ffa85c639ecdfda.tar.gz otp-158d95e6b8575be8983ae6024ffa85c639ecdfda.tar.bz2 otp-158d95e6b8575be8983ae6024ffa85c639ecdfda.zip |
Make service_info behave with nested item lists and non-atoms
Diffstat (limited to 'lib')
-rw-r--r-- | lib/diameter/src/base/diameter_service.erl | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/lib/diameter/src/base/diameter_service.erl b/lib/diameter/src/base/diameter_service.erl index ad5a853a0d..6aff03ec1d 100644 --- a/lib/diameter/src/base/diameter_service.erl +++ b/lib/diameter/src/base/diameter_service.erl @@ -2812,14 +2812,33 @@ transports(#state{peerT = PeerT}) -> peers, statistics]). -service_info(Items, S) - when is_list(Items) -> - [{complete(I), service_info(I,S)} || I <- Items]; service_info(Item, S) when is_atom(Item) -> - service_info(Item, S, true). + case tagged_info(Item, S) of + {_, T} -> T; + undefined = No -> No + end; + +service_info(Items, S) -> + tagged_info(Items, S). + +tagged_info(Item, S) + when is_atom(Item) -> + case complete(Item) of + {value, I} -> + {I, complete_info(I,S)}; + false -> + undefined + end; + +tagged_info(Items, S) + when is_list(Items) -> + [T || I <- Items, T <- [tagged_info(I,S)], T /= undefined, T /= []]; + +tagged_info(_, _) -> + undefined. -service_info(Item, #state{service = Svc} = S, Complete) -> +complete_info(Item, #state{service = Svc} = S) -> case Item of name -> S#state.service_name; @@ -2867,18 +2886,20 @@ service_info(Item, #state{service = Svc} = S, Complete) -> all -> service_info(?ALL_INFO, S); statistics -> info_stats(S); connections -> info_connections(S); - peers -> info_peers(S); - _ when Complete -> service_info(complete(Item), S, false); - _ -> undefined + peers -> info_peers(S) end. +complete(I) + when I == keys; + I == all -> + {value, I}; complete(Pre) -> P = atom_to_list(Pre), case [I || I <- ?ALL_INFO ++ ?CAP_INFO ++ ?OTHER_INFO, lists:prefix(P, atom_to_list(I))] of - [I] -> I; - _ -> Pre + [I] -> {value, I}; + _ -> false end. %% info_stats/1 |