fix compile errors
This commit is contained in:
parent
96e9bd8f28
commit
6c6e131e61
1 changed files with 14 additions and 28 deletions
24
src/main.rs
24
src/main.rs
|
|
@ -23,7 +23,7 @@ use tokio::{
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This function logs the current amount of changed pixels to stdout every second
|
/// This function logs the current amount of changed pixels to stdout every second
|
||||||
async fn pixel_change_stdout_log() -> () {
|
async fn pixel_change_stdout_log() -> io::Result<()> {
|
||||||
let mut interval = tokio::time::interval(Duration::from_millis(1000));
|
let mut interval = tokio::time::interval(Duration::from_millis(1000));
|
||||||
loop {
|
loop {
|
||||||
interval.tick().await;
|
interval.tick().await;
|
||||||
|
|
@ -65,25 +65,12 @@ async fn save_image_frames(grids: Arc<[grid::Flut<u32>]>, duration: Duration) ->
|
||||||
/// Handle connections made to the socket, keeps a vec of the currently active connections,
|
/// Handle connections made to the socket, keeps a vec of the currently active connections,
|
||||||
/// uses timeout to loop through them and clean them up to stop a memory leak while not throwing
|
/// uses timeout to loop through them and clean them up to stop a memory leak while not throwing
|
||||||
/// everything away
|
/// everything away
|
||||||
async fn handle_flut(flut_listener: TcpListener, grids: Arc<[grid::Flut<u32>]>) -> () {
|
async fn handle_flut(flut_listener: TcpListener, grids: Arc<[grid::Flut<u32>]>) -> io::Result<()> {
|
||||||
let mut handles = VecDeque::new();
|
let mut handles = Vec::new();
|
||||||
tokio::spawn(async {
|
|
||||||
loop {
|
loop {
|
||||||
if let Some(handle) = handles.pop_front() {
|
let (mut socket, _) = flut_listener.accept().await?;
|
||||||
match timeout(Duration::from_secs(10), handle).await {
|
|
||||||
Ok(Ok(())) => debug_println!("connection closed ok"),
|
|
||||||
Ok(Err(e)) => debug_eprintln!("connection error {:?}", e),
|
|
||||||
Err(_) => handles.push_back(handle),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sleep(Duration::from_secs(30)).await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
loop {
|
|
||||||
if let Ok((mut socket, _)) = flut_listener.accept().await {
|
|
||||||
let grids = grids.clone();
|
let grids = grids.clone();
|
||||||
handles.push_back(tokio::spawn(async move {
|
handles.push(tokio::spawn(async move {
|
||||||
let (reader, writer) = socket.split();
|
let (reader, writer) = socket.split();
|
||||||
let mut connection = FlutClient::new(reader, writer, grids);
|
let mut connection = FlutClient::new(reader, writer, grids);
|
||||||
let resp = connection.process_socket().await;
|
let resp = connection.process_socket().await;
|
||||||
|
|
@ -92,7 +79,6 @@ async fn handle_flut(flut_listener: TcpListener, grids: Arc<[grid::Flut<u32>]>)
|
||||||
Err(err) => Err(err),
|
Err(err) => Err(err),
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue