aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base
AgeCommit message (Collapse)Author
2017-06-12Remove minor diameter_config bloatAnders Svensson
Folded when I should have mapped.
2017-06-12Don't prepend bit for sub binary optimizationAnders Svensson
2017-06-12Remove upgrade-related codeAnders Svensson
This and subsequent commits are destined for OTP 20.0.
2017-06-12Remove unnecessary value mappingAnders Svensson
Since value is ignored.
2017-06-12Use dictionary '#new-'/1 when creating CEAAnders Svensson
Which is the equivalent of what was done with '#new-'/1 and '#set-'/2.
2017-06-12Optimize sub binary creationAnders Svensson
2017-06-12Optimize sub binary creationAnders Svensson
base/diameter_codec.erl:716: Warning: OPTIMIZED: creation of sub binary delayed
2017-06-12Optimize sub binary creationAnders Svensson
base/diameter_codec.erl:545: Warning: OPTIMIZED: creation of sub binary delayed
2017-06-12Optimize sub binary creationAnders Svensson
base/diameter_codec.erl:600: Warning: OPTIMIZED: creation of sub binary delayed
2017-06-12Don't match for no useful reasonAnders Svensson
2017-06-12Avoid modifying records during encodeAnders Svensson
2017-06-12Don't create intermediate terms unnecessarily during encodeAnders Svensson
2017-06-12Don't create intermediate binaries unnecessarily during encodeAnders Svensson
Dict:avp(encode, Value, Name) no longer needs to return a binary, only an iolist(). Message encode runs list_to_binary/1 to convert accumulated lists into a message binary.
2017-06-12Fix encode of Grouped AVP as {Dict, Name, Data}Anders Svensson
This is a special case to allow encode of something other than an iolist. Eg. #diameter_avp{data = {diameter_gen_base_rfc6733, 'Proxy-Info', [{'Proxy-Host', "HOST"}, {'Proxy-State', "STATE"}]}} Only worked as expected for AVPs of type other than Grouped.
2017-06-12Make encoding of Diameter header more efficientAnders Svensson
On the same theme as the parent commit, building binaries in fewer steps.
2017-06-12Make encoding of diameter_avp records more efficientAnders Svensson
Prepend the header in a single step. Before: {[{{diameter_codec,pack_avp,1}, 7000, 126.074, 51.058}], { {diameter_codec,pack_avp,2}, 7000, 126.074, 51.058}, % [{{diameter_codec,pack_avp,5}, 7000, 51.144, 25.758}, {{diameter_codec,pad,2}, 7000, 23.844, 23.570}, {suspend, 1, 0.028, 0.000}]}. After: {[{{diameter_codec,pack_avp,1}, 7000, 78.563, 26.986}], { {diameter_codec,pack_avp,2}, 7000, 78.563, 26.986}, % [{{diameter_codec,pack_avp,6}, 7000, 51.459, 26.381}, {suspend, 4, 0.118, 0.000}]}.
2017-06-12Decode message header in a single matchAnders Svensson
2017-06-12Make AVP splitting more efficientAnders Svensson
Profiling with fprof showed this prior to this commit: {[{{diameter_codec,decode,3}, 1000, 231.122, 4.092}, {{diameter_codec,collect_avps,1}, 1000, 0.000, 3.929}], { {diameter_codec,collect_avps,1}, 2000, 231.122, 8.021}, % [{{diameter_codec,collect_avps,3}, 1000, 222.932, 11.644}, {garbage_collect, 19, 0.169, 0.169}, {{diameter_codec,collect_avps,1}, 1000, 0.000, 3.929}]}. {[{{diameter_codec,collect_avps,1}, 1000, 222.932, 11.644}, {{diameter_codec,collect_avps,3}, 7000, 0.000, 68.186}], { {diameter_codec,collect_avps,3}, 8000, 222.932, 79.830}, % [{{diameter_codec,split_avp,1}, 7000, 120.886, 72.382}, {{erlang,setelement,3}, 7000, 21.830, 21.830}, {garbage_collect, 48, 0.386, 0.386}, {{diameter_codec,collect_avps,3}, 7000, 0.000, 68.186}]}. Note the time consumed in split_avp/1 and erlang:setelement/3. This commit does more matching in one go, without intermediate results, giving this: {[{{diameter_codec,decode,3}, 1000, 42.512, 3.701}, {{diameter_codec,collect_avps,1}, 1000, 0.000, 3.594}], { {diameter_codec,collect_avps,1}, 2000, 42.512, 7.295}, % [{{diameter_codec,collect_avps,3}, 1000, 35.217, 4.577}, {{diameter_codec,collect_avps,1}, 1000, 0.000, 3.594}]}. {[{{diameter_codec,collect_avps,1}, 1000, 35.217, 4.577}, {{diameter_codec,collect_avps,3}, 7000, 0.000, 27.754}], { {diameter_codec,collect_avps,3}, 8000, 35.217, 32.331}, % [{garbage_collect, 262, 2.647, 2.647}, {suspend, 9, 0.239, 0.000}, {{diameter_codec,collect_avps,3}, 7000, 0.000, 27.754}]}.
2017-06-12Remove bloat from zero encodeAnders Svensson
Don't call a function when we know the result, and consistently return a binary.
2017-06-12Fix comment typosAnders Svensson
2017-06-12Remove upgrade from diameter_trafficAnders Svensson
2017-06-11Simplify acks to transport processesAnders Svensson
What's interesting when implementing some form of load regulation is when an incoming request has been answered or discarded. Acknowledge exactly this, not the identity of handler processes as previously. A transport process can request acks of nonforthcoming answers by sending {diameter, ack} to the parent peer_fsm, a handler processes identifies itself with a {handler, pid()} message, and the peer_fsm monitors on this to be able to send a notification to the transport if the handler dies before sending an answer.
2017-06-11Fix handling of message length errorsAnders Svensson
Message length errors in incoming messages were misinterpreted with transport_opt() {length_errors, exit} due to the throw introduced in commit 2ffb288: the corresponding catch in incoming/2 caught errors thrown by close/1, leading to failure when the error reason was interpreted as a diameter_packet record. Do away with the throw, that also caused woe in the parent commit.
2017-06-11Fix broken discard acknowledgementAnders Svensson
A transport process can request acknowledgement of the fate of an incoming message to a specified pid, causing it to receive one of {diameter, {request|answer, pid()} | discard} depending on whether or not diameter passes the message off to a handler process. This was broken in commit a4da06a5 (since recv/3 threw a message that should be received), but is of little consequence since the interface isn't yet documented and is only used from diameter_tcp with configuration that will soon change.
2017-06-11Remove trailing whitespaceAnders Svensson
From commits 5ca5fb71 and 58091992.
2017-03-08Merge branch 'anders/diameter/capx_strictness/OTP-14257' into maintAnders Svensson
* anders/diameter/capx_strictness/OTP-14257: Add transport_opt() capx_strictness
2017-03-08Add transport_opt() capx_strictnessAnders Svensson
To allow the Peer State Machine requirement that only the expected capabilities exchange message be received in the relevant state to be relaxed. If {capx_strictness, false} is configured then anything bu the expected CER/CEA is ignored. This is non-standard behaviour, and thusfar undocumented. Use at your own risk.
2017-03-07Avoid sending large terms between nodes unnecessarilyAnders Svensson
When relaying outgoing requests through transport on a remote node, terms that were stripped when sending to the transport process weren't stripped when spawning a process on the remote node. Also, don't save the request to the process dictionary in a process that just relays an answer.
2017-03-07Don't use request table for answer routingAnders Svensson
The table has existed forever, to route incoming answers to a waiting request process: each outgoing request writes to the table, and each incoming answer reads. This has been seen to suffer from lock contention at high load however, so this commit moves the routing into the diameter_peer_fsm processes that are diameter's conduit to transport processes. The request table is still used for failover detection, but entries are only written when a watchdog state transitions leaves or enters state OKAY.
2017-02-24Fix/redo failover optimizationAnders Svensson
Commit 9a878743 addressed inefficiency at failover, but introduced inefficiency in the sending of outgoing requests in so doing: each outgoing request added an request table entry keyed on a transport pid, then looked for a specific element with this key, and then (later) removed the inserted element. Since the request table is a bag, this results in linear searches over a potentially long list of element keyed on the same pid. The higher the rate of outgoing calls, the more costly it becomes. Instead of writing entries to the request table, the peer_up/down calls to diameter_traffic that mirror transitions to and from the OKAY state in the RFC 3539 watchdog state machine now result in a process for request processes to monitor in order to detect failover.
2016-09-12Merge branch 'anders/diameter/19.1/OTP-13838' into maintAnders Svensson
* anders/diameter/19.1/OTP-13838: vsn -> 1.12.1 Update appup for 19.1 Fix xmllint errors in documentation Remove documentation overkill Don't run traffic tests in parallel when {string_decode, true} Remove copyright from generated dictionary modules Fix dictionary function typo Fix dictionary typo in relay example
2016-09-12Merge branch 'anders/diameter/failover/OTP-13412' into maintAnders Svensson
* anders/diameter/failover/OTP-13412: Make peer failover more efficient
2016-09-11Let unfortunate min_heap_size setting be disabledAnders Svensson
The setting in all diameter server processes has existed since the beginning of time. Whether it's actually useful is questionable, but it does lead to increased memory usage, especially if there are many peer connections whose processes wouldn't otherwise be large. Let the setting be disabled with -diameter min_heap_size false. (Or any value that isn't a non-negative integer.) The diameter application itself only calls diameter_lib:spawn_opts(server, []), but let other arguments remain for backwards compatibility, since diameter_lib:spawn_opts/2 has been abused from outside of diameter.
2016-08-26Fix dictionary function typoAnders Svensson
It's '#get-'/2, not 'get-'/2. Only failed if the dictionary in question defined no Failed-AVP, which is rarely the case in practice. Thanks to Ferenc Holzhauser.
2016-06-12Merge branch 'anders/diameter/rand/OTP-13664'Anders Svensson
* anders/diameter/rand/OTP-13664: Use rand(3) instead of random(3)
2016-06-11Use rand(3) instead of random(3)Anders Svensson
The latter is deprecated in OTP 19.
2016-06-11Remove unnecessary no_auto_importAnders Svensson
Not difficult to avoid, and better without.
2016-06-11Redo transport config server as a gen_serverAnders Svensson
To properly handle system messages. Initially implemented in commit 5ca5fb71.
2016-05-30Close listening sockets at transport removalAnders Svensson
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.
2016-05-30Don't restart transport processes after transport removalAnders Svensson
A replacement accepting transport could be started after the service process received a shutdown message from diameter_config, if a connection was accepted before the transport process in question was terminated. The replacement lived on until the service needed to restart it.
2016-05-30Rename diameter_reg:del -> removeAnders Svensson
Letters are cheap.
2016-05-30Add diameter_reg:subscribe/2Anders Svensson
To allow processes to subscribe to a message when a matching association is added or removed. The intention is to use this in diameter_{tcp,sctp}, in order for listening processes to find out when transport their transport configuration has been removed.
2016-05-30Add dialyzer specs to diameter_regAnders Svensson
Last missed in commit 25bef13f.
2016-05-30Remove diameter_reg:repl/2Anders Svensson
Unused, and in the way for what's to come.
2016-05-30Remove diameter_reg bloatAnders Svensson
Unexpected messages don't happen in practice, and no_auto_import is neither necessery nor difficult to avoid.
2016-05-09Merge branch 'anders/diameter/info/OTP-13508'Anders Svensson
* anders/diameter/info/OTP-13508: Add diameter:peer_find/1 Add diameter:peer_info/1
2016-05-09Merge branch 'anders/diameter/overload/OTP-13330'Anders Svensson
* anders/diameter/overload/OTP-13330: Suppress dialyzer warning Remove dead case clause Let throttling callback send a throttle message Acknowledge answers to notification pids when throttling Throttle properly with TLS Don't ask throttling callback to receive more unless needed Let a throttling callback answer a received message Let a throttling callback discard a received message Let throttling callback return a notification pid Make throttling callbacks on message reception Add diameter_tcp option throttle_cb
2016-05-04Add diameter:peer_find/1Anders Svensson
To return a peer_fsm/transport pair given one of them.
2016-05-04Add diameter:peer_info/1Anders Svensson
To return information about a single peer_ref(), to avoid having to retrieve more than is needed with service_info/2.
2016-03-16Make peer failover more efficientAnders Svensson
Failover caused the entire request table to be scanned in search of entries with the transport process in question. With many entries (possibly as a result of the leak fixed in commit 6c9cbd96), this can lead to the service process hanging in ets:select_trap/1, with memory growth when many request processes write concurrently. Now write entries keyed on the transport pid, so that finding request processes at failover is a lookup rather than a select scanning the entire table. There is no upgrade handling in that new code doesn't consider that old code didn't write entries on the transport pid. Thus, a request whose table entries were written in old code will timeout rather than failover in new code. That is, there is a small window for failover to be missed (since request processes are short-lived), but it requires that it take place during the upgrade. As a minor aside, don't ignore failovers when sending binaries (which isn't officially supported), let prepare_retransmit callbacks deal with modifying the binary as required.