Skip to content

Commit

Permalink
fix(Kernels): When searching for running kernels also check against name
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Dec 7, 2021
1 parent 5022eb5 commit 1fde46c
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions rust/kernels/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ impl MetaKernel {
macro_rules! microkernel_new {
($feat:literal, $crat:ident, $select:expr) => {
#[cfg(feature = $feat)]
let kernel = $crat::new();
if kernel.spec().matches($select) && kernel.available().await {
return Ok(MetaKernel::Micro(kernel));
{
let kernel = $crat::new();
if kernel.spec().matches($select) && kernel.available().await {
return Ok(MetaKernel::Micro(kernel));
}
}
};
}
Expand Down Expand Up @@ -390,10 +392,10 @@ impl KernelSpace {
///
/// Returns the kernel's id.
async fn ensure(&mut self, selector: &str) -> Result<KernelId> {
// Is there already a running kernel capable of executing the language?
// Is there already a running kernel with a nam or language matching the selector?
for (kernel_id, kernel) in self.kernels.iter_mut() {
let spec = kernel.spec();
if !spec.languages.contains(&selector.to_string()) {
if !(spec.name == selector || spec.languages.contains(&selector.to_string())) {
// Not a match, so keep looking
continue;
}
Expand All @@ -405,6 +407,7 @@ impl KernelSpace {
continue;
}
};

match status {
// For these, use the existing kernel
KernelStatus::Pending
Expand Down Expand Up @@ -532,9 +535,11 @@ pub async fn available() -> Result<Vec<Kernel>> {
macro_rules! microkernel_available {
($feat:literal, $crat:ident, $list:expr) => {
#[cfg(feature = $feat)]
let kernel = $crat::new();
if kernel.available().await {
$list.push(kernel.spec())
{
let kernel = $crat::new();
if kernel.available().await {
$list.push(kernel.spec())
}
}
};
}
Expand Down

0 comments on commit 1fde46c

Please sign in to comment.