Skip to content

Commit

Permalink
extmod/modussl_mbedtls: Make socket.close() free all TLS resources.
Browse files Browse the repository at this point in the history
Also, use mp_stream_close() helper to close the underlying socket.
  • Loading branch information
dpgeorge committed Jul 25, 2017
1 parent 363087a commit 0893b27
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions extmod/modussl_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_setblocking_obj, socket_setblocking);
STATIC mp_obj_t socket_close(mp_obj_t self_in) {
mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in);

mbedtls_pk_free(&self->pkey);
mbedtls_x509_crt_free(&self->cert);
mbedtls_x509_crt_free(&self->cacert);
mbedtls_ssl_free(&self->ssl);
mbedtls_ssl_config_free(&self->conf);
mbedtls_ctr_drbg_free(&self->ctr_drbg);
mbedtls_entropy_free(&self->entropy);

mp_obj_t dest[2];
mp_load_method(self->sock, MP_QSTR_close, dest);
return mp_call_method_n_kw(0, 0, dest);
return mp_stream_close(self->sock);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_close_obj, socket_close);

Expand Down

0 comments on commit 0893b27

Please sign in to comment.