static void erts_cleanup_message(ErtsMessage *mp) { ErlHeapFragment *bp; if (ERTS_SIG_IS_EXTERNAL_MSG(mp) || ERTS_SIG_IS_NON_MSG(mp)) { ErtsDistExternal *edep = erts_proc_sig_get_external(mp); if (edep) { erts_free_dist_ext_copy(edep); if (mp->data.heap_frag == &mp->hfrag) { ASSERT(ERTS_SIG_IS_EXTERNAL_MSG(mp)); mp->data.heap_frag = ERTS_MSG_COMBINED_HFRAG; } } } if (ERTS_SIG_IS_MSG(mp) && mp->data.attached != ERTS_MSG_COMBINED_HFRAG) { bp = mp->data.heap_frag; } else { /* All non msg signals are combined HFRAG messages, but we overwrite the mp->data field with the nm_signal queue ptr so have to fix that here before freeing it. */ mp->data.attached = ERTS_MSG_COMBINED_HFRAG; bp = mp->hfrag.next; erts_cleanup_offheap(&mp->hfrag.off_heap); } if (bp) free_message_buffer(bp); }
Uint erts_msg_attached_data_size_aux(ErtsMessage *msg) { Sint sz; ErtsDistExternal *edep = erts_get_dist_ext(msg->data.heap_frag); ASSERT(ERTS_SIG_IS_EXTERNAL_MSG(msg)); if (edep->heap_size < 0) { sz = erts_decode_dist_ext_size(edep, 1); if (sz < 0) { /* Bad external * We leave the message intact in this case as it's not worth the trouble * to make all callers remove it from queue. It will be detected again * and removed from message queue later anyway. */ return 0; } edep->heap_size = sz; } else { sz = edep->heap_size; } if (is_not_nil(ERL_MESSAGE_TOKEN(msg))) { sz += msg->data.heap_frag->used_size; } return sz; }
void erts_cleanup_messages(ErtsMessage *msgp) { ErtsMessage *mp = msgp; while (mp) { ErtsMessage *fmp; ErlHeapFragment *bp; if (ERTS_SIG_IS_EXTERNAL_MSG(mp)) { if (is_not_immed(ERL_MESSAGE_TOKEN(mp))) { bp = (ErlHeapFragment *) mp->data.dist_ext->ext_endp; erts_cleanup_offheap(&bp->off_heap); } if (mp->data.dist_ext) erts_free_dist_ext_copy(mp->data.dist_ext); } else { if (ERTS_SIG_IS_INTERNAL_MSG(mp) && mp->data.attached != ERTS_MSG_COMBINED_HFRAG) { bp = mp->data.heap_frag; } else { mp->data.attached = ERTS_MSG_COMBINED_HFRAG; bp = mp->hfrag.next; erts_cleanup_offheap(&mp->hfrag.off_heap); } if (bp) free_message_buffer(bp); } fmp = mp; mp = mp->next; erts_free_message(fmp); } }