aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2017-08-07 15:35:11 +0200
committerAnders Svensson <[email protected]>2017-08-10 11:16:00 +0200
commit05e1764c1f7d079b5432bff11a792cdb31b00dcd (patch)
tree75c5f382c34373597f293546ee9fe3a3a7aec21d /lib/diameter
parent64e0dbd8f002d076f5d6c079f9166840c5fb17e3 (diff)
downloadotp-05e1764c1f7d079b5432bff11a792cdb31b00dcd.tar.gz
otp-05e1764c1f7d079b5432bff11a792cdb31b00dcd.tar.bz2
otp-05e1764c1f7d079b5432bff11a792cdb31b00dcd.zip
Don't update diameter_tcp state unnecessarily
Only reset the fragment after all messages have been extracted.
Diffstat (limited to 'lib/diameter')
-rw-r--r--lib/diameter/src/transport/diameter_tcp.erl22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/diameter/src/transport/diameter_tcp.erl b/lib/diameter/src/transport/diameter_tcp.erl
index e6168652de..ead4e7e72a 100644
--- a/lib/diameter/src/transport/diameter_tcp.erl
+++ b/lib/diameter/src/transport/diameter_tcp.erl
@@ -598,11 +598,12 @@ t(T,S) ->
%% Incoming packets.
transition({P, Sock, Bin}, #transport{socket = Sock,
- ssl = B}
+ ssl = B,
+ frag = Frag}
= S)
when P == ssl, true == B;
P == tcp ->
- recv(Bin, S#transport{active = false});
+ recv(acc(Frag, Bin), S#transport{active = false});
%% Capabilties exchange has decided on whether or not to run over TLS.
transition({diameter, {tls, Ref, Type, B}}, #transport{parent = Pid}
@@ -719,14 +720,13 @@ tls(accept, Sock, Opts) ->
%% using Nagle.
%% Receive packets until a full message is received,
-recv(Bin, #transport{frag = Head} = S) ->
- case acc(Head, Bin) of
- {Msg, B} -> %% have a complete message ...
- message(recv, Msg, S#transport{frag = B});
- Frag -> %% read more on the socket
- start_fragment_timer(setopts(S#transport{frag = Frag,
- flush = false}))
- end.
+
+recv({Msg, Rest}, S) -> %% have a complete message ...
+ recv(acc(Rest), message(recv, Msg, S));
+
+recv(Frag, S) -> %% or not
+ start_fragment_timer(setopts(S#transport{frag = Frag,
+ flush = false})).
%% acc/2
@@ -962,7 +962,7 @@ message(ack, _, #transport{message_cb = false} = S) ->
S;
message(Dir, Msg, #transport{message_cb = CB} = S) ->
- recv(<<>>, actions(cb(CB, Dir, Msg), Dir, S)).
+ setopts(actions(cb(CB, Dir, Msg), Dir, S)).
%% actions/3