Skip to content

Fix pooled packet reuse during concurrent ACK and resend - #74

Open
NikoCat233 wants to merge 1 commit into
willardf:mainfrom
NikoCat233:fix/reliable-resend-lifetime
Open

NikoCat233 wants to merge 1 commit into
willardf:mainfrom
NikoCat233:fix/reliable-resend-lifetime

Conversation

@NikoCat233

Copy link
Copy Markdown

A reliable packet could be acknowledged and recycled while a resend still referenced its buffer. A subsequent send could overwrite that buffer, causing the resend to transmit unrelated data.

This change:

  • Acquires a buffer usage under the packet lifecycle lock before resending.
  • Uses generation-tagged registrations to prevent stale references from resending or recycling a reused Packet.
  • Releases buffer usages when asynchronous send setup or queueing fails, including DEBUG delayed sends.
  • Keeps transport calls and application callbacks outside the lifecycle lock.

The wire protocol remains unchanged.

Validation:

  • New regression tests: 11/11 passed in Release and 12/12 in Debug, including a controlled race using real UDP and ACK packets.
  • Builds passed for net472 and netstandard2.0.
  • Selected existing network suite: 100 passed, 1 failed, 2 skipped. The previously observed timing-sensitive UdpReliableMessageAckWithDropTest failed in the grouped run and passed in isolation; the grouped run is not considered fully passing.

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