Commit f498e465 authored by Pierre-François's avatar Pierre-François

Detached send to avoid deadlocks

parent f331816e
...@@ -11,7 +11,7 @@ using namespace std; ...@@ -11,7 +11,7 @@ using namespace std;
XBT_LOG_NEW_DEFAULT_CATEGORY(ipp, "ipp"); //!< Logging XBT_LOG_NEW_DEFAULT_CATEGORY(ipp, "ipp"); //!< Logging
void send_message(const std::string & destination_mailbox, IPMessageType type, void * data) void generic_send_message(const std::string & destination_mailbox, IPMessageType type, void * data, bool detached)
{ {
IPMessage * message = new IPMessage; IPMessage * message = new IPMessage;
message->type = type; message->type = type;
...@@ -22,7 +22,27 @@ void send_message(const std::string & destination_mailbox, IPMessageType type, v ...@@ -22,7 +22,27 @@ void send_message(const std::string & destination_mailbox, IPMessageType type, v
XBT_INFO("message from '%s' to '%s' of type '%s' with data %p", XBT_INFO("message from '%s' to '%s' of type '%s' with data %p",
MSG_process_get_name(MSG_process_self()), destination_mailbox.c_str(), ipMessageTypeToString(type).c_str(), data); MSG_process_get_name(MSG_process_self()), destination_mailbox.c_str(), ipMessageTypeToString(type).c_str(), data);
MSG_task_send(task_to_send, destination_mailbox.c_str()); if (detached)
{
MSG_task_dsend(task_to_send, destination_mailbox.c_str(), NULL);
}
else
{
MSG_task_send(task_to_send, destination_mailbox.c_str());
}
XBT_INFO("message from '%s' to '%s' of type '%s' with data %p done",
MSG_process_get_name(MSG_process_self()), destination_mailbox.c_str(), ipMessageTypeToString(type).c_str(), data);
}
void send_message(const std::string & destination_mailbox, IPMessageType type, void * data)
{
generic_send_message(destination_mailbox, type, data, false);
}
void dsend_message(const std::string & destination_mailbox, IPMessageType type, void * data)
{
generic_send_message(destination_mailbox, type, data, true);
} }
std::string ipMessageTypeToString(IPMessageType type) std::string ipMessageTypeToString(IPMessageType type)
...@@ -87,6 +107,12 @@ void send_message(const char *destination_mailbox, IPMessageType type, void *dat ...@@ -87,6 +107,12 @@ void send_message(const char *destination_mailbox, IPMessageType type, void *dat
send_message(str, type, data); send_message(str, type, data);
} }
void dsend_message(const char *destination_mailbox, IPMessageType type, void *data)
{
const string str = destination_mailbox;
dsend_message(str, type, data);
}
IPMessage::~IPMessage() IPMessage::~IPMessage()
{ {
switch (type) switch (type)
......
...@@ -272,6 +272,22 @@ void send_message(const std::string & destination_mailbox, IPMessageType type, v ...@@ -272,6 +272,22 @@ void send_message(const std::string & destination_mailbox, IPMessageType type, v
*/ */
void send_message(const char * destination_mailbox, IPMessageType type, void * data = nullptr); void send_message(const char * destination_mailbox, IPMessageType type, void * data = nullptr);
/**
* @brief Sends a message from the given process to the given mailbox
* @param[in] destination_mailbox The destination mailbox
* @param[in] type The type of message to send
* @param[in] data The data associated to the message
*/
void dsend_message(const std::string & destination_mailbox, IPMessageType type, void * data = nullptr);
/**
* @brief Sends a message from the given process to the given mailbox
* @param[in] destination_mailbox The destination mailbox
* @param[in] type The type of message to send
* @param[in] data The data associated to the message
*/
void dsend_message(const char * destination_mailbox, IPMessageType type, void * data = nullptr);
/** /**
* @brief Transforms a IPMessageType into a std::string * @brief Transforms a IPMessageType into a std::string
* @param[in] type The IPMessageType * @param[in] type The IPMessageType
......
...@@ -229,7 +229,7 @@ int request_reply_scheduler_process(int argc, char *argv[]) ...@@ -229,7 +229,7 @@ int request_reply_scheduler_process(int argc, char *argv[])
case NOP: case NOP:
{ {
xbt_assert(parts2.size() == 2, "Invalid event received ('%s'): NOP messages must be composed of 2 parts separated by ':'", event_string.c_str()); xbt_assert(parts2.size() == 2, "Invalid event received ('%s'): NOP messages must be composed of 2 parts separated by ':'", event_string.c_str());
send_message("server", IPMessageType::SCHED_NOP); dsend_message("server", IPMessageType::SCHED_NOP);
} break; // End of case received_stamp == NOP } break; // End of case received_stamp == NOP
case NOP_ME_LATER: case NOP_ME_LATER:
...@@ -241,7 +241,7 @@ int request_reply_scheduler_process(int argc, char *argv[]) ...@@ -241,7 +241,7 @@ int request_reply_scheduler_process(int argc, char *argv[])
if (message->target_time < MSG_get_clock()) if (message->target_time < MSG_get_clock())
XBT_WARN("Event '%s' tells to wait until time %g but it is already reached", event_string.c_str(), message->target_time); XBT_WARN("Event '%s' tells to wait until time %g but it is already reached", event_string.c_str(), message->target_time);
send_message("server", IPMessageType::SCHED_NOP_ME_LATER, (void*) message); dsend_message("server", IPMessageType::SCHED_NOP_ME_LATER, (void*) message);
} break; // End of case received_stamp == NOP_ME_LATER } break; // End of case received_stamp == NOP_ME_LATER
case STATIC_JOB_ALLOCATION: case STATIC_JOB_ALLOCATION:
......
...@@ -113,7 +113,7 @@ int uds_server_process(int argc, char *argv[]) ...@@ -113,7 +113,7 @@ int uds_server_process(int argc, char *argv[])
msg->job_id = message->job_id; msg->job_id = message->job_id;
Submitter * submitter = origin_of_jobs.at(message->job_id); Submitter * submitter = origin_of_jobs.at(message->job_id);
send_message(submitter->mailbox, IPMessageType::SUBMITTER_CALLBACK, (void*) msg); dsend_message(submitter->mailbox, IPMessageType::SUBMITTER_CALLBACK, (void*) msg);
origin_of_jobs.erase(message->job_id); origin_of_jobs.erase(message->job_id);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment