-
Notifications
You must be signed in to change notification settings - Fork 250
Description
The documentation of get_disconnector() seems to imply that the Disconnector future will wait until the RpcSystem's connection is cleanly shut down:
capnproto-rust/capnp-rpc/src/lib.rs
Lines 360 to 364 in 4602348
| /// Returns a `Disconnector` future that can be run to cleanly close the connection to this `RpcSystem`'s network. | |
| /// You should get the `Disconnector` before you spawn the `RpcSystem`. | |
| pub fn get_disconnector(&self) -> rpc::Disconnector<VatId> { | |
| rpc::Disconnector::new(self.connection_state.clone()) | |
| } |
However, the actual logic just calls ConnectionState::disconnect()
capnproto-rust/capnp-rpc/src/rpc.rs
Lines 1635 to 1637 in 4602348
| state.disconnect(::capnp::Error::disconnected( | |
| "client requested disconnect".to_owned(), | |
| )); |
shutdown(): capnproto-rust/capnp-rpc/src/rpc.rs
Lines 577 to 591 in 4602348
| let promise = c.shutdown(Err(error)).then(|r| match r { | |
| Ok(()) => Promise::ok(()), | |
| Err(e) => { | |
| if e.kind != ::capnp::ErrorKind::Disconnected { | |
| // Don't report disconnects as an error. | |
| Promise::err(e) | |
| } else { | |
| Promise::ok(()) | |
| } | |
| } | |
| }); | |
| let Some(fulfiller) = self.disconnect_fulfiller.borrow_mut().take() else { | |
| unreachable!() | |
| }; | |
| let _ = fulfiller.send(Promise::from_future(promise.attach(c))); |
This means that the Disconnector future will not report any errors from the shutdown, and indeed will probably resolve before the actual shutdown completes. This is contrary to the documentation noted above, and go against what I would expect from asynchronous disconnect, even without reading the documentation.