Skip to content

Release AEADChunkWriter lock on write errors - #15

Open
hawkff wants to merge 1 commit into
SagerNet:devfrom
nyaakuza:fix-aead-writer-lock
Open

hawkff wants to merge 1 commit into
SagerNet:devfrom
nyaakuza:fix-aead-writer-lock

Conversation

@hawkff

@hawkff hawkff commented Oct 12, 2026

Copy link
Copy Markdown

AEADChunkWriter.Write takes writeAccess before it writes the length chunk, the payload and the padding. It unlocks only after all three writes succeed. If one of them fails, Write returns with the lock still held, and the next Write on the same writer blocks forever.

This change releases the lock with defer, the same fix that 9b95ab8 applied to StreamChunkWriter.Write.

A regression test makes the first write fail through an upstream writer that always returns an error. It then checks that a second write returns an error instead of blocking. Before this change, the second write blocks and the test fails after two seconds.

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