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,10 +639,21 @@ fn respawn<F>(io: &Io, handle: &mut Option<ThreadHandle>, f: F)
} }
pub fn thread(io: Io) { pub fn thread(io: Io) {
let listener = TcpListener::new(&io, 65535);
listener.listen(1381).expect("session: cannot listen");
info!("accepting network sessions");
BufferLogger::with_instance(|logger| logger.disable_trace_to_uart());
let congress = Urc::new(RefCell::new(Congress::new())); let congress = Urc::new(RefCell::new(Congress::new()));
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"); info!("running startup kernel");
match flash_kernel_worker(&io, &mut *borrow_mut!(congress), "startup_kernel") { match flash_kernel_worker(&io, &mut congress, "startup_kernel") {
Ok(()) => info!("startup kernel finished"), Ok(()) => info!("startup kernel finished"),
Err(err) => { Err(err) => {
if err.kind() == io::ErrorKind::NotFound { if err.kind() == io::ErrorKind::NotFound {
@ -652,14 +663,9 @@ pub fn thread(io: Io) {
} }
} }
} }
})
}
BufferLogger::with_instance(|logger| logger.disable_trace_to_uart());
let listener = TcpListener::new(&io, 65535);
listener.listen(1381).expect("session: cannot listen");
info!("accepting network sessions");
let mut kernel_thread = None;
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");