Skip to content

Refactor tcpsocket tests to use sigio and not to wait #9794

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

Merged
merged 1 commit into from
Feb 26, 2019

Conversation

michalpasztamobica
Copy link
Contributor

Description

As previously done for TLSSockets - we don't want the receiver thread to do a busy wait.
I decided not to touch the UDPSocket echo tests as they do packet counting (and accept some missing packets ratio), so the design there would have to be different, but if you think it's reasonable to rewrite that test to, I can do it as well.

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[x] Test update
[ ] Breaking change

Reviewers

@SeppoTakalo
@AriParkkila
@VeijoPesonen
@KariHaapalehto
@mtomczykmobica
@tymoteuszblochmobica

continue;
} else if (recvd < 0) {
TEST_FAIL();
int recvd = sock.recv(&(tcp_global::rx_buffer[bytes2recv_total - bytes2recv]), bytes2recv);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you should remove the while() loop.

You are supposed to loop UNTIl you get the WOULD_BLOCK.

Only then you are guaranteed to receive sigio() event.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I understand correctly... The tcpsocket_echotest_nonblock_receive() function is called from sigio handler. I thought it is supposed to trigger on the event to be sure the data is there waiting to be read?
Perhaps I am missing something about how the sigio works?

Copy link
Contributor

Choose a reason for hiding this comment

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

For example, if the driver received 2kB of data.. sends sigio() event to notify that there is new data to be read, and you read 1kB. It does not send another event, because there was not change in the state.. the device is still readable.

Copy link
Contributor

Choose a reason for hiding this comment

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

sigio() notifies that there is change of state.

readable -> not readable or
not readable -> readable or
connected -> disconnected or
connecting -> connected or
new connections acceptable -> no new connections
etc...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I see. Then I will also fix the tlssocket echo tests as I made the same mistake there some time ago.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Brough the loop back into the receiver both for tcp and tls socket tests. Thanks for pointing this out!

@ciarmcom
Copy link
Member

@michalpasztamobica, thank you for your changes.
@tymoteuszblochmobica @AriParkkila @VeijoPesonen @SeppoTakalo @KariHaapalehto @mtomczykmobica @ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-test @ARMmbed/mbed-os-maintainers please review.

@michalpasztamobica
Copy link
Contributor Author

@VeijoPesonen , thanks for your remarks. I just pushed improved code.

@cmonr cmonr requested review from SeppoTakalo, OPpuolitaival and VeijoPesonen and removed request for SeppoTakalo and OPpuolitaival February 25, 2019 17:08
Copy link
Contributor

@cmonr cmonr left a comment

Choose a reason for hiding this comment

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

LGTM

@cmonr
Copy link
Contributor

cmonr commented Feb 26, 2019

CI started while waiting on one or two more people to complete reviews

@mbed-ci
Copy link

mbed-ci commented Feb 26, 2019

Test run: SUCCESS

Summary: 10 of 10 test jobs passed
Build number : 1
Build artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants