Function esp_idf_svc::hal::sys::mbedtls_ssl_check_pending
source · pub unsafe extern "C" fn mbedtls_ssl_check_pending(
ssl: *const mbedtls_ssl_context,
) -> i32
Expand description
\brief Check if there is data already read from the underlying transport but not yet processed.
\param ssl SSL context
\return 0 if nothing’s pending, 1 otherwise.
\note This is different in purpose and behaviour from \c mbedtls_ssl_get_bytes_avail in that it considers any kind of unprocessed data, not only unread application data. If \c mbedtls_ssl_get_bytes returns a non-zero value, this function will also signal pending data, but the converse does not hold. For example, in DTLS there might be further records waiting to be processed from the current underlying transport’s datagram.
\note If this function returns 1 (data pending), this does not imply that a subsequent call to \c mbedtls_ssl_read will provide any data; e.g., the unprocessed data might turn out to be an alert or a handshake message.
\note This function is useful in the following situation: If the SSL/TLS module successfully returns from an operation - e.g. a handshake or an application record read - and you’re awaiting incoming data next, you must not immediately idle on the underlying transport to have data ready, but you need to check the value of this function first. The reason is that the desired data might already be read but not yet processed. If, in contrast, a previous call to the SSL/TLS module returned MBEDTLS_ERR_SSL_WANT_READ, it is not necessary to call this function, as the latter error code entails that all internal data has been processed.