emscripten-core / emscripten-core/emscripten

WasmFS: Allow backends to implement readv to support pipes

Open
#16,269 1 comment 0 reactions 1 assignee Claimed by @shashank-mishra14 View on GitHub
wasmfs
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Right now WasmFS implements readv by issuing multiple individual reads to a backend, so there's no way for the backend to tell the difference between a single large read using multiple iovecs and multiple smaller reads each using one iovec. This makes it impossible to correctly implement pipes.

Pipe semantics are that reads return immediately when data is available even if the read requests more data than is available, but reads block when there is no data available. If an overlarge read that should not block is split over multiple iovecs, one of the multiple backend reads might precisely empty the pipe and the next backend read call will incorrectly block because the backend will think that it is a new read call on an empty pipe rather than a continuation of the same read call.

The fix is to give backends visibility into full readv calls, not just individual single-buffer reads.

We should also look into whether there is an analogous problem for writes.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.