Closed baude closed 1 year ago
@baude and I have looked into trying to detect when the client disconnects from the server, but we found that this is not yet possible with tonic UDS gRPC. One thought that I had was to send the server a signal right before the client quits to notify the server that it is disconnecting. Then, stopping the thread in which the server was looking for the lease. Please let me know if this idea has potential.
did you file an upstream issue with tonic?
Just created this issue https://github.com/hyperium/tonic/issues/1249.
Do you have any thoughts on alternative solutions for the time being?
@baude Could you give your solution for this issue here? I believe it involved changing the Mozim lease to return a Future.
The mozim is just returning a unix file descriptor for people poll on event. Depend on how you get notified by the client disconnection, we may:
A: Get the fd of client disconnection notify channel, and use select
on two unix fd. No change required for mozim.
B: The client disconnection notify is Future
. Then we add async API to mozim returning the Future
. The netavark-dhcp-proxy could use futures::future::Select()
on both futures.
I see the benefit of having both sync(like mio) and async (like tokio) API in mozim. So I will assume option B) is more elegant. Let me start the coding in mozim for async API.
I have added async support to mozim 0.2, you may take this as example code of this async API:
https://github.com/nispor/mozim/blob/main/examples/mozim_async.rs
I will start to implement this.
If a client quits when the proxy is trying to obtain a lease, the attempt to lease continues until a timeout is reached. If the client quits, the proxy should also terminate its lease attempt.