check
[oweals/gnunet.git] / src / core / gnunet-service-core.c
index 298b5e27717c15fb2b13f683080641a6cafb1b76..f54e4a7a0434537530cbec2904c460ccb6c52ec6 100644 (file)
@@ -1375,6 +1375,7 @@ destroy_active_client_request (void *cls,
 
   peer.hashPubKey = *key;
   n = find_neighbour (&peer);
+  GNUNET_assert (NULL != n);
   GNUNET_CONTAINER_DLL_remove (n->active_client_request_head,
                               n->active_client_request_tail,
                               car);
@@ -1433,6 +1434,11 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
 
 /**
  * Helper function for handle_client_iterate_peers.
+ *
+ * @param cls the 'struct GNUNET_SERVER_TransmitContext' to queue replies
+ * @param key identity of the connected peer
+ * @param value the 'struct Neighbour' for the peer
+ * @return GNUNET_OK (continue to iterate)
  */
 static int
 queue_connect_message (void *cls,
@@ -1516,7 +1522,7 @@ handle_client_iterate_peers (void *cls,
 }
 
 /**
- * Handle CORE_ITERATE_PEERS request.
+ * Handle CORE_ITERATE_PEERS request.  Notify client about existing neighbours.
  *
  * @param cls unused
  * @param client client sending the iteration request
@@ -1531,15 +1537,13 @@ handle_client_have_peer (void *cls,
   struct GNUNET_MessageHeader done_msg;
   struct GNUNET_SERVER_TransmitContext *tc;
   struct GNUNET_PeerIdentity *peer;
-  int msize;
-  /* notify new client about existing neighbours */
 
-  msize = ntohs(message->size);
   tc = GNUNET_SERVER_transmit_context_create (client);
-
-  peer = (struct GNUNET_PeerIdentity *)&message[1];
-  GNUNET_CONTAINER_multihashmap_get_multiple(neighbours, &peer->hashPubKey, &queue_connect_message, tc);
-
+  peer = (struct GNUNET_PeerIdentity *) &message[1];
+  GNUNET_CONTAINER_multihashmap_get_multiple(neighbours,
+                                            &peer->hashPubKey, 
+                                            &queue_connect_message, 
+                                            tc);
   done_msg.size = htons (sizeof (struct GNUNET_MessageHeader));
   done_msg.type = htons (GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS_END);
   GNUNET_SERVER_transmit_context_append_message (tc, &done_msg);
@@ -1550,6 +1554,10 @@ handle_client_have_peer (void *cls,
 
 /**
  * Handle REQUEST_INFO request.
+ *
+ * @param cls unused
+ * @param client client sending the request
+ * @param message iteration request message
  */
 static void
 handle_client_request_info (void *cls,
@@ -1563,7 +1571,9 @@ handle_client_request_info (void *cls,
   int32_t want_reserv;
   int32_t got_reserv;
   unsigned long long old_preference;
+  struct GNUNET_TIME_Relative rdelay;
 
+  rdelay = GNUNET_TIME_relative_get_zero();
 #if DEBUG_CORE_CLIENT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Core service receives `%s' request.\n", "REQUEST_INFO");
@@ -1613,8 +1623,9 @@ handle_client_request_info (void *cls,
         }
       else if (want_reserv > 0)
         {
-         if (GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window,
-                                                 want_reserv).rel_value == 0)
+         rdelay = GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window,
+                                                      want_reserv);
+         if (rdelay.rel_value == 0)
            got_reserv = want_reserv;
          else
             got_reserv = 0; /* all or nothing */
@@ -1639,6 +1650,7 @@ handle_client_request_info (void *cls,
                  (int) got_reserv);
 #endif
       cim.reserved_amount = htonl (got_reserv);
+      cim.reserve_delay = GNUNET_TIME_relative_hton (rdelay);
       cim.rim_id = rcm->rim_id;
       cim.bw_out = n->bw_out;
       cim.preference = n->current_preference;