-
Notifications
You must be signed in to change notification settings - Fork 12
Description
In the current master (45dcf9d) branch, if we upgrade the mio library, Foundry can't receive sockets' HUP events.
You can easily check it by upgrading the mio version and running the command below:
yarn mocha -r ts-node/register --timeout 5000 src/e2e/network2.test.ts
I found that mio's this commit changed the behavior: tokio-rs/mio@b89e3bd
Using other libraries that have a mio >= 0.6.17 as a dependency (tokio is the example) causes the problem.
We are using the deprecated APIs of the mio. I suspect that the cause of the problem came from the usage of the deprecated APIs.
I found that we should not depend on the "HUP" event in the mio document.
In other words, portable programs that explicitly check for hup or error readiness should be doing so as an optimization and always be able to handle an error or HUP situation when performing the actual read operation.
https://docs.rs/mio/0.6.21/mio/struct.Poll.html#readiness-operations
I also checked that the return value of the read is zero when a connection is canceled.
If n is 0, then it can indicate one of two scenarios:
This reader has reached its "end of file" and will likely no longer be able to produce bytes. Note that this does not mean that the reader will always no longer be able to produce bytes.
https://doc.rust-lang.org/std/io/trait.Read.html#tymethod.read
However, our code depends on the HUP event from the mio. We should check the return value of the read.