}
}
- // send the SUCCESSOR_LEAVING to our predecessor
- ChordMessage* succ_msg = new ChordMessage(SUCCESSOR_LEAVING);
- succ_msg->request_id = fingers_[0];
- succ_msg->answer_to = mailbox_;
- XBT_DEBUG("Sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_);
-
- try {
- simgrid::s4u::this_actor::send(simgrid::s4u::Mailbox::byName(std::to_string(pred_id_)), succ_msg, 10, timeout);
- } catch (xbt_ex& e) {
- if (e.category == timeout_error) {
- XBT_DEBUG("Timeout expired when sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_);
- delete succ_msg;
+ if (pred_id_ != -1) {
+ // send the SUCCESSOR_LEAVING to our predecessor (only if I have one)
+ ChordMessage* succ_msg = new ChordMessage(SUCCESSOR_LEAVING);
+ succ_msg->request_id = fingers_[0];
+ succ_msg->answer_to = mailbox_;
+ XBT_DEBUG("Sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_);
+
+ try {
+ simgrid::s4u::this_actor::send(simgrid::s4u::Mailbox::byName(std::to_string(pred_id_)), succ_msg, 10, timeout);
+ } catch (xbt_ex& e) {
+ if (e.category == timeout_error) {
+ XBT_DEBUG("Timeout expired when sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_);
+ delete succ_msg;
+ }
}
}
}
double next_fix_fingers_date = start_time_ + PERIODIC_FIX_FINGERS_DELAY;
double next_check_predecessor_date = start_time_ + PERIODIC_CHECK_PREDECESSOR_DELAY;
double next_lookup_date = start_time_ + PERIODIC_LOOKUP_DELAY;
-
+ simgrid::s4u::CommPtr comm_receive = nullptr;
while ((now < (start_time_ + deadline_)) && now < MAX_SIMULATION_TIME) {
- data = nullptr;
- simgrid::s4u::CommPtr comm_receive = simgrid::s4u::this_actor::irecv(mailbox_, &data);
+ if (comm_receive == nullptr)
+ comm_receive = simgrid::s4u::this_actor::irecv(mailbox_, &data);
while ((now < (start_time_ + deadline_)) && now < MAX_SIMULATION_TIME && not comm_receive->test()) {
// no task was received: make some periodic calls
if (now >= next_stabilize_date) {
if (data != nullptr) {
ChordMessage* message = static_cast<ChordMessage*>(data);
handleMessage(message);
- } else {
- comm_receive->cancel();
+ comm_receive = nullptr;
+ data = nullptr;
}
now = simgrid::s4u::Engine::getClock();
}
/* make sure no one will finish the comm after this process is destroyed,
* because src_proc or dst_proc would be an invalid pointer */
- comm->cancel();
if (comm->src_proc == process) {
XBT_DEBUG("Found an unfinished send comm %p (detached = %d), state %d, src = %p, dst = %p",
}
process->comms.pop_front();
synchro = static_cast<smx_activity_t>(process->comms.front());
+ comm->cancel();
}
XBT_DEBUG("%p should not be run anymore",process);