Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit 68bbeb1

Browse files
committed
If a message can't be allocated on locked heap fallback to fragment
1 parent 1317cbf commit 68bbeb1

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

liblumen_alloc/src/erts/process.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,18 @@ impl ProcessControlBlock {
359359
/// Returns `true` if the process should stop waiting and be rescheduled as runnable.
360360
pub fn send_from_other(&self, data: Term) -> Result<bool, Alloc> {
361361
match self.heap.try_lock() {
362-
Some(ref mut destination_heap) => {
363-
let destination_data = data.clone_to_heap(destination_heap)?;
364-
365-
self.send_message(Message::Process(message::Process {
366-
data: destination_data,
367-
}));
368-
}
362+
Some(ref mut destination_heap) => match data.clone_to_heap(destination_heap) {
363+
Ok(destination_data) => {
364+
self.send_message(Message::Process(message::Process {
365+
data: destination_data,
366+
}));
367+
}
368+
Err(_) => {
369+
let (heap_fragment_data, heap_fragment) = data.clone_to_fragment()?;
370+
371+
self.send_heap_message(heap_fragment, heap_fragment_data);
372+
}
373+
},
369374
None => {
370375
let (heap_fragment_data, heap_fragment) = data.clone_to_fragment()?;
371376

0 commit comments

Comments
 (0)