]> AND Public Git Repository - simgrid.git/blobdiff - src/smpi/bindings/smpi_mpi.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
[simgrid.git] / src / smpi / bindings / smpi_mpi.cpp
index 7249a491f22263f5fa5d9582585e28d185acf9a8..9f4638777bdf43db51313ae2702cece0cb3380f6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.           */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.           */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license ,(GNU LGPL) which comes with this package. */
@@ -39,12 +39,15 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi, smpi, "Logging specific to SMPI ,(mpi)
       char error_string[MPI_MAX_ERROR_STRING];                                                                         \
       int error_size;                                                                                                  \
       PMPI_Error_string(ret, error_string, &error_size);                                                               \
-      if ((errhan) == nullptr || (errhan)->errhandler() == MPI_ERRORS_RETURN)                                          \
+      MPI_Errhandler err = (errhan) ? (errhan)->errhandler() : MPI_ERRHANDLER_NULL;                                    \
+      if (err == MPI_ERRHANDLER_NULL || err == MPI_ERRORS_RETURN)                                                      \
         XBT_WARN("%s - returned %.*s instead of MPI_SUCCESS", __func__, error_size, error_string);                     \
-      else if ((errhan)->errhandler() == MPI_ERRORS_ARE_FATAL)                                                         \
+      else if (err == MPI_ERRORS_ARE_FATAL)                                                                            \
         xbt_die("%s - returned %.*s instead of MPI_SUCCESS", __func__, error_size, error_string);                      \
       else                                                                                                             \
-        (errhan)->errhandler()->call((errhan), ret);                                                                   \
+        err->call((errhan), ret);                                                                                      \
+      if (err != MPI_ERRHANDLER_NULL)                                                                                  \
+        simgrid::smpi::Errhandler::unref(err);                                                                         \
       MC_assert(not MC_is_active()); /* Only fail in MC mode */                                                        \
     }                                                                                                                  \
     XBT_VERB("SMPI - Leaving %s", __func__);                                                                           \