aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/test
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2016-05-18 14:39:32 +0200
committerAnders Svensson <[email protected]>2016-05-30 08:56:15 +0200
commit5ca5fb71695ccdf7267007b8405f7a13497a2f17 (patch)
treedf6fb7c7a1fa9138da443e68c3df80bf789219ca /lib/diameter/test
parent7d7271121b4d2e786bf6fb41508166efb96e5842 (diff)
downloadotp-5ca5fb71695ccdf7267007b8405f7a13497a2f17.tar.gz
otp-5ca5fb71695ccdf7267007b8405f7a13497a2f17.tar.bz2
otp-5ca5fb71695ccdf7267007b8405f7a13497a2f17.zip
Close listening sockets at transport removal
The transport interface documented in diameter_transport(3) is used to start/stop accepting/connecting transport processes: they're started with a function call, and told to die with their parent process. In the accepting case, both diameter_tcp and diameter_sctp start a listening process when the first accepting transport is started. However, there's no way for a listening process to find out that that it should stop listening when transport configuration is removed. Both diameter_tcp and diameter_sctp have used a timer to terminate the listening process after all existing accepting processes have died as a consequence of transport removal. The problem with this is that nothing stops a new client from connecting before this, and also that no new transport can succeed in opening the same listening port (eg. reconfiguration) until the old listener dies. This commit solves the problem by adding diameter_reg:subscribe/2, to allow callers to subscribe to messages about added/removed associations. A call to diameter:add_transport/2 results in a new child process that registers a term that a listening process subscribes to. Transport removal results in the death of the child, and the resulting notification to the listener causes the latter to close its socket and terminate. This is still an internal interface, but the subscription mechanism should probably be made external (eg. a diameter:subscribe/1 that can be used to subscribe to specified messages), so that transport modules other than diameter's own can make use of it. There is no support for soft upgrade.
Diffstat (limited to 'lib/diameter/test')
-rw-r--r--lib/diameter/test/diameter_transport_SUITE.erl6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/diameter/test/diameter_transport_SUITE.erl b/lib/diameter/test/diameter_transport_SUITE.erl
index 53d2d6660e..f2884eacb4 100644
--- a/lib/diameter/test/diameter_transport_SUITE.erl
+++ b/lib/diameter/test/diameter_transport_SUITE.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.
@@ -140,7 +140,9 @@ sctp_accept(Config) ->
-define(PEER_COUNT, 8).
accept(Prot) ->
- T = {Prot, make_ref()},
+ Ref = make_ref(),
+ true = diameter_reg:add_new({diameter_config, transport, Ref}), %% fake it
+ T = {Prot, Ref},
[] = ?util:run(?util:scramble(acc(2*?PEER_COUNT, T, []))).
acc(0, _, Acc) ->