Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
try to catch some leaks
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 6 Jun 2017 06:30:31 +0000 (08:30 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 6 Jun 2017 06:30:31 +0000 (08:30 +0200)
examples/s4u/dht-chord/node.cpp
include/simgrid/s4u/Activity.hpp
include/simgrid/s4u/Comm.hpp
src/kernel/activity/ActivityImpl.hpp
src/s4u/s4u_activity.cpp
src/s4u/s4u_comm.cpp
src/simix/smx_network.cpp

index 98058a2..02c37e4 100644 (file)
@@ -236,13 +236,13 @@ void Node::checkPredecessor()
   try {
     comm->wait(timeout);
     XBT_DEBUG("Received the answer to my 'Predecessor Alive': my predecessor %d is alive", pred_id_);
   try {
     comm->wait(timeout);
     XBT_DEBUG("Received the answer to my 'Predecessor Alive': my predecessor %d is alive", pred_id_);
-    delete message;
   } catch (xbt_ex& e) {
     if (e.category == timeout_error) {
       XBT_DEBUG("Failed to receive the answer to my 'Predecessor Alive' request");
       pred_id_ = -1;
     }
   }
   } catch (xbt_ex& e) {
     if (e.category == timeout_error) {
       XBT_DEBUG("Failed to receive the answer to my 'Predecessor Alive' request");
       pred_id_ = -1;
     }
   }
+  delete message;
 }
 
 /* Asks its predecessor to a remote node
 }
 
 /* Asks its predecessor to a remote node
index b85daaa..aaa9e38 100644 (file)
@@ -24,8 +24,8 @@ XBT_PUBLIC_CLASS Activity {
   friend void intrusive_ptr_add_ref(Comm * c);
 
 protected:
   friend void intrusive_ptr_add_ref(Comm * c);
 
 protected:
-  Activity();
-  virtual ~Activity();
+  Activity()  = default;
+  ~Activity() = default;
 
 public:
   Activity(Activity const&) = delete;
 
 public:
   Activity(Activity const&) = delete;
index d889b61..45db6ec 100644 (file)
@@ -11,7 +11,6 @@
 #include <simgrid/forward.h>
 #include <simgrid/s4u/Activity.hpp>
 #include <simgrid/s4u/forward.hpp>
 #include <simgrid/forward.h>
 #include <simgrid/s4u/Activity.hpp>
 #include <simgrid/s4u/forward.hpp>
-
 namespace simgrid {
 namespace s4u {
 /** @brief Communication async
 namespace simgrid {
 namespace s4u {
 /** @brief Communication async
index e144296..af36c69 100644 (file)
@@ -46,7 +46,6 @@ namespace activity {
     void ref();
     /** @brief Reduces the refcount */
     void unref();
     void ref();
     /** @brief Reduces the refcount */
     void unref();
-
   private:
     std::atomic_int_fast32_t refcount_{1};
   };
   private:
     std::atomic_int_fast32_t refcount_{1};
   };
index 4e8caaa..157010d 100644 (file)
@@ -15,13 +15,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_activity,s4u,"S4U activities");
 namespace simgrid {
 namespace s4u {
 
 namespace simgrid {
 namespace s4u {
 
-Activity::Activity() {
-
-}
-Activity::~Activity() {
-
-}
-
 void Activity::setRemains(double remains) {
   xbt_assert(state_ == inited, "Cannot change the remaining amount of work once the Activity is started");
   remains_ = remains;
 void Activity::setRemains(double remains) {
   xbt_assert(state_ == inited, "Cannot change the remaining amount of work once the Activity is started");
   remains_ = remains;
index d8c635b..547e39c 100644 (file)
@@ -117,13 +117,17 @@ void Comm::wait() {
     }
   }
   state_ = finished;
     }
   }
   state_ = finished;
+  if (pimpl_)
+    pimpl_->unref();
 }
 }
+
 void Comm::wait(double timeout) {
   xbt_assert(state_ == started || state_ == inited);
 
   if (state_ == started) {
     simcall_comm_wait(pimpl_, timeout);
     state_ = finished;
 void Comm::wait(double timeout) {
   xbt_assert(state_ == started || state_ == inited);
 
   if (state_ == started) {
     simcall_comm_wait(pimpl_, timeout);
     state_ = finished;
+    pimpl_->unref();
     return;
   }
 
     return;
   }
 
@@ -139,6 +143,8 @@ void Comm::wait(double timeout) {
         userData_, timeout, rate_);
   }
   state_ = finished;
         userData_, timeout, rate_);
   }
   state_ = finished;
+  if (pimpl_)
+    pimpl_->unref();
 }
 
 void Comm::send_detached(MailboxPtr dest, void* data, int simulatedSize)
 }
 
 void Comm::send_detached(MailboxPtr dest, void* data, int simulatedSize)
@@ -150,6 +156,7 @@ void Comm::send_detached(MailboxPtr dest, void* data, int simulatedSize)
   res->detached_    = true;
   res->start();
 }
   res->detached_    = true;
   res->start();
 }
+
 s4u::CommPtr Comm::send_async(MailboxPtr dest, void* data, int simulatedSize)
 {
   s4u::CommPtr res = CommPtr(s4u::Comm::send_init(dest));
 s4u::CommPtr Comm::send_async(MailboxPtr dest, void* data, int simulatedSize)
 {
   s4u::CommPtr res = CommPtr(s4u::Comm::send_init(dest));
@@ -173,6 +180,7 @@ void Comm::cancel()
   simgrid::kernel::activity::CommImpl* commPimpl = static_cast<simgrid::kernel::activity::CommImpl*>(pimpl_);
   commPimpl->cancel();
 }
   simgrid::kernel::activity::CommImpl* commPimpl = static_cast<simgrid::kernel::activity::CommImpl*>(pimpl_);
   commPimpl->cancel();
 }
+
 bool Comm::test() {
   xbt_assert(state_ == inited || state_ == started || state_ == finished);
   
 bool Comm::test() {
   xbt_assert(state_ == inited || state_ == started || state_ == finished);
   
@@ -185,6 +193,7 @@ bool Comm::test() {
   
   if(simcall_comm_test(pimpl_)){
     state_ = finished;
   
   if(simcall_comm_test(pimpl_)){
     state_ = finished;
+    pimpl_->unref();
     return true;
   }
   return false;
     return true;
   }
   return false;
index b9e5ced..528ceda 100644 (file)
@@ -129,7 +129,6 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx
 
     other_comm->state = SIMIX_READY;
     other_comm->type = SIMIX_COMM_READY;
 
     other_comm->state = SIMIX_READY;
     other_comm->type = SIMIX_COMM_READY;
-
   }
   src_proc->comms.push_back(other_comm);
 
   }
   src_proc->comms.push_back(other_comm);