Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace most instances of IncRef with Clone. #11284

Merged
merged 1 commit into from
Dec 13, 2024
Merged

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Dec 10, 2024

Replace most instances of IncRef with Clone.

Incrementing the reference count of a packet as a means of granting ownership
is unsafe when the packet is shared across gorountines. The underlying buffer's
reference count is unchanged since it "technically" has the same owning
PacketBuffer, which means different goroutines operating on the underlying
buffer (and packet itself) race.

Clones are roughly as fast as IncRefs because the PacketBuffers allocate from
a pool and the underlying buffers are cloned with copy-on-write
semantics.

I've left IncRef in places where the original packet in obviously going out of
scope at the end of the function or in some tests.

Reported-by: [email protected]
Reported-by: [email protected]
Reported-by: [email protected]

@copybara-service copybara-service bot added the exported Issue was exported automatically label Dec 10, 2024
@copybara-service copybara-service bot force-pushed the test/cl704824675 branch 6 times, most recently from a3257f6 to 0b413c6 Compare December 13, 2024 00:24
Incrementing the reference count of a packet as a means of granting ownership
is unsafe when the packet is shared across gorountines. The underlying buffer's
reference count is unchanged since it "technically" has the same owning
PacketBuffer, which means different goroutines operating on the underlying
buffer (and packet itself) race.

Clones are roughly as fast as IncRefs because the PacketBuffers allocate from
a pool and the underlying buffers are cloned with copy-on-write
semantics.

I've left IncRef in places where the original packet in obviously going out of
scope at the end of the function or in some tests.

Reported-by: [email protected]
Reported-by: [email protected]
Reported-by: [email protected]
PiperOrigin-RevId: 705676806
@copybara-service copybara-service bot merged commit afa323b into master Dec 13, 2024
0 of 2 checks passed
@copybara-service copybara-service bot deleted the test/cl704824675 branch December 13, 2024 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exported Issue was exported automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant