diff --git a/src/wrench/simgrid_S4U_util/S4U_CommPort.cpp b/src/wrench/simgrid_S4U_util/S4U_CommPort.cpp index 8712b34296..8dcb3badb6 100755 --- a/src/wrench/simgrid_S4U_util/S4U_CommPort.cpp +++ b/src/wrench/simgrid_S4U_util/S4U_CommPort.cpp @@ -108,14 +108,14 @@ namespace wrench { if (log) WRENCH_DEBUG("Getting a message from commport '%s' with timeout %lf sec", this->s4u_mb->get_cname(), timeout); - SimulationMessage **msg_mb = (SimulationMessage**)malloc(1*sizeof(SimulationMessage*)); - SimulationMessage **msg_mq = (SimulationMessage**)malloc(1*sizeof(SimulationMessage*)); + SimulationMessage *msg_mb; + SimulationMessage *msg_mq; WRENCH_INFO("IN GET MESSAGE FOR COMMPORT %p", this); simgrid::s4u::ActivitySet pending_receives; - auto mb_comm = this->s4u_mb->get_async(msg_mb); + auto mb_comm = this->s4u_mb->get_async(&msg_mb); pending_receives.push(mb_comm); - auto mq_comm = this->s4u_mq->get_async(msg_mq); + auto mq_comm = this->s4u_mq->get_async(&msg_mq); pending_receives.push(mq_comm); WRENCH_INFO("IN GET MESSAGE: %p(%s) %p(%s)", @@ -134,26 +134,22 @@ namespace wrench { if (failed_recv == mb_comm) { mq_comm->cancel(); pending_receives.erase(mq_comm); - free(msg_mq); } else if (failed_recv == mq_comm) { mb_comm->cancel(); pending_receives.erase(mb_comm); - free(msg_mb); } throw ExecutionException(std::make_shared(NetworkError::RECEIVING, NetworkError::TIMEOUT, this->name, "")); } catch (simgrid::Exception &e) { WRENCH_INFO("IN THAT TRY CATCH"); auto failed_recv = pending_receives.get_failed_activity(); if (failed_recv == mb_comm) { - mq_comm->cancel(); - pending_receives.erase(mq_comm); - free(msg_mq); + mq_comm->cancel(); + pending_receives.erase(mq_comm); throw ExecutionException(std::make_shared( NetworkError::RECEIVING, NetworkError::FAILURE, this->name, "")); } else { mb_comm->cancel(); pending_receives.erase(mb_comm); - free(msg_mb); throw ExecutionException(std::make_shared( NetworkError::RECEIVING, NetworkError::FAILURE, this->name, "")); } @@ -165,19 +161,19 @@ namespace wrench { WRENCH_INFO("XXX IN GET MESSAGE BEFORE CANCEL"); if (finished_recv == mb_comm) { - msg = *msg_mb; + msg = msg_mb; WRENCH_INFO("IT WAS THE MB_COM"); WRENCH_INFO("CANCELING %p", mq_comm.get()); mq_comm->cancel(); pending_receives.erase(mq_comm); - free(msg_mq); + pending_receives.erase(mb_comm); WRENCH_INFO("WAITING ON %p", mb_comm.get()); // mb_comm->wait(); } else if (finished_recv == mq_comm) { - msg = *msg_mq; + msg = msg_mq; mb_comm->cancel(); pending_receives.erase(mb_comm); - free(msg_mb); + pending_receives.erase(mq_comm); // mq_comm->wait(); } @@ -317,7 +313,7 @@ namespace wrench { } simgrid::s4u::MessPtr mess_ptr = this->s4u_mq->get_async((void **) (&(pending_communication->simulation_message))); pending_communication->mess_ptr = mess_ptr; - std::cerr << "in IGETMESSAGE MQ " << mess_ptr.get() << "\n"; + std::cerr << "in IGETMESSAGE MQ " << mess_ptr.get() << "\n"; return pending_communication; }