extmod/modussl: fix socket and ussl read/write errors for non-blocking sockets #6615
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR replaces #5825 and is based on #6613
This PR attempts to make read and write behave identically on non-blocking sockets and on SSL wrappers with a non-blocking socket underneath. The goal is for stuff like EAGAIN and EINPROGRESS or None returns to be correct and the same. In the end, that makes it easier to write software that can use plain or SSL sockets.
The PR includes a test that checks all combinations for connect+op on non-blocking sockets with and without ssl (
net_hosted/connect_noblock.py
). I've tested on esp32, pyboard and unix so far. I don't have any of the other platforms. The test passes on esp32 and fails on unix, the failure is because AXTLS can't quite do non-blocking SSL handshakes. The test fails on pyboard because trying to send 4 bytes on a non-blocking socket that hasn't connected succeeds when it should raise EAGAIN or EINPROGRESS.