forked from M-Labs/artiq-zynq
cargo fmt
This commit is contained in:
parent
fc1fd96f71
commit
299cecd962
|
@ -781,43 +781,18 @@ async fn handle_connection(
|
||||||
match msg {
|
match msg {
|
||||||
Request::GetLog => process!(stream, _drtio_tuple, _destination, get_log),
|
Request::GetLog => process!(stream, _drtio_tuple, _destination, get_log),
|
||||||
Request::ClearLog => process!(stream, _drtio_tuple, _destination, clear_log),
|
Request::ClearLog => process!(stream, _drtio_tuple, _destination, clear_log),
|
||||||
Request::PullLog => process!(
|
Request::PullLog => process!(stream, _drtio_tuple, _destination, pull_log, &pull_id),
|
||||||
stream,
|
|
||||||
_drtio_tuple,
|
|
||||||
_destination,
|
|
||||||
pull_log,
|
|
||||||
&pull_id
|
|
||||||
),
|
|
||||||
Request::SetLogFilter => {
|
Request::SetLogFilter => {
|
||||||
let lvl = read_log_level_filter(stream).await?;
|
let lvl = read_log_level_filter(stream).await?;
|
||||||
process!(
|
process!(stream, _drtio_tuple, _destination, set_log_filter, lvl)
|
||||||
stream,
|
|
||||||
_drtio_tuple,
|
|
||||||
_destination,
|
|
||||||
set_log_filter,
|
|
||||||
lvl
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Request::SetUartLogFilter => {
|
Request::SetUartLogFilter => {
|
||||||
let lvl = read_log_level_filter(stream).await?;
|
let lvl = read_log_level_filter(stream).await?;
|
||||||
process!(
|
process!(stream, _drtio_tuple, _destination, set_uart_log_filter, lvl)
|
||||||
stream,
|
|
||||||
_drtio_tuple,
|
|
||||||
_destination,
|
|
||||||
set_uart_log_filter,
|
|
||||||
lvl
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Request::ConfigRead => {
|
Request::ConfigRead => {
|
||||||
let key = read_key(stream).await?;
|
let key = read_key(stream).await?;
|
||||||
process!(
|
process!(stream, _drtio_tuple, _destination, config_read, &cfg, &key)
|
||||||
stream,
|
|
||||||
_drtio_tuple,
|
|
||||||
_destination,
|
|
||||||
config_read,
|
|
||||||
&cfg,
|
|
||||||
&key
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Request::ConfigWrite => {
|
Request::ConfigWrite => {
|
||||||
let key = read_key(stream).await?;
|
let key = read_key(stream).await?;
|
||||||
|
@ -828,26 +803,11 @@ async fn handle_connection(
|
||||||
buffer.set_len(len);
|
buffer.set_len(len);
|
||||||
}
|
}
|
||||||
read_chunk(stream, &mut buffer).await?;
|
read_chunk(stream, &mut buffer).await?;
|
||||||
process!(
|
process!(stream, _drtio_tuple, _destination, config_write, &cfg, &key, buffer)
|
||||||
stream,
|
|
||||||
_drtio_tuple,
|
|
||||||
_destination,
|
|
||||||
config_write,
|
|
||||||
&cfg,
|
|
||||||
&key,
|
|
||||||
buffer
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Request::ConfigRemove => {
|
Request::ConfigRemove => {
|
||||||
let key = read_key(stream).await?;
|
let key = read_key(stream).await?;
|
||||||
process!(
|
process!(stream, _drtio_tuple, _destination, config_remove, &cfg, &key)
|
||||||
stream,
|
|
||||||
_drtio_tuple,
|
|
||||||
_destination,
|
|
||||||
config_remove,
|
|
||||||
&cfg,
|
|
||||||
&key
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Request::Reboot => {
|
Request::Reboot => {
|
||||||
process!(stream, _drtio_tuple, _destination, reboot)
|
process!(stream, _drtio_tuple, _destination, reboot)
|
||||||
|
@ -856,12 +816,7 @@ async fn handle_connection(
|
||||||
process!(stream, _drtio_tuple, _destination, config_erase)
|
process!(stream, _drtio_tuple, _destination, config_erase)
|
||||||
}
|
}
|
||||||
Request::DebugAllocator => {
|
Request::DebugAllocator => {
|
||||||
process!(
|
process!(stream, _drtio_tuple, _destination, debug_allocator)
|
||||||
stream,
|
|
||||||
_drtio_tuple,
|
|
||||||
_destination,
|
|
||||||
debug_allocator
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}?;
|
}?;
|
||||||
}
|
}
|
||||||
|
@ -869,15 +824,10 @@ async fn handle_connection(
|
||||||
|
|
||||||
pub fn start(
|
pub fn start(
|
||||||
cfg: Config,
|
cfg: Config,
|
||||||
drtio_tuple: Option<(
|
drtio_tuple: Option<(&Rc<Mutex<bool>>, &Rc<RefCell<drtio_routing::RoutingTable>>, GlobalTimer)>,
|
||||||
&Rc<Mutex<bool>>,
|
|
||||||
&Rc<RefCell<drtio_routing::RoutingTable>>,
|
|
||||||
GlobalTimer,
|
|
||||||
)>,
|
|
||||||
) {
|
) {
|
||||||
let drtio_tuple = drtio_tuple.map(
|
let drtio_tuple =
|
||||||
|(aux_mutex, routing_table, timer)| (aux_mutex.clone(), routing_table.clone(), timer)
|
drtio_tuple.map(|(aux_mutex, routing_table, timer)| (aux_mutex.clone(), routing_table.clone(), timer));
|
||||||
);
|
|
||||||
task::spawn(async move {
|
task::spawn(async move {
|
||||||
let pull_id = Rc::new(RefCell::new(0u32));
|
let pull_id = Rc::new(RefCell::new(0u32));
|
||||||
let cfg = Rc::new(cfg);
|
let cfg = Rc::new(cfg);
|
||||||
|
@ -891,12 +841,12 @@ pub fn start(
|
||||||
info!("received connection");
|
info!("received connection");
|
||||||
// Avoid consuming the tuple
|
// Avoid consuming the tuple
|
||||||
// Keep the borrowed value on stack
|
// Keep the borrowed value on stack
|
||||||
let drtio_tuple = drtio_tuple.as_ref().map(
|
let drtio_tuple = drtio_tuple
|
||||||
|(aux_mutex, routing_table, timer)| (aux_mutex, routing_table.borrow(), *timer)
|
.as_ref()
|
||||||
);
|
.map(|(aux_mutex, routing_table, timer)| (aux_mutex, routing_table.borrow(), *timer));
|
||||||
let drtio_tuple = drtio_tuple.as_ref().map(
|
let drtio_tuple = drtio_tuple
|
||||||
|(aux_mutex, routing_table, timer)| (*aux_mutex, routing_table.deref(), *timer)
|
.as_ref()
|
||||||
);
|
.map(|(aux_mutex, routing_table, timer)| (*aux_mutex, routing_table.deref(), *timer));
|
||||||
let _ = handle_connection(&mut stream, pull_id, cfg, drtio_tuple)
|
let _ = handle_connection(&mut stream, pull_id, cfg, drtio_tuple)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| warn!("connection terminated: {:?}", e));
|
.map_err(|e| warn!("connection terminated: {:?}", e));
|
||||||
|
|
Loading…
Reference in New Issue