Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 38 additions & 27 deletions kinode/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,37 +1097,48 @@ async fn kernel_message<T: Serialize>(
body: T,
send_to_loop: &MessageSender,
) {
let _ = send_to_loop
.send(KernelMessage {
id: km_id,
source: Address {
node: our.to_string(),
process: ETH_PROCESS_ID.clone(),
},
target,
rsvp,
message: if req {
Message::Request(Request {
let Err(e) = send_to_loop.try_send(KernelMessage {
id: km_id,
source: Address {
node: our.to_string(),
process: ETH_PROCESS_ID.clone(),
},
target,
rsvp,
message: if req {
Message::Request(Request {
inherit: false,
expects_response: timeout,
body: serde_json::to_vec(&body).unwrap(),
metadata: None,
capabilities: vec![],
})
} else {
Message::Response((
Response {
inherit: false,
expects_response: timeout,
body: serde_json::to_vec(&body).unwrap(),
metadata: None,
capabilities: vec![],
})
} else {
Message::Response((
Response {
inherit: false,
body: serde_json::to_vec(&body).unwrap(),
metadata: None,
capabilities: vec![],
},
None,
))
},
lazy_load_blob: None,
})
.await;
},
None,
))
},
lazy_load_blob: None,
}) else {
// not Err -> send successful; done here
return;
};
// its an Err: handle
match e {
tokio::sync::mpsc::error::TrySendError::Closed(_) => {
panic!("(eth) kernel message sender: receiver closed");
}
tokio::sync::mpsc::error::TrySendError::Full(_) => {
// TODO: implement backpressure
panic!("(eth) kernel overloaded with messages: TODO: implement backpressure");
}
}
}

fn find_index(vec: &Vec<&str>, item: &str) -> Option<usize> {
Expand Down
2 changes: 1 addition & 1 deletion kinode/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod terminal;
mod timer;
mod vfs;

const EVENT_LOOP_CHANNEL_CAPACITY: usize = 10_000;
const EVENT_LOOP_CHANNEL_CAPACITY: usize = 100_000;
const EVENT_LOOP_DEBUG_CHANNEL_CAPACITY: usize = 50;
const TERMINAL_CHANNEL_CAPACITY: usize = 32;
const WEBSOCKET_SENDER_CHANNEL_CAPACITY: usize = 32;
Expand Down
15 changes: 14 additions & 1 deletion lib/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,20 @@ impl KernelMessage {
}

pub async fn send(self, sender: &MessageSender) {
sender.send(self).await.expect("kernel message sender died");
let Err(e) = sender.try_send(self) else {
// not Err -> send successful; done here
return;
};
// its an Err: handle
match e {
tokio::sync::mpsc::error::TrySendError::Closed(_) => {
panic!("kernel message sender: receiver closed");
}
tokio::sync::mpsc::error::TrySendError::Full(_) => {
// TODO: implement backpressure
panic!("kernel overloaded with messages: TODO: implement backpressure");
}
}
}
}

Expand Down