/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "s4u_dht-chord.hpp"
+#include "s4u-dht-chord.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(s4u_chord);
return i <= e;
}
+void ChordMessage::destroy(void* message)
+{
+ delete static_cast<ChordMessage*>(message);
+}
+
/* Initializes the current node as the first one of the system */
Node::Node(std::vector<std::string> args)
{
}
// receive the answer
XBT_DEBUG("Sent 'Predecessor Alive' request to %d, waiting for the answer on my mailbox '%s'", pred_id_,
- message->answer_to->getName());
+ message->answer_to->getCname());
simgrid::s4u::CommPtr comm = return_mailbox->get_async(&data);
try {
// receive the answer
XBT_DEBUG("Sent 'Get Predecessor' request to %d, waiting for the answer on my mailbox '%s'", ask_to,
- message->answer_to->getName());
+ message->answer_to->getCname());
simgrid::s4u::CommPtr comm = return_mailbox->get_async(&data);
try {
// send a "Notify" request to notify_id
XBT_DEBUG("Sending a 'Notify' request to %d", notify_id);
simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(notify_id));
- mailbox->put_init(message, 10)->detach();
+ mailbox->put_init(message, 10)->detach(ChordMessage::destroy);
}
/* This function is called periodically. It checks the immediate successor of the current node. */
message->type = FIND_SUCCESSOR_ANSWER;
message->answer_id = fingers_[0];
XBT_DEBUG("Sending back a 'Find Successor Answer' to %s (mailbox %s): the successor of %d is %d",
- message->issuer_host_name.c_str(), message->answer_to->getName(), message->request_id,
+ message->issuer_host_name.c_str(), message->answer_to->getCname(), message->request_id,
message->answer_id);
- message->answer_to->put_init(message, 10)->detach();
+ message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy);
} else {
// otherwise, forward the request to the closest preceding finger in my table
int closest = closestPrecedingFinger(message->request_id);
XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d",
message->request_id, closest);
simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(closest));
- mailbox->put_init(message, 10)->detach();
+ mailbox->put_init(message, 10)->detach(ChordMessage::destroy);
}
break;
message->type = GET_PREDECESSOR_ANSWER;
message->answer_id = pred_id_;
XBT_DEBUG("Sending back a 'Get Predecessor Answer' to %s via mailbox '%s': my predecessor is %d",
- message->issuer_host_name.c_str(), message->answer_to->getName(), message->answer_id);
- message->answer_to->put_init(message, 10)->detach();
+ message->issuer_host_name.c_str(), message->answer_to->getCname(), message->answer_id);
+ message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy);
break;
case NOTIFY:
XBT_DEBUG("Receiving a 'Predecessor Alive' request from %s", message->issuer_host_name.c_str());
message->type = PREDECESSOR_ALIVE_ANSWER;
XBT_DEBUG("Sending back a 'Predecessor Alive Answer' to %s (mailbox %s)", message->issuer_host_name.c_str(),
- message->answer_to->getName());
- message->answer_to->put_init(message, 10)->detach();
+ message->answer_to->getCname());
+ message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy);
break;
default: