Skip to content

Data serialization fix - #4

Open
BHandle wants to merge 2 commits into
seaeagle1:masterfrom
BHandle:DataSerializationFix
Open

Data serialization fix#4
BHandle wants to merge 2 commits into
seaeagle1:masterfrom
BHandle:DataSerializationFix

Conversation

@BHandle

@BHandle BHandle commented Jan 24, 2025

Copy link
Copy Markdown

Previously, the KeepAlive pings could cause serialization errors by injecting data in-between a write header and payload. This would cause the receiving reader to receive data that was prefixed by the Ping's size header and exception.

By ensuring that only one thread has access to the writer at a time, we can eliminate this risk and ensure the integrity of Header/Payload pairs.

I also changed the second size header byte to be a modulus operation. Even over millions of iterations, modern compiled modulus is still approximately the same performance. That said, however, there was nothing wrong with the previous calculation, I just find modulus to be more clear in intent.

@BHandle

BHandle commented Jan 24, 2025

Copy link
Copy Markdown
Author

When creating this, I did not personally use the encrypted or stateful variants, and I haven't echoed any changes to those implementations. It's possible that these changes should also be performed there to keep each of them in sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant