aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2017-08-29 22:26:51 +0200
committerAnders Svensson <[email protected]>2017-08-29 22:29:49 +0200
commita3749fd240260958053f90539b0f7e04e720d070 (patch)
treef9ec8c915f45db72a232d2fba46e32a3d03e2f1b /lib/diameter
parent1fd9b919608b54e4d08340c45fe1cabb6975880c (diff)
downloadotp-a3749fd240260958053f90539b0f7e04e720d070.tar.gz
otp-a3749fd240260958053f90539b0f7e04e720d070.tar.bz2
otp-a3749fd240260958053f90539b0f7e04e720d070.zip
Send unordered on all outbound diameter_sctp streams
There's no reason for sending ordered since request handling is concurrent: different processes handling incoming requests can't know in which order they were received on the transport, and different processes sending requests can't know the order in which they're sent.
Diffstat (limited to 'lib/diameter')
-rw-r--r--lib/diameter/src/transport/diameter_sctp.erl26
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/diameter/src/transport/diameter_sctp.erl b/lib/diameter/src/transport/diameter_sctp.erl
index 86a98776c5..2af11729a9 100644
--- a/lib/diameter/src/transport/diameter_sctp.erl
+++ b/lib/diameter/src/transport/diameter_sctp.erl
@@ -102,10 +102,10 @@
streams :: {uint(), uint()} %% {InStream, OutStream} counts
| undefined,
os = 0 :: uint(), %% next output stream
+ rotate = 1 :: boolean() | 0 | 1, %% rotate os?
packet = true :: boolean() %% legacy transport_data?
| raw,
message_cb = false :: false | diameter:eval(),
- unordered = 1 :: boolean() | 0 | 1, %% send unordered?
send = false :: pid() | boolean()}). %% sending process
%% Monitor process state.
@@ -678,14 +678,14 @@ send(#diameter_packet{transport_data = {outstream, SId}}
= S) ->
send(SId rem OS, Msg, S);
-%% ... or not: rotate when sending ordered ...
-send(Msg, #transport{unordered = false,
+%% ... or not: rotate when sending on multiple streams ...
+send(Msg, #transport{rotate = true,
streams = {_, OS},
os = N}
= S) ->
send(N, Msg, S#transport{os = (N + 1) rem OS});
-%% ... or send only on the first stream, possibly unordered.
+%% ... or send on the only stream available.
send(Msg, S) ->
send(0, Msg, S).
@@ -777,24 +777,20 @@ recv({_, #sctp_pdapi_event{}}, _) ->
%% recv/1
%%
-%% Start sending unordered on a lone outbound stream after the second
-%% reception, so that an outgoing CER/CEA will arrive at the peer
-%% before another request.
+%% Start sending unordered after the second reception, so that an
+%% outgoing CER/CEA will arrive at the peer before another request.
-recv(#transport{unordered = B} = S)
+recv(#transport{rotate = B} = S)
when is_boolean(B) ->
S;
-recv(#transport{unordered = 0, streams = {_, 1}, socket = Sock} = S) ->
+recv(#transport{rotate = 0, streams = {_,N}, socket = Sock} = S) ->
ok = inet:setopts(Sock, [{sctp_default_send_param,
#sctp_sndrcvinfo{flags = [unordered]}}]),
- S#transport{unordered = true};
+ S#transport{rotate = 1 < N};
-recv(#transport{unordered = 0} = S) ->
- S#transport{unordered = false};
-
-recv(#transport{unordered = N} = S) ->
- S#transport{unordered = N-1}.
+recv(#transport{rotate = N} = S) ->
+ S#transport{rotate = N-1}.
%% publish/4