Skip to content

Commit 599aafe

Browse files
committed
this is how to close a file for writing
1 parent 2f45010 commit 599aafe

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

libc-bottom-half/sources/wasip3_file.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@ static void file_close_streams(void *data) {
2525
filesystem_future_result_void_error_code_drop_readable(file->read.f1);
2626
}
2727
if (file->write.output != 0) {
28-
// TODO: This fails
29-
if (WASIP3_SUBTASK_HANDLE(file->write.subtask)) {
30-
wasip3_subtask_status_t status2 =
31-
wasip3_subtask_cancel(WASIP3_SUBTASK_HANDLE(file->write.subtask));
32-
wasip3_subtask_block_on(status2);
33-
file->write.subtask = WASIP3_SUBTASK_RETURNED_CANCELLED;
34-
}
35-
sockets_stream_u8_drop_writable(file->write.output);
28+
filesystem_stream_u8_drop_writable(file->write.output);
3629
file->write.output = 0;
30+
wasip3_subtask_block_on(file->write.subtask);
31+
if (file->write.pending_result.is_err) {
32+
translate_error(file->write.pending_result.val.err);
33+
}
3734
}
3835
}
3936

@@ -156,6 +153,7 @@ static int file_write_stream(void *data, wasip3_write_t **out, off_t **offs) {
156153
file->write.subtask = filesystem_method_descriptor_write_via_stream(
157154
filesystem_borrow_descriptor(file->file_handle), write_read,
158155
file->offset, &file->write.pending_result);
156+
// filesystem_stream_u8_drop_readable(write_read);
159157
}
160158
*out = &file->write;
161159
*offs = &file->offset;

0 commit comments

Comments
 (0)