-
Notifications
You must be signed in to change notification settings - Fork 950
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
bugfix: use same memory in ringbuffer #2268
bugfix: use same memory in ringbuffer #2268
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2268 +/- ##
==========================================
- Coverage 66.72% 58.81% -7.91%
==========================================
Files 208 208
Lines 16926 17340 +414
==========================================
- Hits 11294 10199 -1095
- Misses 4267 5638 +1371
- Partials 1365 1503 +138
|
ContainerIO' backend will read data into ringbuffer. But the data blocks use the same memory so that the comming data will override the previous one. Need to copy data before push into ringbuffer. Signed-off-by: Wei Fu <fuweid89@gmail.com>
// If we don't copy the data and the previous data isn't consumed by | ||
// ringbuf pop action, the incoming data will override the previous data | ||
// in the ringbuf. | ||
copyData := make([]byte, n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the comment, Copy
make data not be override, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More qeustion, as I do not know all ringbuf logic. The data will always append if pop not assume?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. if the size reaches the capacity, ringbuffer will drop the old one.
LGTM |
LGTM as well |
Signed-off-by: Wei Fu fuweid89@gmail.com
Ⅰ. Describe what this PR did
ContainerIO' backend will read data into ringbuffer. But the data blocks
use the same memory so that the comming data will override the previous
one.
Ⅱ. Does this pull request fix one issue?
When the input is too long, ContainerIO will separate one line into two data blocks. But the blocks shares the same memory, the new one will override the old one, like
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
Added
Ⅳ. Describe how to verify it
input >128 chars
Ⅴ. Special notes for reviews
I hate the pattern...