pass restart_idle semaphore
This commit is contained in:
parent
69e7d88dbc
commit
90312e2fb7
@ -804,12 +804,14 @@ pub fn main(timer: GlobalTimer, cfg: Config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let cfg = Rc::new(cfg);
|
let cfg = Rc::new(cfg);
|
||||||
mgmt::start(cfg.clone());
|
let restart_idle = Rc::new(Semaphore::new(0, 1));
|
||||||
|
mgmt::start(cfg.clone(), restart_idle.clone());
|
||||||
|
|
||||||
task::spawn(async move {
|
task::spawn(async move {
|
||||||
let terminate = Rc::new(Semaphore::new(0, 1));
|
let terminate = Rc::new(Semaphore::new(0, 1));
|
||||||
let running = Rc::new(Mutex::new(false));
|
let running = Rc::new(Mutex::new(false));
|
||||||
let repeat_lock = Rc::new(Mutex::new(false));
|
let repeat_lock = Rc::new(Mutex::new(false));
|
||||||
|
let restart_idle = restart_idle.clone();
|
||||||
let cfg = cfg.clone();
|
let cfg = cfg.clone();
|
||||||
let control = control.clone();
|
let control = control.clone();
|
||||||
let up_destinations = up_destinations.clone();
|
let up_destinations = up_destinations.clone();
|
||||||
@ -867,6 +869,7 @@ pub fn main(timer: GlobalTimer, cfg: Config) {
|
|||||||
let terminate = terminate.clone();
|
let terminate = terminate.clone();
|
||||||
let running = running.clone();
|
let running = running.clone();
|
||||||
let repeat_lock = repeat_lock.clone();
|
let repeat_lock = repeat_lock.clone();
|
||||||
|
let restart_idle = restart_idle.clone();
|
||||||
|
|
||||||
let _rep_lock = repeat_lock.async_lock().await;
|
let _rep_lock = repeat_lock.async_lock().await;
|
||||||
drop(_rep_lock);
|
drop(_rep_lock);
|
||||||
@ -881,6 +884,7 @@ pub fn main(timer: GlobalTimer, cfg: Config) {
|
|||||||
}
|
}
|
||||||
}).fuse() => (),
|
}).fuse() => (),
|
||||||
_ = terminate.async_wait().fuse() => (),
|
_ = terminate.async_wait().fuse() => (),
|
||||||
|
_ = restart_idle.async_wait().fuse() => ()
|
||||||
}
|
}
|
||||||
info!("supposed to drop idle kernel");
|
info!("supposed to drop idle kernel");
|
||||||
drop(_lock);
|
drop(_lock);
|
||||||
@ -932,8 +936,9 @@ pub fn soft_panic_main(timer: GlobalTimer, cfg: Config) -> ! {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Sockets::init(32);
|
Sockets::init(32);
|
||||||
|
|
||||||
mgmt::start(Rc::new(cfg));
|
let dummy_restart = Rc::new(Semaphore::new(0, 1));
|
||||||
|
mgmt::start(Rc::new(cfg), dummy_restart);
|
||||||
|
|
||||||
// getting eth settings disables the LED as it resets GPIO
|
// getting eth settings disables the LED as it resets GPIO
|
||||||
// need to re-enable it here
|
// need to re-enable it here
|
||||||
|
@ -6,6 +6,7 @@ use libasync::{smoltcp::TcpStream, task};
|
|||||||
use libboard_artiq::logger::{BufferLogger, LogBufferRef};
|
use libboard_artiq::logger::{BufferLogger, LogBufferRef};
|
||||||
use libboard_zynq::{slcr, smoltcp};
|
use libboard_zynq::{slcr, smoltcp};
|
||||||
use libconfig::Config;
|
use libconfig::Config;
|
||||||
|
use libcortex_a9::semaphore::Semaphore;
|
||||||
use log::{self, debug, error, info, warn, LevelFilter};
|
use log::{self, debug, error, info, warn, LevelFilter};
|
||||||
use num_derive::FromPrimitive;
|
use num_derive::FromPrimitive;
|
||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
@ -111,7 +112,7 @@ async fn read_key(stream: &mut TcpStream) -> Result<String> {
|
|||||||
Ok(String::from_utf8(buffer).unwrap())
|
Ok(String::from_utf8(buffer).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_connection(stream: &mut TcpStream, pull_id: Rc<RefCell<u32>>, cfg: Rc<Config>) -> Result<()> {
|
async fn handle_connection(stream: &mut TcpStream, pull_id: Rc<RefCell<u32>>, cfg: Rc<Config>, restart_idle: Rc<Semaphore>) -> Result<()> {
|
||||||
if !expect(&stream, b"ARTIQ management\n").await? {
|
if !expect(&stream, b"ARTIQ management\n").await? {
|
||||||
return Err(Error::UnexpectedPattern);
|
return Err(Error::UnexpectedPattern);
|
||||||
}
|
}
|
||||||
@ -201,6 +202,9 @@ async fn handle_connection(stream: &mut TcpStream, pull_id: Rc<RefCell<u32>>, cf
|
|||||||
if value.is_ok() {
|
if value.is_ok() {
|
||||||
debug!("write success");
|
debug!("write success");
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
|
if key == "idle_kernel" {
|
||||||
|
restart_idle.signal();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// this is an error because we do not expect write to fail
|
// this is an error because we do not expect write to fail
|
||||||
error!("failed to write: {:?}", value);
|
error!("failed to write: {:?}", value);
|
||||||
@ -229,16 +233,17 @@ async fn handle_connection(stream: &mut TcpStream, pull_id: Rc<RefCell<u32>>, cf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(cfg: Rc<Config>) {
|
pub fn start(cfg: Rc<Config>, restart_idle: Rc<Semaphore>) {
|
||||||
task::spawn(async move {
|
task::spawn(async move {
|
||||||
let pull_id = Rc::new(RefCell::new(0u32));
|
let pull_id = Rc::new(RefCell::new(0u32));
|
||||||
loop {
|
loop {
|
||||||
let mut stream = TcpStream::accept(1380, 2048, 2048).await.unwrap();
|
let mut stream = TcpStream::accept(1380, 2048, 2048).await.unwrap();
|
||||||
let pull_id = pull_id.clone();
|
let pull_id = pull_id.clone();
|
||||||
|
let restart_idle = restart_idle.clone();
|
||||||
let cfg = cfg.clone();
|
let cfg = cfg.clone();
|
||||||
task::spawn(async move {
|
task::spawn(async move {
|
||||||
info!("received connection");
|
info!("received connection");
|
||||||
let _ = handle_connection(&mut stream, pull_id, cfg)
|
let _ = handle_connection(&mut stream, pull_id, cfg, restart_idle)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| warn!("connection terminated: {:?}", e));
|
.map_err(|e| warn!("connection terminated: {:?}", e));
|
||||||
let _ = stream.flush().await;
|
let _ = stream.flush().await;
|
||||||
|
Loading…
Reference in New Issue
Block a user