diff options
Diffstat (limited to 'extmod')
| -rw-r--r-- | extmod/modwebrepl.c | 4 | ||||
| -rw-r--r-- | extmod/modwebsocket.c | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/extmod/modwebrepl.c b/extmod/modwebrepl.c index c160abea2..e9e60b7b4 100644 --- a/extmod/modwebrepl.c +++ b/extmod/modwebrepl.c @@ -250,8 +250,8 @@ STATIC mp_uint_t _webrepl_read(mp_obj_t self_in, void *buf, mp_uint_t size, int DEBUG_printf("webrepl: Writing %lu bytes to file\n", buf_sz); int err; - mp_uint_t res = mp_stream_writeall(self->cur_file, filebuf, buf_sz, &err); - if(res == MP_STREAM_ERROR) { + mp_uint_t res = mp_stream_write_exactly(self->cur_file, filebuf, buf_sz, &err); + if (err != 0 || res != buf_sz) { assert(0); } diff --git a/extmod/modwebsocket.c b/extmod/modwebsocket.c index 344933ded..949a5fed9 100644 --- a/extmod/modwebsocket.c +++ b/extmod/modwebsocket.c @@ -240,9 +240,9 @@ STATIC mp_uint_t websocket_write(mp_obj_t self_in, const void *buf, mp_uint_t si mp_call_method_n_kw(1, 0, dest); } - mp_uint_t out_sz = mp_stream_writeall(self->sock, header, hdr_sz, errcode); - if (out_sz != MP_STREAM_ERROR) { - out_sz = mp_stream_writeall(self->sock, buf, size, errcode); + mp_uint_t out_sz = mp_stream_write_exactly(self->sock, header, hdr_sz, errcode); + if (*errcode == 0) { + out_sz = mp_stream_write_exactly(self->sock, buf, size, errcode); } if (self->opts & BLOCKING_WRITE) { @@ -250,6 +250,9 @@ STATIC mp_uint_t websocket_write(mp_obj_t self_in, const void *buf, mp_uint_t si mp_call_method_n_kw(1, 0, dest); } + if (*errcode != 0) { + return MP_STREAM_ERROR; + } return out_sz; } |
