Conversation
|
Another part of #711 |
|
This is definitely going to be a particularly tricky one to implement. The main thing is that the component model doesn't specify that a 0-length read/write is guaranteed to signal readiness, so wasi-libc will need to recover in situations where readiness isn't working. That'll involve storing a bit more state in the fds in wasi-libc for handles and is in theory tractable, however. Another thing from this implementation is that in-flight reads/writes aren't necessarily handled super well. This'll kick off a 0-length read/write for input fds, but after the function returns these are still in flight. This happens in both erroneous cases as well as successful cases. The easiest solution would probably be to cancel all in-flight reads/writes, but a more advanced solution would be to leave the in-flight read/write happening. That way subsequent calls to |
|
Oh, I see, so the readiness would need to be stored in the descriptor and these zero size uncancelled transfers could remain active across poll calls. I never read the specification to the end (beyond that zero size calls can be used to query readiness) but it starts making sense. Ideally waitable-set would be reused across calls, but I didn't find an elegant solution, yet. |
|
To be honest I'm not sure if it's worth it to keep the zero-size transfers in flight. That'd require cancelling them, or waiting for them, during normal reads/writes as well. Overall that might be an optimization step too far for where wasi-libc is at. For now it's probably best to just enusre that by the time Overall this is all pretty horribly inefficient. For example I don't think it's possible to share the |
|
Oh, I just realized that there is another related implementation question: Should we combine |
|
That's a good point yeah, and I agree it'd be reasonable to use that to report back more events |
Without the separate file nor stream support this doesn't change any test to work, yet. (The code worked for me with tcp in the past, though)