-
Notifications
You must be signed in to change notification settings - Fork 7.6k
NetworkUDP - in parsePacket handle previous parsed packet #10239
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
Conversation
👋 Hello JAndrassy, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
Test Results 56 files - 83 56 suites - 83 4m 56s ⏱️ - 1h 38m 13s Results for commit 2e50c1c. ± Comparison against base commit cd3d0bf. This pull request removes 9 tests.
♻️ This comment has been updated with latest results. |
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
e0978e4
to
2e50c1c
Compare
@@ -292,7 +292,10 @@ void NetworkUDP::flush() {} | |||
|
|||
int NetworkUDP::parsePacket() { | |||
if (rx_buffer) { | |||
return 0; | |||
if (rx_buffer->full()) { // packet was not read yet | |||
return rx_buffer->available(); |
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.
can you show a benefit from returning the previous packet len more than once? If code did not care about it the first time, why should it care after that?
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.
for the library it is better than destroying it then allocate the next then destroy it ...
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.
library will not destroy it. It will just return 0, because old packet is still there and new one was not received. The point of returning positive length is to signal that a new packet has been received. This happens only once per packet.
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.
but the PR is about not returning a zero if the packet was not read until the end
if (rx_buffer->full()) { // packet was not read yet | ||
return rx_buffer->available(); | ||
} | ||
clear(); // discard the rest of the packet |
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.
What will happen in you call parsePacket
from one thread, but you read it's data from another?
parsePacket
now returns 0 if previous packet was not read. what is the logic of that?this PR proposes to changes it to return the existing packet if it was not read yet and discard the packet if the user read some part of it.