From: Timo Heister <timo.heister@gmail.com>
Date: Mon, 4 Nov 2019 15:53:11 +0000 (-0500)
Subject: move mutex down
X-Git-Tag: v9.2.0-rc1~911^2
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f34fa26a6040b4ede8e4eedd13a20a08098d25d;p=dealii.git

move mutex down
---

diff --git a/include/deal.II/base/mpi_compute_index_owner_internal.h b/include/deal.II/base/mpi_compute_index_owner_internal.h
index b2e63c0a34..3587b2b31e 100644
--- a/include/deal.II/base/mpi_compute_index_owner_internal.h
+++ b/include/deal.II/base/mpi_compute_index_owner_internal.h
@@ -119,10 +119,6 @@ namespace Utilities
             this->partition(owned_indices, comm);
 
 #ifdef DEAL_II_WITH_MPI
-
-            static CollectiveMutex      mutex;
-            CollectiveMutex::ScopedLock lock(mutex, comm);
-
             unsigned int my_rank = this_mpi_process(comm);
 
             types::global_dof_index dic_local_received = 0;
@@ -188,6 +184,10 @@ namespace Utilities
                   }
               }
 
+            // protect the following communication steps using a mutex:
+            static CollectiveMutex      mutex;
+            CollectiveMutex::ScopedLock lock(mutex, comm);
+
             n_dict_procs_in_owned_indices = buffers.size();
             std::vector<MPI_Request> request;
             request.reserve(n_dict_procs_in_owned_indices);