Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make sure that the user don't try a detached receive
[simgrid.git] / src / s4u / s4u_comm.cpp
index 8340bd3..7729d3e 100644 (file)
@@ -23,8 +23,6 @@ Comm::~Comm()
       XBT_INFO("pimpl_ is null");
     xbt_backtrace_display_current();
   }
-  if (pimpl_)
-    pimpl_->unref();
 }
 
 s4u::CommPtr Comm::send_init(s4u::MailboxPtr chan)
@@ -90,6 +88,7 @@ void Comm::start() {
         matchFunction_, cleanFunction_, copyDataFunction_,
         userData_, detached_);
   } else if (dstBuff_ != nullptr) { // Receiver side
+    xbt_assert(not detached_, "Receive cannot be detached");
     pimpl_ = simcall_comm_irecv(receiver_, mailbox_->getImpl(), dstBuff_, &dstBuffSize_,
         matchFunction_, copyDataFunction_,
         userData_, rate_);
@@ -117,8 +116,6 @@ void Comm::wait() {
     }
   }
   state_ = finished;
-  if (pimpl_)
-    pimpl_->unref();
 }
 
 void Comm::wait(double timeout) {
@@ -127,7 +124,6 @@ void Comm::wait(double timeout) {
   if (state_ == started) {
     simcall_comm_wait(pimpl_, timeout);
     state_ = finished;
-    pimpl_->unref();
     return;
   }
 
@@ -143,8 +139,6 @@ void Comm::wait(double timeout) {
         userData_, timeout, rate_);
   }
   state_ = finished;
-  if (pimpl_)
-    pimpl_->unref();
 }
 
 void Comm::send_detached(MailboxPtr dest, void* data, int simulatedSize)
@@ -194,7 +188,6 @@ bool Comm::test() {
 
   if(simcall_comm_test(pimpl_)){
     state_ = finished;
-    pimpl_->unref();
     return true;
   }
   return false;