From a194eba74fb223219d19e9d5c967c17b2e41122e Mon Sep 17 00:00:00 2001 From: Luke Roberts Date: Tue, 5 Nov 2024 10:21:13 -0700 Subject: [PATCH] Check that send buffers are completed before deleting --- src/bvals/comms/combined_buffers.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bvals/comms/combined_buffers.hpp b/src/bvals/comms/combined_buffers.hpp index d8598174d2f8..79ecd8ecbb65 100644 --- a/src/bvals/comms/combined_buffers.hpp +++ b/src/bvals/comms/combined_buffers.hpp @@ -159,8 +159,15 @@ struct CombinedBuffers { } void clear() { - // TODO(LFR): Need to be more careful here that the asynchronous send buffers are - // finished + bool can_delete; + do { + can_delete = true; + for (auto &[p, cbr] : combined_send_buffers) { + for (auto &[r, cbrp] : cbr.combined_bufs) { + can_delete = cbrp.IsAvailableForWrite() && can_delete; + } + } + } while (!can_delete); combined_send_buffers.clear(); combined_recv_buffers.clear(); processing_messages.clear();