Skip to content

Commit

Permalink
bug--?
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Dec 9, 2023
1 parent 20dd429 commit 04040c1
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/wrench/simgrid_S4U_util/S4U_CommPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SimulationMessage>(msg_mb);
auto mb_comm = this->s4u_mb->get_async<SimulationMessage>(&msg_mb);
pending_receives.push(mb_comm);
auto mq_comm = this->s4u_mq->get_async<SimulationMessage>(msg_mq);
auto mq_comm = this->s4u_mq->get_async<SimulationMessage>(&msg_mq);
pending_receives.push(mq_comm);

WRENCH_INFO("IN GET MESSAGE: %p(%s) %p(%s)",
Expand All @@ -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>(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>(
NetworkError::RECEIVING, NetworkError::FAILURE, this->name, ""));
} else {
mb_comm->cancel();
pending_receives.erase(mb_comm);
free(msg_mb);
throw ExecutionException(std::make_shared<NetworkError>(
NetworkError::RECEIVING, NetworkError::FAILURE, this->name, ""));
}
Expand All @@ -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();
}

Expand Down Expand Up @@ -317,7 +313,7 @@ namespace wrench {
}
simgrid::s4u::MessPtr mess_ptr = this->s4u_mq->get_async<void>((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;
}

Expand Down

0 comments on commit 04040c1

Please sign in to comment.