Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited500e4

Browse files
committed
extmod/modwebrepl: Make GET_FILE operation non-blocking.
In the sense that while GET_FILE transfers its data, REPL still works.This is done by requiring client to send 1-byte block before WebREPLserver transfers next block of data.
1 parentc16612e commited500e4

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

‎extmod/modwebrepl.c‎

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,7 @@ STATIC void handle_op(mp_obj_webrepl_t *self) {
151151
if (self->hdr.type==PUT_FILE) {
152152
self->data_to_recv=self->hdr.size;
153153
}elseif (self->hdr.type==GET_FILE) {
154-
// TODO: It's not ideal that we block connection while sending file
155-
// and don't process any input.
156-
while (1) {
157-
mp_uint_tout_sz=write_file_chunk(self);
158-
assert(out_sz!=MP_STREAM_ERROR);
159-
if (out_sz==0) {
160-
break;
161-
}
162-
}
163-
164-
write_webrepl_resp(self->sock,0);
165-
self->hdr_to_recv=sizeof(structwebrepl_file);
154+
self->data_to_recv=1;
166155
}
167156
}
168157

@@ -250,17 +239,27 @@ STATIC mp_uint_t _webrepl_read(mp_obj_t self_in, void *buf, mp_uint_t size, int
250239
buf_sz+=sz;
251240
}
252241

253-
DEBUG_printf("webrepl: Writing %lu bytes to file\n",buf_sz);
254-
interr;
255-
mp_uint_tres=mp_stream_write_exactly(self->cur_file,filebuf,buf_sz,&err);
256-
if (err!=0||res!=buf_sz) {
257-
assert(0);
242+
if (self->hdr.type==PUT_FILE) {
243+
DEBUG_printf("webrepl: Writing %lu bytes to file\n",buf_sz);
244+
interr;
245+
mp_uint_tres=mp_stream_write_exactly(self->cur_file,filebuf,buf_sz,&err);
246+
if (err!=0||res!=buf_sz) {
247+
assert(0);
248+
}
249+
}elseif (self->hdr.type==GET_FILE) {
250+
assert(buf_sz==1);
251+
assert(self->data_to_recv==0);
252+
assert(filebuf[0]==0);
253+
mp_uint_tout_sz=write_file_chunk(self);
254+
if (out_sz!=0) {
255+
self->data_to_recv=1;
256+
}
258257
}
259258

260259
if (self->data_to_recv==0) {
261260
mp_stream_close(self->cur_file);
262261
self->hdr_to_recv=sizeof(structwebrepl_file);
263-
DEBUG_printf("webrepl: Finishedwritingfile\n");
262+
DEBUG_printf("webrepl: Finished file operation %d\n",self->hdr.type);
264263
write_webrepl_resp(self->sock,0);
265264
}
266265

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp