-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
extmod/modussl: fix socket and ussl read/recv/send/write errors for non-blocking sockets #5825
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
Conversation
I added a test performing complete non-blocking connections. Unfortunately run-tests doesn't like it and reports a crash even though pyboard runs it just fine:
|
CI for this PR fails. On stm32 mbedtls doesn't include |
f83c09e
to
f08a6b9
Compare
@tve could you please rebase this on latest master (mainly to pick up the improvements to mbedtls error strings)?
I'm not sure about adding send/recv: in CPython there's the concept of
You need to do |
I'll try to get the rebase started today. I knew you would have issues with send/recv. I did not realize the SSLObject vs SSLSocket difference. For me the primary reason to implement send/recv is to be able to write tests that run the same on all platforms 'cause I could not keep all the combos of ssl/non-ssl blocking/non-blocking read/write/recv/send straight otherwise. Even as-is the axtls platforms are slightly different. |
Is it not possible to do this using just read/write? What are the issues there? |
f08a6b9
to
40a4b51
Compare
I did a rebase, it would be really helpful to get #5968 in first so I can fix the tests only once. It ended up with a question about what you want... WRT send/recv/read/write: Here's what I see in CPython 3.8.5:
I was being driven nuts by all these inconsistencies and ended up ensuring TLS supports read/write/send/recv like regular sockets on MP, that was quite the relief. It's now easy to go back and just delete, but someone has to actually dig into all this and decide what to delete, i.e., how compatible you want to be with CPython and what the total fall-out is... Or maybe I'm totally confused and I'm looking at he wrong stuff altogether? (Quite likely...) |
Ok, will check that.
It seems your REPL code is wrong: you tab-complete on the normal socket, not the ssl wrapped object! On my CPython 3.8.5 the ssl wrapped object has read/write. You can use |
Ugh, my mind clearly was elsewhere...
So the CPython SSL socket has read/write/send/recv. |
superseded by #6615 |
This PR attempts to make read/recv/send/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. In order to get there, this PR also implements send/recv on SSL "sockets", that makes for one less exception (the code added is minimal, so it seemed worth eliminating that source of frustration). Funny enough, CPython doesn't have read/write on sockets, gaaaa! I've tested on esp32 and unix so far, I hope to try esp8266 as well. 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.
This PR includes #5819 'cause I can't get this one right without the error messages produced by the other one.I backed-out #5819 so the "Files changed" in github is more reasonable and it's easier to review. The downside is that CI will fail due to missing functions. I'll rebase on master once the fate of #5819 is decided.I'm planning to add a test that performs a full non-blocking SSL connection, but I wanted to get the PR started.done