X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/08e7455d67920bbd7a87f440d00f2c1e071314a0..b5ce35d0a47049999d7a28185745a2a37e01d7c3:/examples/c/dht-kademlia/dht-kademlia.c diff --git a/examples/c/dht-kademlia/dht-kademlia.c b/examples/c/dht-kademlia/dht-kademlia.c index 9c266fb5b7..9297eafc5b 100644 --- a/examples/c/dht-kademlia/dht-kademlia.c +++ b/examples/c/dht-kademlia/dht-kademlia.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2012-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -50,20 +50,12 @@ static void node(int argc, char* argv[]) sg_mailbox_t mailbox = get_node_mailbox(node->id); while (simgrid_get_clock() < deadline) { - if (node->receive_comm == NULL) - node->receive_comm = sg_mailbox_get_async(mailbox, &node->received_msg); - - if (sg_comm_test(node->receive_comm)) { + const kademlia_message_t msg = receive(node, mailbox); + if (msg) { // There has been a transfer, we need to handle it ! - const kademlia_message_t msg = (kademlia_message_t)(node->received_msg); - if (msg) { - handle_find_node(node, msg); - answer_free(msg->answer); - free(msg); - node->receive_comm = NULL; - } else { - sg_actor_sleep_for(1); - } + handle_find_node(node, msg); + answer_free(msg->answer); + free(msg); } else { /* We search for a pseudo random node */ if (simgrid_get_clock() >= next_lookup_time) { @@ -92,8 +84,8 @@ int main(int argc, char* argv[]) simgrid_init(&argc, argv); /* Check the arguments */ - xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n\tExample: %s msg_platform.xml msg_deployment.xml\n", - argv[0], argv[0]); + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n\tExample: %s platform.xml deployment.xml\n", argv[0], + argv[0]); simgrid_load_platform(argv[1]); simgrid_register_function("node", node);