From: Luca Heltai Date: Mon, 2 Dec 2019 17:32:50 +0000 (+0100) Subject: Fixed deadlock. X-Git-Tag: v9.2.0-rc1~828^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9121%2Fhead;p=dealii.git Fixed deadlock. --- 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);