forked from M-Labs/artiq
firmware: fix TOCTTOU race in sync/async RPC code.
Before this commit, the main loop in session code was laid like: 1. process_kern_queued_rpc 2. process_host_message 3. process_kern_message If a host message (such as an RPC reply) caused the kernel to exit, then any async RPCs would not complete, since RunFinished immediately shuts down the kernel. Fix this by reordering 1 and 2.
This commit is contained in:
parent
59033d2588
commit
0edae64afb
|
@ -502,16 +502,16 @@ fn host_kernel_worker(io: &Io, aux_mutex: &Mutex,
|
||||||
let mut session = Session::new(congress);
|
let mut session = Session::new(congress);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
while !rpc_queue::empty() {
|
|
||||||
process_kern_queued_rpc(stream, &mut session)?
|
|
||||||
}
|
|
||||||
|
|
||||||
if stream.can_recv() {
|
if stream.can_recv() {
|
||||||
process_host_message(io, stream, &mut session)?
|
process_host_message(io, stream, &mut session)?
|
||||||
} else if !stream.may_recv() {
|
} else if !stream.may_recv() {
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while !rpc_queue::empty() {
|
||||||
|
process_kern_queued_rpc(stream, &mut session)?
|
||||||
|
}
|
||||||
|
|
||||||
if mailbox::receive() != 0 {
|
if mailbox::receive() != 0 {
|
||||||
process_kern_message(io, aux_mutex,
|
process_kern_message(io, aux_mutex,
|
||||||
routing_table, up_destinations,
|
routing_table, up_destinations,
|
||||||
|
|
Loading…
Reference in New Issue