From: Martin Quinson Date: Thu, 6 Apr 2017 14:57:19 +0000 (+0200) Subject: be more robust to plugins creating processes a bit early X-Git-Tag: v3.16~372 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/323124aa9c477698fe9e0670c3a0ad4d41af5b22 be more robust to plugins creating processes a bit early --- diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index df96ad7120..9e256c9b72 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -237,13 +237,8 @@ void SIMIX_maestro_create(void (*code)(void*), void* data) * * \return the process created */ -smx_actor_t SIMIX_process_create( - const char *name, - std::function code, - void *data, - sg_host_t host, - xbt_dict_t properties, - smx_actor_t parent_process) +smx_actor_t SIMIX_process_create(const char* name, std::function code, void* data, simgrid::s4u::Host* host, + xbt_dict_t properties, smx_actor_t parent_process) { XBT_DEBUG("Start process %s on host '%s'", name, host->cname()); @@ -285,6 +280,10 @@ smx_actor_t SIMIX_process_create( /* Add properties */ process->properties = properties; + /* Make sure that the process is initialized for simix, in case we are called from the Host::onCreation signal */ + if (host->extension() == nullptr) + host->extension_set(new simgrid::simix::Host()); + /* Add the process to it's host process list */ xbt_swag_insert(process, host->extension()->process_list); diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index dfcf0bac9f..a8538f4ee6 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -228,7 +228,8 @@ void SIMIX_global_init(int *argc, char **argv) sg_platf_init(); simgrid::s4u::onPlatformCreated.connect(SIMIX_post_create_environment); simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) { - host.extension_set(new simgrid::simix::Host()); + if (host.extension() == nullptr) // another callback to the same signal may have created it + host.extension_set(new simgrid::simix::Host()); }); simgrid::surf::storageCreatedCallbacks.connect([](simgrid::surf::Storage* storage) {