Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / mpi / nonblocking.hpp
index ba024c7..a2d2e34 100644 (file)
@@ -59,8 +59,10 @@ wait_any(ForwardIterator first, ForwardIterator last)
   ForwardIterator current = first;
   while (true) {
     // Check if we have found a completed request. If so, return it.
-    if (optional<status> result = current->test())
-      return std::make_pair(*result, current);
+    if (current->m_requests[0] != MPI_REQUEST_NULL &&
+        current->m_requests[1] != MPI_REQUEST_NULL)
+      if (optional<status> result = current->test())
+        return std::make_pair(*result, current);
 
     // Check if this request (and all others before it) are "trivial"
     // requests, e.g., they can be represented with a single