From 9f80dde7c768af51a942df6864d2ee9cf773faca Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Mon, 2 Dec 2019 18:32:50 +0100 Subject: [PATCH] Fixed deadlock. --- include/deal.II/base/mpi.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/deal.II/base/mpi.h b/include/deal.II/base/mpi.h index 9af1832740..5b3dbc87f6 100644 --- a/include/deal.II/base/mpi.h +++ b/include/deal.II/base/mpi.h @@ -1500,13 +1500,16 @@ namespace Utilities else send_to.emplace_back(m.first); - // Shortcut, when running in serial - if (send_to.size() == 0) - return received_objects; - const auto n_point_point_communications = Utilities::MPI::compute_n_point_to_point_communications(comm, send_to); + // If we have something to send, or we expect something from other + // processors, we need to visit one of the two scopes below. Otherwise, + // no other action is required by this mpi process, and we can safely + // return. + if (send_to.size() == 0 && n_point_point_communications == 0) + return received_objects; + // Protect the following communication: static CollectiveMutex mutex; CollectiveMutex::ScopedLock lock(mutex, comm); -- 2.39.5