-
Notifications
You must be signed in to change notification settings - Fork 194
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
Restricting tasks to CPU0 breaks async tls #296
Comments
Might be caused by this terrible hack which is trying to mitigate this oddity in esp-tls which is masking out whether mbedtls wants us to wait on the socket to become readable, or writeable. Can you increase the delay from 0, to - say - 20 (= 20ms), and then remove the |
Additional info: IF the main task had higher priority than the pthread-based "poll my sockets" task which I hope you haven't changed your main task priority. It is by default with priority 1, which is only higher than the idle tasks which run at prio 0. pthread tasks on the other hand by default run with priority 5, which is a higher priority. But if you DID change your main task prio to something higher than 5... that would explain what is going on there... |
I cannot currently check anything, but I'm sure my main task priority is the default one. |
It will take me a couple of days to check myself, but I guess, no rush. |
This is the stack trace when the watchdog interrupts the thread:
I've increased the delay in the
Interestingly, I've had one case where it did manage to do TLS negotation (and afterwards communicated normally with the server). However, it took abnormally long (7 seconds) and I wasn't able to reproduce it a second time. |
@torkleyy TL;DR: If you wrap your thread::Builder::new().stack_size(15000).spawn(move || {
smol::block_on(<... your code driving AsyncEspTls ...>)
})?
.join()
.unwrap() ... it would work. Long story: still to get to the exact root cause, but in the meantime pretty sure the problem is caused by the combination of two factors:
As a result, both the main task, as well as the idle tasks are actually starving and never being scheduled. So - in a way - the The workaround of running your code in a pthread task works, because this way you raise the priority of your task to 5, and allow it to pre-empt the busy-looping I have a deja-vu feeling that I'm discovering this for the second time, and have experienced this on the single-core esp32c3 a while ago. I think there is a reason why I've put all the async code in |
Ha! I see. Thanks a bunch for all the information! |
If I restrict threads to run on CPU0:
the
AsyncEspTls::negotiate
won't become ready.I would expect the main thread (
async_io::block_on
) to yield at some point to let the IO thread make progress.The text was updated successfully, but these errors were encountered: