diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-05-20 22:20:37 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-05-20 22:20:37 +0300 |
commit | 0ab372585f57c80202a432bd757d52088de80850 (patch) | |
tree | d00e04f3962bd1dc3c1023af368396841c0a5b7c /esp8266 | |
parent | 3a29db8e58d963747697025e847444430c9f8b9e (diff) | |
download | micropython-0ab372585f57c80202a432bd757d52088de80850.tar.gz micropython-0ab372585f57c80202a432bd757d52088de80850.zip |
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).
Diffstat (limited to 'esp8266')
-rw-r--r-- | esp8266/esp_mphal.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/esp8266/esp_mphal.c b/esp8266/esp_mphal.c index 25f1a9322f..ec5da7d3d0 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; |