Skip to content

Commit 7614a6c

Browse files
committed
extmod/modussl_mbedtls: Consider mbedtls buffer when polling.
1 parent 5987130 commit 7614a6c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

extmod/modussl_mbedtls.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,14 @@ STATIC mp_uint_t socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, i
366366
mbedtls_ssl_config_free(&self->conf);
367367
mbedtls_ctr_drbg_free(&self->ctr_drbg);
368368
mbedtls_entropy_free(&self->entropy);
369+
} else if (request == MP_STREAM_POLL) {
370+
/* For POLL_RD, first check if ssl layer has bytes available... */
371+
if (arg & MP_STREAM_POLL_RD) {
372+
if (mbedtls_ssl_get_bytes_avail(&self->ssl) > 0) {
373+
return MP_STREAM_POLL_RD;
374+
}
375+
}
376+
/* ...otherwise fall through to pass request to underlying socket */
369377
}
370378
// Pass all requests down to the underlying socket
371379
return mp_get_stream(self->sock)->ioctl(self->sock, request, arg, errcode);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy