net_would_block()
does not use the mbedtls context for timeouts (IDFGH-14247)
#15043
Open
3 tasks done
Labels
Answers checklist.
IDF version.
5.1.5 & master
Espressif SoC revision.
ESP32s3
Operating System used.
Linux
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
None
Development Kit.
Custom
Power Supply used.
Battery
What is the expected behavior?
We are writing a cross-platform library and would like to rely on network socket timeout instead of using
mbedtls_net_recv_timeout()
.It is expected that
mbedtls_ssl_read()
returnsMBEDTLS_ERR_NET_RECV_FAILED
when there is a signal that interrupts the connection (like the socket timeout).What is the actual behavior?
mbedtls_ssl_read()
returnsMBEDTLS_ERR_SSL_WANT_READ
becausenet_would_block()
checkserrno=EAGAIN
and returns 1.Steps to reproduce.
...
Debug Logs.
No response
More Information.
Traditionally, the function
int net_would_block( const mbedtls_net_context *ctx )
returns0
when the network socket is blocking (including when there is a timeout on it).Given that the upstream library does not behave that way, this makes cross-platform support harder.
Some references:
This commit removes the upstream behaviour. I could not find the merge request for more details, but this is the merge message from the git logs.
This change seems incorrect, as the sockets with receive timeouts DO block until the timeout elapses. The commit message seems to be confused, as a socket with timeout should NOT meet the condition
NON_BLOCK
.This is the way we are handling it currently, using a define flag
CHECK_BLOCKING_SOCKET
Simplified code:
@MTsimon
The text was updated successfully, but these errors were encountered: