- SIMIX_action_communicate(t_simdata->sender->simdata->m_host->
- simdata->smx_host,
- process->simdata->m_host->simdata->smx_host,
- t->name, t_simdata->message_size,
- t_simdata->rate);
+ SIMIX_action_communicate(t_simdata->sender->simdata->m_host->simdata->
+ smx_host,
+ process->simdata->m_host->simdata->smx_host,
+ t->name, t_simdata->message_size,
+ t_simdata->rate);
+
+ /* This is a hack. We know that both the receiver and the sender will
+ need to look at the content of t_simdata->comm. And it needs to be
+ destroyed. However, we don't known whether the receiver or the sender
+ will get to it first. So by setting with refcount to 2 we can enforce
+ that things happen correctly. An alternative would be to only do ++ and
+ -- on this refcount and to sprinkle them judiciously throughout the code,
+ which appears perhaps worse? Or perhaps the refcount field of
+ task->simdata can be used for this? At any rate, this will do for now */
+ t_simdata->comm->refcount = 2;