X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1928b36ff7a719c88d3db6b4e685bed8f544c7da..dd1b2a87a1d03d3f69bcef76a5b75e5fa464e593:/src/simix/smx_network.cpp diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index 072a961a0d..e6ce384b48 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -5,6 +5,10 @@ #include +#include + +#include + #include "src/surf/surf_interface.hpp" #include "src/simix/smx_private.h" #include "xbt/log.h" @@ -43,7 +47,7 @@ smx_mailbox_t SIMIX_mbox_create(const char *name) smx_mailbox_t mbox = (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name); if (!mbox) { - mbox = xbt_new0(s_smx_mailbox_t, 1); + mbox = new s_smx_mailbox_t(); mbox->name = xbt_strdup(name); mbox->comm_queue = new std::deque(); mbox->done_comm_queue = nullptr; // Allocated on need only @@ -62,8 +66,7 @@ void SIMIX_mbox_free(void *data) xbt_free(mbox->name); delete mbox->comm_queue; delete mbox->done_comm_queue; - - xbt_free(mbox); + delete mbox; } smx_mailbox_t SIMIX_mbox_get_by_name(const char *name) @@ -198,7 +201,7 @@ XBT_PRIVATE smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_ if (mbox->permanent_receiver!=nullptr){ //this mailbox is for small messages, which have to be sent right now other_synchro->state = SIMIX_READY; - other_comm->dst_proc=mbox->permanent_receiver; + other_comm->dst_proc=mbox->permanent_receiver.get(); other_comm->ref(); mbox->done_comm_queue->push_back(other_synchro); other_comm->mbox=mbox; @@ -455,6 +458,8 @@ void simcall_HANDLER_comm_testany(smx_simcall_t simcall, xbt_dynar_t synchros) { unsigned int cursor; smx_synchro_t synchro; + // The default result is -1 -- this means, "nothing is ready". + // It can be changed below, but only if something matches. simcall_comm_testany__set__result(simcall, -1); if (MC_is_active() || MC_record_replay_is_active()){ @@ -665,12 +670,22 @@ void SIMIX_comm_finish(smx_synchro_t synchro) } /* if there is an exception during a waitany or a testany, indicate the position of the failed communication */ - if (simcall->issuer->doexception) { - if (simcall->call == SIMCALL_COMM_WAITANY) { - simcall->issuer->running_ctx->exception.value = xbt_dynar_search(simcall_comm_waitany__get__comms(simcall), &synchro); + if (simcall->issuer->exception) { + // In order to modify the exception we have to rethrow it: + try { + std::rethrow_exception(simcall->issuer->exception); + } + catch(xbt_ex& e) { + if (simcall->call == SIMCALL_COMM_WAITANY) { + e.value = xbt_dynar_search(simcall_comm_waitany__get__comms(simcall), &synchro); + } + else if (simcall->call == SIMCALL_COMM_TESTANY) { + e.value = xbt_dynar_search(simcall_comm_testany__get__comms(simcall), &synchro); + } + simcall->issuer->exception = std::make_exception_ptr(e); } - else if (simcall->call == SIMCALL_COMM_TESTANY) { - simcall->issuer->running_ctx->exception.value = xbt_dynar_search(simcall_comm_testany__get__comms(simcall), &synchro); + catch(...) { + // Nothing to do } }