forked from M-Labs/artiq
1
0
Fork 0

firmware: accept sessions even when startup kernel is running.

Fixes #625.
Fixes #649.
This commit is contained in:
whitequark 2017-01-27 13:11:38 +00:00
parent 24ce9a057b
commit 6891b5fcfd
1 changed files with 22 additions and 16 deletions

View File

@ -639,27 +639,33 @@ fn respawn<F>(io: &Io, handle: &mut Option<ThreadHandle>, f: F)
} }
pub fn thread(io: Io) { pub fn thread(io: Io) {
let congress = Urc::new(RefCell::new(Congress::new()));
info!("running startup kernel");
match flash_kernel_worker(&io, &mut *borrow_mut!(congress), "startup_kernel") {
Ok(()) => info!("startup kernel finished"),
Err(err) => {
if err.kind() == io::ErrorKind::NotFound {
info!("no startup kernel found")
} else {
error!("startup kernel aborted: {}", err);
}
}
}
BufferLogger::with_instance(|logger| logger.disable_trace_to_uart());
let listener = TcpListener::new(&io, 65535); let listener = TcpListener::new(&io, 65535);
listener.listen(1381).expect("session: cannot listen"); listener.listen(1381).expect("session: cannot listen");
info!("accepting network sessions"); info!("accepting network sessions");
BufferLogger::with_instance(|logger| logger.disable_trace_to_uart());
let congress = Urc::new(RefCell::new(Congress::new()));
let mut kernel_thread = None; let mut kernel_thread = None;
{
let congress = congress.clone();
respawn(&io, &mut kernel_thread, move |io| {
let mut congress = borrow_mut!(congress);
info!("running startup kernel");
match flash_kernel_worker(&io, &mut congress, "startup_kernel") {
Ok(()) => info!("startup kernel finished"),
Err(err) => {
if err.kind() == io::ErrorKind::NotFound {
info!("no startup kernel found")
} else {
error!("startup kernel aborted: {}", err);
}
}
}
})
}
loop { loop {
if listener.can_accept() { if listener.can_accept() {
let mut stream = listener.accept().expect("session: cannot accept"); let mut stream = listener.accept().expect("session: cannot accept");