mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
rpc/server/test: Stop all active connections when the server is stopped.
This commit is contained in:
@@ -238,13 +238,21 @@ mod tests {
|
||||
drop(listener);
|
||||
|
||||
let rpc_server = Arc::new(RpcServer { rpc_connections: Mutex::new(HashSet::new()) });
|
||||
let rpc_server_ = rpc_server.clone();
|
||||
|
||||
let server_task = StoppableTask::new();
|
||||
server_task.clone().start(
|
||||
listen_and_serve(endpoint.clone(), rpc_server.clone(), None, executor.clone()),
|
||||
|res| async move {
|
||||
match res {
|
||||
Ok(()) | Err(Error::RpcServerStopped) => {}
|
||||
Ok(()) | Err(Error::RpcServerStopped) => {
|
||||
eprintln!("Stopping connections");
|
||||
for (i, task) in rpc_server_.get_connections().await.iter().enumerate()
|
||||
{
|
||||
eprintln!("Stopping connection #{}", i);
|
||||
task.stop().await;
|
||||
}
|
||||
}
|
||||
Err(e) => panic!("{}", e),
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user