forked from M-Labs/nac3
moninj: better connection logging
This commit is contained in:
parent
4af29e8eca
commit
8c60947291
|
@ -1,6 +1,6 @@
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use alloc::collections::BTreeMap;
|
use alloc::collections::BTreeMap;
|
||||||
use log::{debug, warn};
|
use log::{debug, info, warn};
|
||||||
use void::Void;
|
use void::Void;
|
||||||
|
|
||||||
use libboard_zynq::{smoltcp, timer::GlobalTimer, time::Milliseconds};
|
use libboard_zynq::{smoltcp, timer::GlobalTimer, time::Milliseconds};
|
||||||
|
@ -180,9 +180,13 @@ pub fn start(timer: GlobalTimer) {
|
||||||
loop {
|
loop {
|
||||||
let stream = TcpStream::accept(1383, 2048, 2048).await.unwrap();
|
let stream = TcpStream::accept(1383, 2048, 2048).await.unwrap();
|
||||||
task::spawn(async move {
|
task::spawn(async move {
|
||||||
let _ = handle_connection(&stream, timer)
|
info!("received connection");
|
||||||
.await
|
let result = handle_connection(&stream, timer).await;
|
||||||
.map_err(|e| warn!("connection terminated: {}", e));
|
match result {
|
||||||
|
Err(Error::NetworkError(smoltcp::Error::Illegal)) => info!("peer closed connection"),
|
||||||
|
Err(error) => warn!("connection terminated: {}", error),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
let _ = stream.flush().await;
|
let _ = stream.flush().await;
|
||||||
let _ = stream.abort().await;
|
let _ = stream.abort().await;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue