diff options
author | Anders Svensson <[email protected]> | 2015-02-12 11:18:52 +0100 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2015-03-23 15:27:37 +0100 |
commit | 75ee72b4e1d288b1d96194d0e352eb0c73db4a6f (patch) | |
tree | fa4a5d0922b833807a50324863555f0b2e06f92d /lib/diameter/src/base/diameter_watchdog.erl | |
parent | deed57ed8da08e3262d61197da2ed00391b94be6 (diff) | |
download | otp-75ee72b4e1d288b1d96194d0e352eb0c73db4a6f.tar.gz otp-75ee72b4e1d288b1d96194d0e352eb0c73db4a6f.tar.bz2 otp-75ee72b4e1d288b1d96194d0e352eb0c73db4a6f.zip |
Strip potentially large terms when sending outgoing Diameter messages
Both incoming and outgoing Diameter messages pass through two or three
processes, depending on whether they're incoming or outgoing: the
transport process and corresponding peer_fsm process and (for incoming)
watchdog processes. Since terms other than binary are copied when
passing process boundaries, large terms lead to copying that can be
problematic, if frequent enough. Since only the bin and transport_data
fields of a diameter_packet record are needed by the transport process,
discard others when sending outgoing messages.
Strictly speaking, the statement that only the aforementioned fields are
needed by the transport process depends on the transport process. It's
true of those implemented by diameter (in diameter_tcp and
diameter_sctp), but an implementation that makes use of other fields is
assuming more than the documentation in diameter_transport(3) promises.
Diffstat (limited to 'lib/diameter/src/base/diameter_watchdog.erl')
-rw-r--r-- | lib/diameter/src/base/diameter_watchdog.erl | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/diameter/src/base/diameter_watchdog.erl b/lib/diameter/src/base/diameter_watchdog.erl index 67715906e8..8223b7df98 100644 --- a/lib/diameter/src/base/diameter_watchdog.erl +++ b/lib/diameter/src/base/diameter_watchdog.erl @@ -572,11 +572,18 @@ rcv('DWR', Pkt, #watchdog{transport = TPid, DPkt = diameter_codec:decode(Dict0, Pkt), diameter_traffic:incr(recv, DPkt, TPid, Dict0), diameter_traffic:incr_error(recv, DPkt, TPid, Dict0), - EPkt = encode(dwa, Dict0, Pkt), + #diameter_packet{header = H, + transport_data = T, + bin = Bin} + = EPkt + = encode(dwa, Dict0, Pkt), diameter_traffic:incr(send, EPkt, TPid, Dict0), diameter_traffic:incr_rc(send, EPkt, TPid, Dict0), - send(TPid, {send, EPkt}), + %% Strip potentially large message terms. + send(TPid, {send, #diameter_packet{header = H, + transport_data = T, + bin = Bin}}), ?LOG(send, 'DWA'); rcv('DWA', Pkt, #watchdog{transport = TPid, |