Skip to content

Commit 0719c93

Browse files
committed
extmod/modussl_axtls: socket_read: Handle EAGAIN.
If SSL_EAGAIN is returned (which is a feature of MicroPython's axTLS fork), return EAGAIN. Original axTLS returns SSL_OK both when there's no data to return to user yet and when the underlying stream returns EAGAIN. That's not distinctive enough, for example, original module code works well for blocking stream, but will infinite-loop for non-blocking socket with EAGAIN. But if we fix non-blocking case, blocking calls to .read() will return few None's initially (while axTLS progresses thru handshake). Using SSL_EAGAIN allows to fix non-blocking case without regressing the blocking one. Note that this only handles case of non-blocking reads of application data. Initial handshake and writes still don't support non-blocking mode and must be done in the blocking way.
1 parent 3a9b15f commit 0719c93

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

extmod/modussl_axtls.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ STATIC mp_uint_t socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errc
121121
// EOF
122122
return 0;
123123
}
124+
if (r == SSL_EAGAIN) {
125+
r = MP_EAGAIN;
126+
}
124127
*errcode = r;
125128
return MP_STREAM_ERROR;
126129
}

0 commit comments

Comments
 (0)