From 0ab372585f57c80202a432bd757d52088de80850 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 20 May 2016 22:20:37 +0300 Subject: extmod/moduos_dupterm: Dumpterm subsystem is responsible for closing stream. Make dupterm subsystem close a term stream object when EOF or error occurs. There's no other party than dupterm itself in a better position to do this, and this is required to properly reclaim stream resources, especially if multiple dupterm sessions may be established (e.g. as networking connections). --- esp8266/esp_mphal.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'esp8266') diff --git a/esp8266/esp_mphal.c b/esp8266/esp_mphal.c index 25f1a9322..ec5da7d3d 100644 --- a/esp8266/esp_mphal.c +++ b/esp8266/esp_mphal.c @@ -171,16 +171,13 @@ static int call_dupterm_read(void) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(res, &bufinfo, MP_BUFFER_READ); if (bufinfo.len == 0) { - MP_STATE_PORT(term_obj) = NULL; - mp_printf(&mp_plat_print, "dupterm: EOF received, deactivating\n"); + mp_uos_deactivate("dupterm: EOF received, deactivating\n", MP_OBJ_NULL); return -1; } nlr_pop(); return *(byte*)bufinfo.buf; } else { - MP_STATE_PORT(term_obj) = NULL; - mp_printf(&mp_plat_print, "dupterm: Exception in read() method, deactivating: "); - mp_obj_print_exception(&mp_plat_print, nlr.ret_val); + mp_uos_deactivate("dupterm: Exception in read() method, deactivating: ", nlr.ret_val); } return -1; -- cgit v1.2.3