Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a few codacy treats
[simgrid.git] / examples / msg / dht-chord / dht-chord.c
index 717b19d..1cb3654 100644 (file)
@@ -134,7 +134,7 @@ static void print_finger_table(node_t node)
 }
 
 /* Sets a finger of the current node.
- * 
+ *
  * \param node the current node
  * \param finger_index index of the finger to set (0 to nb_bits - 1)
  * \param id the id to set for this finger
@@ -150,7 +150,7 @@ static void set_finger(node_t node, int finger_index, int id)
 }
 
 /* Sets the predecessor of the current node.
- * 
+ *
  * \param node the current node
  * \param id the id to predecessor, or -1 to unset the predecessor
  */
@@ -169,14 +169,14 @@ static void set_predecessor(node_t node, int predecessor_id)
 }
 
 /* Node main Function
- * 
+ *
  * Arguments:
  * - my id
  * - the id of a guy I know in the system (except for the first node)
  * - the time to sleep before I join (except for the first node)
  */
 /* This function is called when the current node receives a task.
- * 
+ *
  * \param node the current node
  * \param task the task to handle (don't touch it afterward: it will be destroyed, reused or forwarded)
  */
@@ -276,7 +276,7 @@ void create(node_t node)
 }
 
 /* Makes the current node join the ring, knowing the id of a node already in the ring
- * 
+ *
  * \param node the current node
  * \param known_id id of a node already in the ring
  * \return 1 if the join operation succeeded, 0 otherwise
@@ -327,7 +327,6 @@ void quit_notify(node_t node)
   get_mailbox(node->pred_id, mailbox);
   task_data_t req_data_s = xbt_new0(s_task_data_t,1);
   req_data_s->type = TASK_SUCCESSOR_LEAVING;
-  req_data_s->request_id = node->fingers[0].id;
   req_data_s->request_id = node->pred_id;
   get_mailbox(node->id, req_data_s->answer_to);
   req_data_s->issuer_host_name = MSG_host_get_name(MSG_host_self());
@@ -341,7 +340,7 @@ void quit_notify(node_t node)
 }
 
 /* Makes the current node find the successor node of an id.
- * 
+ *
  * \param node the current node
  * \param id the id to find
  * \return the id of the successor node, or -1 if the request failed
@@ -359,7 +358,7 @@ int find_successor(node_t node, int id)
 }
 
 /* \brief Asks another node the successor node of an id.
- * 
+ *
  * \param node the current node
  * \param ask_to the node to ask to
  * \param id the id to find
@@ -368,7 +367,6 @@ int find_successor(node_t node, int id)
 int remote_find_successor(node_t node, int ask_to, int id)
 {
   int successor = -1;
-  int stop = 0;
   char mailbox[MAILBOX_NAME_SIZE];
   get_mailbox(ask_to, mailbox);
   task_data_t req_data = xbt_new0(s_task_data_t, 1);
@@ -386,6 +384,7 @@ int remote_find_successor(node_t node, int ask_to, int id)
     XBT_DEBUG("Failed to send the 'Find Successor' request (task %p) to %d for id %d", task_sent, ask_to, id);
     task_free(task_sent);
   } else {
+    int stop = 0;
     // receive the answer
     XBT_DEBUG("Sent a 'Find Successor' request (task %p) to %d for key %d, waiting for the answer",
         task_sent, ask_to, id);
@@ -448,7 +447,7 @@ int remote_find_successor(node_t node, int ask_to, int id)
 }
 
 /* Asks its predecessor to a remote node
- * 
+ *
  * \param node the current node
  * \param ask_to the node to ask to
  * \return the id of its predecessor node, or -1 if the request failed
@@ -527,7 +526,7 @@ int remote_get_predecessor(node_t node, int ask_to)
 }
 
 /* Returns the closest preceding finger of an id with respect to the finger table of the current node.
- * 
+ *
  * \param node the current node
  * \param id the id to find
  * \return the closest preceding finger of that id