-
Notifications
You must be signed in to change notification settings - Fork 116
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
[test] TCP Ping Pong for C API #151
Conversation
assert(demi_sgafree(&sga) == 0); | ||
|
||
/* Pop data scatter-gather array. */ | ||
pop_wait(sockqd, &qr); |
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.
Shouldn't we check the result for something? (Beyond what pop_wait() does internally, I mean)
Note that since TCP doesn't guarantee preservation of message boundaries, there is no guarantee here that we'll get back the same number of bytes that we sent in the push_wait above. But you could turn this into a loop of pop_wait()s that continue until the expected number of bytes come back.
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.
Sure. I missed this. I introduced a simple payload checking logic, similarly to what we have in the rust test.
tests/c/tcp-ping-pong.c
Outdated
/* Pop data scatter-gather array. */ | ||
pop_wait(sockqd, &qr); | ||
|
||
nbytes += sga.sga_segs[0].sgaseg_len; |
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.
I think it would make more sense here to increment nbytes by the number of bytes received in the pop_wait(), rather than the number of bytes sent in the push_wait(). Especially since you're not currently checking that they're the same thing.
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.
This was unintentional. Thanks for noting down.
8b83d8d
to
28cf2af
Compare
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.
Looks okay now.
Description
This PR is a partial fix for #131.
Summary of Changes