Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a TODO in the TURN Data Indication handler in the
steamnetworkingsockets_ice_client.cppfile about avoiding a heap allocation per packet.It was building a
CUtlVectorof every STUN attribute just to find XOR-PEER-ADDRESS and DATA.The change I applied to fix this heap allocation per packet was to walk the attributes in place and keep the first match of each, stopping early once both are found.
It also stops at the same points
ParseSTUNAttributesdoes when called with no key, so the same packets get accepted or dropped as before.To avoid duplicating the fingerprint check, I moved it into a small helper. It is called
BCheckFingerprint, that both paths use. I also added the fingerprint XOR value as a constantk_nSTUN_FingerprintXORin the header, similar to howk_nSTUN_CookieValueis already defined there. I didn't see any rules prohibiting this in code style, and thus I made this change as other constants were already doing so, please let me know if this is incorrect.test_cryptoand test_p2p.py pass, including the TURN relay cases. I also ran the full test_p2p.py suite under heaptrack on master and on this branch. On master there were 1,692 allocations from the Data Indication handler, all from the CUtlVector behind the ParseSTUNAttributes call. With this change there are none.