X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/61ad789615c7b04790836c7d580ef9d26241138c..9d87ca5268acfd15dfaf5068cc40f9d00a03e8c3:/examples/msg/dht-pastry/dht-pastry.c diff --git a/examples/msg/dht-pastry/dht-pastry.c b/examples/msg/dht-pastry/dht-pastry.c index f7f0ccaa40..e4e48097f3 100644 --- a/examples/msg/dht-pastry/dht-pastry.c +++ b/examples/msg/dht-pastry/dht-pastry.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. +/* Copyright (c) 2013-2018. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -6,8 +6,9 @@ #include "simgrid/msg.h" #include "xbt/dynar.h" -#include +#include +#include XBT_LOG_NEW_DEFAULT_CATEGORY(msg_pastry, "Messages specific for this msg example"); @@ -312,7 +313,7 @@ static void handle_task(node_t node, msg_task_t task) { // if the node is ready, do all the pending tasks and send update to known nodes if (node->ready==0) { XBT_DEBUG("Node %i is ready!!!", node->id); - while(xbt_dynar_length(node->pending_tasks)){ + while (!xbt_dynar_is_empty(node->pending_tasks)) { msg_task_t task; xbt_dynar_shift(node->pending_tasks, &task); handle_task(node, task); @@ -378,16 +379,13 @@ static void handle_task(node_t node, msg_task_t task) { // add lower elements j = NAMESPACE_SIZE/2-1; for (i=NAMESPACE_SIZE/2-1; i>=0; i--) { - if (min<0) { + if (min < 0 || curr_namespace_set[j] > task_namespace_set[min]) { node->namespace_set[i] = curr_namespace_set[j]; j--; } else if (curr_namespace_set[j] == task_namespace_set[min]) { node->namespace_set[i] = curr_namespace_set[j]; j--; min--; - } else if (curr_namespace_set[j] > task_namespace_set[min]) { - node->namespace_set[i] = curr_namespace_set[j]; - j--; } else { node->namespace_set[i] = task_namespace_set[min]; min--; @@ -401,19 +399,16 @@ static void handle_task(node_t node, msg_task_t task) { node->namespace_set[i] = curr_namespace_set[j]; j++; } else if (max >= 0){ - if (curr_namespace_set[j] == -1) { + if (curr_namespace_set[j] == -1 || curr_namespace_set[j] > task_namespace_set[max]) { node->namespace_set[i] = task_namespace_set[max]; max++; } else if (curr_namespace_set[j] == task_namespace_set[max]) { node->namespace_set[i] = curr_namespace_set[j]; j++; max++; - } else if (curr_namespace_set[j] < task_namespace_set[max]) { + } else { node->namespace_set[i] = curr_namespace_set[j]; j++; - } else { - node->namespace_set[i] = task_namespace_set[max]; - max++; } } }