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

[test] TCP Ping Pong for C API #151

Merged
merged 3 commits into from
Aug 5, 2022
Merged

[test] TCP Ping Pong for C API #151

merged 3 commits into from
Aug 5, 2022

Conversation

ppenna
Copy link
Contributor

@ppenna ppenna commented Aug 3, 2022

Description

This PR is a partial fix for #131.

Summary of Changes

  • Introduced C test for TCP ping pong

@ppenna ppenna added the enhancement Enhancement Request on an Existing Feature label Aug 3, 2022
@ppenna ppenna requested a review from BrianZill August 3, 2022 11:59
@ppenna ppenna self-assigned this Aug 3, 2022
assert(demi_sgafree(&sga) == 0);

/* Pop data scatter-gather array. */
pop_wait(sockqd, &qr);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

/* Pop data scatter-gather array. */
pop_wait(sockqd, &qr);

nbytes += sga.sga_segs[0].sgaseg_len;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@BrianZill BrianZill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay now.

@ppenna ppenna merged commit c4bd6db into dev Aug 5, 2022
@ppenna ppenna deleted the enhancement-tests-c branch August 5, 2022 18:52
@ppenna ppenna mentioned this pull request Aug 5, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement Request on an Existing Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants