Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use a smart pointer for RAII.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 9 Mar 2020 11:00:33 +0000 (12:00 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 9 Mar 2020 11:00:33 +0000 (12:00 +0100)
wait_for() may be interrupted (in case of platform failure) and unref() never called.

src/s4u/s4u_Comm.cpp

index e7cc4df..84e27cb 100644 (file)
@@ -267,8 +267,9 @@ sg_error_t sg_comm_wait(sg_comm_t comm)
 {
   sg_error_t status = SG_OK;
 
+  simgrid::s4u::CommPtr comm_ptr(comm, false);
   try {
-    comm->wait_for(-1);
+    comm_ptr->wait_for(-1);
   } catch (const simgrid::TimeoutException&) {
     status = SG_ERROR_TIMEOUT;
   } catch (const simgrid::CancelException&) {
@@ -276,7 +277,6 @@ sg_error_t sg_comm_wait(sg_comm_t comm)
   } catch (const simgrid::NetworkFailureException&) {
     status = SG_ERROR_NETWORK;
   }
-  comm->unref();
   return status;
 }