extmod/modussl_mbedtls: When reading and peer wants to close, return 0.

If this particular code is returned then there's no more data, it's not
really an error.
pull/1/head
Damien George 2017-03-03 15:46:23 +11:00
parent 04552ff71b
commit a10467b58a
1 changed files with 4 additions and 0 deletions

View File

@ -192,6 +192,10 @@ STATIC mp_uint_t socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errc
mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in);
int ret = mbedtls_ssl_read(&o->ssl, buf, size);
if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) {
// end of stream
return 0;
}
if (ret >= 0) {
return ret;
}