Skip to content

socket_sigio test uses shared equeue and thread #5527

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

Closed
wants to merge 1 commit into from

Conversation

sarahmarshy
Copy link
Contributor

Description

This modifies the socket_sigio test to use a shared EventQueue and Thread between test cases. Previously, the EventQueue and Thread were created on the stack for each test case.

This is implemented based on feedback from @kjbracey-arm and @pan- in #5474

Status

READY

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 22, 2017

Based on the referenced PR, this looks good to me.

Waiting for the reviewers feedback

@kjbracey
Copy link
Contributor

This does actually raise a number of issues, but they're quite involved. Most notably, the socket using the sigio and being read on the event queue is actually blocking.

The fact it's blocking is covering up some invalid use of sigio - it blocks on the first sigio until data is actually available (which may not be until a later sigio), and the fact that it's was a private event queue covered up the fact that it's blocking.

Plus there's an invalid assumption that all the data arrives in a single read (although it's probably true for a "hello world").

So this would incorrectly block the global event queue, and could theoretically cause deadlock if the network stack were also trying to use it (similar sort of deadlock we see trying to do DNS from mbed client - mbed client and Nanostack are sharing an event queue, so mbed client doing blocking DNS jams the stack).

I'd suggest not going for the global queue unless you want to do a rework to make it properly non-blocking, and then fixing up the sigio handler to cope with that - make it accumulate data into the buffer on each sigio, and finish when it reads 0 (the end of stream marker), rather than just trigger the completion on the first sigio.

An alternative simpler change to purely fix the thread lifetime issues without starting to pick at the network bits would just to be to use a private static thread+event queue in your test - it doesn't matter if you block your own private event queue.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 30, 2017

@sarahmarshy What do you think about the latest comment?

@kjbracey
Copy link
Contributor

kjbracey commented Dec 1, 2017

Part of my comment corresponds to one of @betzw's patches at #5604 - he's modifying the TCP loop there to not assume everything in one go, as I mentioned.

@adbridge
Copy link
Contributor

@sarahmarshy Please rebase this and address Kevin's comments.

@sarahmarshy sarahmarshy closed this Jan 3, 2018
@sg- sg- removed the needs: review label Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants