Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Initialize data members with class initializers, or initialization lists.
[simgrid.git] / src / smpi / mpi / smpi_comm.cpp
index d6ca527..ac061c0 100644 (file)
@@ -30,16 +30,8 @@ int Comm::keyval_id_=0;
 
 Comm::Comm(MPI_Group group, MPI_Topology topo, int smp, int in_id) : group_(group), topo_(topo),is_smp_comm_(smp), id_(in_id)
 {
-  refcount_        = 1;
-  topoType_        = MPI_INVALID_TOPO;
-  intra_comm_      = MPI_COMM_NULL;
-  leaders_comm_    = MPI_COMM_NULL;
-  is_uniform_      = 1;
-  non_uniform_map_ = nullptr;
-  leaders_map_     = nullptr;
-  is_blocked_      = 0;
-  info_            = MPI_INFO_NULL;
   errhandler_      = MPI_ERRORS_ARE_FATAL;
+  errhandler_->ref();
   //First creation of comm is done before SIMIX_run, so only do comms for others
   if(in_id==MPI_UNDEFINED && smp==0 && this->rank()!=MPI_UNDEFINED ){
     int id;
@@ -336,6 +328,8 @@ void Comm::unref(Comm* comm){
     comm->cleanup_attr<Comm>();
     if (comm->info_ != MPI_INFO_NULL)
       simgrid::smpi::Info::unref(comm->info_);
+    if (comm->errhandler_ != MPI_ERRHANDLER_NULL)
+      simgrid::smpi::Errhandler::unref(comm->errhandler_);
     delete comm->topo_; // there's no use count on topos
     delete comm;
   }
@@ -421,6 +415,7 @@ void Comm::init_smp(){
       leader_group_size++;
     }
   }
+  xbt_assert(leader_group_size > 0);
   std::sort(leader_list, leader_list + leader_group_size);
 
   MPI_Group leaders_group = new  Group(leader_group_size);
@@ -557,14 +552,20 @@ void Comm::set_info(MPI_Info info)
     info->ref();
 }
 
-MPI_Errhandler Comm::errhandler(){
+MPI_Errhandler Comm::errhandler()
+{
+  if (errhandler_ != MPI_ERRHANDLER_NULL)
+    errhandler_->ref();
   return errhandler_;
 }
 
-void Comm::set_errhandler(MPI_Errhandler errhandler){
-  errhandler_=errhandler;
-  if(errhandler_!= MPI_ERRHANDLER_NULL)
-    errhandler->ref();
+void Comm::set_errhandler(MPI_Errhandler errhandler)
+{
+  if (errhandler_ != MPI_ERRHANDLER_NULL)
+    simgrid::smpi::Errhandler::unref(errhandler_);
+  errhandler_ = errhandler;
+  if (errhandler_ != MPI_ERRHANDLER_NULL)
+    errhandler_->ref();
 }
 
 MPI_Comm Comm::split_type(int type, int /*key*/, MPI_Info)