I'm trying to create a program where I can add and remove devices during execution. But I find this to be difficult to do in a safe manner for several reasons:
The handler function is private, so I'm not able to create my own server loop.
The server function spawns threads for each socket without keeping track of them, so it's not trivial to close the threads when removing a usb from the vector. (I haven't found any way to do graceful shutdown in the protocol spec)
I had imagined to create something like the following:
/// Spawn a USB/IP server at `addr` using [TcpListener]
pub async fn customServer(addr: SocketAddr, server: UsbIpServer) {
let listener = TcpListener::bind(addr).await.expect("bind to addr");
let server = async move {
let usbip_server = Arc::new(server);
loop {
tokio::select! {
val = listener.accept() => {
match val {
Ok((mut socket, _addr)) => {
...
}
Err(err) => {
...
}
}
}
val = listen_for_devicelist_changes() => {
// add or remove device
...
}
}
}
};
server.await
}
Is this something you would consider to be in the scope of the library?
Hello!
I'm trying to create a program where I can add and remove devices during execution. But I find this to be difficult to do in a safe manner for several reasons:
handler
function is private, so I'm not able to create my own server loop.server
function spawns threads for each socket without keeping track of them, so it's not trivial to close the threads when removing a usb from the vector. (I haven't found any way to do graceful shutdown in the protocol spec)I had imagined to create something like the following:
Is this something you would consider to be in the scope of the library?