Skip to content

Commit

Permalink
Fix EOF issue
Browse files Browse the repository at this point in the history
  • Loading branch information
XuJiandong committed Mar 8, 2024
1 parent e25aa9d commit 7bc2e33
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions script/src/v2_scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ impl<DL: CellDataProvider + HeaderProvider + ExtensionProvider + Send + Sync + C
.machine
.memory_mut()
.store64(&length_addr, &0)?;
read_machine.machine.set_register(A0, OTHER_END_CLOSED as u64);
read_machine.machine.set_register(A0, SUCCESS as u64);
self.states.insert(vm_id, VmState::Runnable);
}
VmState::WaitForWrite {
Expand All @@ -560,7 +560,7 @@ impl<DL: CellDataProvider + HeaderProvider + ExtensionProvider + Send + Sync + C
.machine
.memory_mut()
.store64(&length_addr, &consumed)?;
write_machine.machine.set_register(A0, OTHER_END_CLOSED as u64);
write_machine.machine.set_register(A0, SUCCESS as u64);
self.states.insert(vm_id, VmState::Runnable);
}
_ => (),
Expand Down
Binary file modified script/testdata/spawn_cases
Binary file not shown.
6 changes: 6 additions & 0 deletions script/testdata/spawn_cases.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,14 @@ int child_read_then_close() {
CHECK(err);
uint8_t data[8];
size_t data_len = sizeof(data);
// first read to return 0 byte without error
err = ckb_read(fds[CKB_STDIN], data, &data_len);
CHECK(err);
CHECK2(data_len == 0, -2);
// second read to return error(other end closed)
err = ckb_read(fds[CKB_STDIN], data, &data_len);
CHECK2(err == CKB_OTHER_END_CLOSED, -2);

err = 0;
exit:
return err;
Expand Down

0 comments on commit 7bc2e33

Please sign in to comment.