aboutsummaryrefslogtreecommitdiff
path: root/extmod/modussl_axtls.c
diff options
context:
space:
mode:
authorDamien George2018-07-20 13:05:04 +1000
committerDamien George2018-07-20 13:05:04 +1000
commit7a67f057d74e9a16e7ae7bc562e592335145eaee (patch)
treef7c61fb16da80e49fa12d3876e8a2766be94eb18 /extmod/modussl_axtls.c
parent4a2051eec7f60c4a05822da540f763c5bc1775b1 (diff)
extmod/modussl: Support polling in ussl objects by passing through ioctl
The underlying socket can handling polling, and any other transparent ioctl requests. Note that CPython handles the case of polling an ssl object by polling the file descriptor of the underlying socket file, and that behaviour is emulated here.
Diffstat (limited to 'extmod/modussl_axtls.c')
-rw-r--r--extmod/modussl_axtls.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/extmod/modussl_axtls.c b/extmod/modussl_axtls.c
index 475d3f0ea..88b075c9b 100644
--- a/extmod/modussl_axtls.c
+++ b/extmod/modussl_axtls.c
@@ -177,21 +177,13 @@ STATIC mp_uint_t socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, in
STATIC mp_uint_t socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) {
mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(o_in);
- (void)arg;
- switch (request) {
- case MP_STREAM_CLOSE:
- if (self->ssl_sock != NULL) {
- ssl_free(self->ssl_sock);
- ssl_ctx_free(self->ssl_ctx);
- self->ssl_sock = NULL;
- mp_stream_close(self->sock);
- }
- return 0;
-
- default:
- *errcode = MP_EINVAL;
- return MP_STREAM_ERROR;
+ if (request == MP_STREAM_CLOSE && self->ssl_sock != NULL) {
+ ssl_free(self->ssl_sock);
+ ssl_ctx_free(self->ssl_ctx);
+ self->ssl_sock = NULL;
}
+ // Pass all requests down to the underlying socket
+ return mp_get_stream(self->sock)->ioctl(self->sock, request, arg, errcode);
}
STATIC mp_obj_t socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) {