fix #3284: support lib/MULTIARCH/ paths in installation, use GNUNET_PREFIX=@libdir...
[oweals/gnunet.git] / src / dht / gnunet-service-dht_clients.c
index e15893bed9a9f648c2a58b479ab447484f58b7a3..5195fa3ecc2d0ddde693626eb9165355bc96efe3 100644 (file)
@@ -199,7 +199,7 @@ struct ClientMonitorRecord
    * Previous element in DLL.
    */
   struct ClientMonitorRecord    *prev;
-  
+
   /**
    * Type of blocks that are of interest
    */
@@ -312,7 +312,7 @@ find_active_client (struct GNUNET_SERVER_Client *client)
       return pos;
     pos = pos->next;
   }
-  ret = GNUNET_malloc (sizeof (struct ClientList));
+  ret = GNUNET_new (struct ClientList);
   ret->client_handle = client;
   GNUNET_CONTAINER_DLL_insert (client_head, client_tail, ret);
   return ret;
@@ -326,7 +326,7 @@ find_active_client (struct GNUNET_SERVER_Client *client)
  * @param cls client to search for in source routes
  * @param key current key code (ignored)
  * @param value value in the hash map, a ClientQueryRecord
- * @return GNUNET_YES (we should continue to iterate)
+ * @return #GNUNET_YES (we should continue to iterate)
  */
 static int
 remove_client_records (void *cls, const struct GNUNET_HashCode * key, void *value)
@@ -359,13 +359,16 @@ remove_client_records (void *cls, const struct GNUNET_HashCode * key, void *valu
  *        for the last call when the server is destroyed
  */
 static void
-handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
+handle_client_disconnect (void *cls,
+                         struct GNUNET_SERVER_Client *client)
 {
   struct ClientList *pos;
   struct PendingMessage *reply;
   struct ClientMonitorRecord *monitor;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Local client %p disconnects\n", client);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Local client %p disconnects\n",
+             client);
   pos = find_active_client (client);
   GNUNET_CONTAINER_DLL_remove (client_head, client_tail, pos);
   if (pos->transmit_handle != NULL)
@@ -381,7 +384,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
     if (monitor->client == pos)
     {
       struct ClientMonitorRecord *next;
-      
+
       GNUNET_free_non_null (monitor->key);
       next = monitor->next;
       GNUNET_CONTAINER_DLL_remove (monitor_head, monitor_tail, monitor);
@@ -461,11 +464,11 @@ transmit_next_request_task (void *cls,
   {
     cqr->hnode = NULL;
     delay = GNUNET_TIME_absolute_get_remaining (cqr->retry_time);
-    if (delay.rel_value > 0)
+    if (delay.rel_value_us > 0)
     {
       cqr->hnode =
           GNUNET_CONTAINER_heap_insert (retry_heap, cqr,
-                                        cqr->retry_time.abs_value);
+                                        cqr->retry_time.abs_value_us);
       retry_task =
           GNUNET_SCHEDULER_add_delayed (delay, &transmit_next_request_task,
                                         NULL);
@@ -474,7 +477,7 @@ transmit_next_request_task (void *cls,
     transmit_request (cqr);
     cqr->hnode =
         GNUNET_CONTAINER_heap_insert (retry_heap, cqr,
-                                      cqr->retry_time.abs_value);
+                                      cqr->retry_time.abs_value_us);
   }
 }
 
@@ -547,7 +550,7 @@ handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client,
                            &dht_msg[1],
                            size - sizeof (struct GNUNET_DHT_ClientPutMessage));
   GNUNET_CONTAINER_bloomfilter_free (peer_bf);
-  pm = GNUNET_malloc (sizeof (struct PendingMessage) + 
+  pm = GNUNET_malloc (sizeof (struct PendingMessage) +
                      sizeof (struct GNUNET_DHT_ClientPutConfirmationMessage));
   conf = (struct GNUNET_DHT_ClientPutConfirmationMessage *) &pm[1];
   conf->header.size = htons (sizeof (struct GNUNET_DHT_ClientPutConfirmationMessage));
@@ -819,7 +822,7 @@ handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client,
   const struct GNUNET_DHT_MonitorStartStopMessage *msg;
 
   msg = (struct GNUNET_DHT_MonitorStartStopMessage *) message;
-  r = GNUNET_malloc (sizeof(struct ClientMonitorRecord));
+  r = GNUNET_new (struct ClientMonitorRecord);
 
   r->client = find_active_client(client);
   r->type = ntohl(msg->type);
@@ -830,7 +833,7 @@ handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client,
       r->key = NULL;
   else
   {
-    r->key = GNUNET_malloc (sizeof (struct GNUNET_HashCode));
+    r->key = GNUNET_new (struct GNUNET_HashCode);
     memcpy (r->key, &msg->key, sizeof (struct GNUNET_HashCode));
   }
   GNUNET_CONTAINER_DLL_insert (monitor_head, monitor_tail, r);
@@ -881,7 +884,7 @@ handle_dht_local_monitor_stop (void *cls, struct GNUNET_SERVER_Client *client,
     }
     r = r->next;
   }
+
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
@@ -1020,9 +1023,10 @@ forward_reply (void *cls, const struct GNUNET_HashCode * key, void *value)
   int do_free;
   struct GNUNET_HashCode ch;
   unsigned int i;
-
-  LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "XDHT CLIENT-RESULT %s @ %u\n",
-               GNUNET_h2s (key), getpid ());
+  
+  LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
+              "XDHT CLIENT-RESULT %s\n",
+               GNUNET_h2s (key));
   if ((record->type != GNUNET_BLOCK_TYPE_ANY) && (record->type != frc->type))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1108,7 +1112,8 @@ forward_reply (void *cls, const struct GNUNET_HashCode * key, void *value)
   reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1];
   reply->unique_id = record->unique_id;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Queueing reply to query %s for client %p\n", GNUNET_h2s (key),
+       "Queueing reply to query %s for client %p\n",
+       GNUNET_h2s (key),
        record->client->client_handle);
   add_pending_message (record->client, pm);
   if (GNUNET_YES == do_free)
@@ -1124,12 +1129,12 @@ forward_reply (void *cls, const struct GNUNET_HashCode * key, void *value)
  *
  * @param expiration when will the reply expire
  * @param key the query this reply is for
- * @param get_path_length number of peers in 'get_path'
+ * @param get_path_length number of peers in @a get_path
  * @param get_path path the reply took on get
- * @param put_path_length number of peers in 'put_path'
+ * @param put_path_length number of peers in @a put_path
  * @param put_path path the reply took on put
  * @param type type of the reply
- * @param data_size number of bytes in 'data'
+ * @param data_size number of bytes in @a data
  * @param data application payload data
  */
 void
@@ -1148,7 +1153,9 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
   struct GNUNET_PeerIdentity *paths;
   size_t msize;
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "reply for key %s\n", GNUNET_h2s (key));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "reply for key %s\n",
+       GNUNET_h2s (key));
 
   if (NULL == GNUNET_CONTAINER_multihashmap_get (forward_map, key))
   {
@@ -1191,6 +1198,7 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
   frc.type = type;
   GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, key, &forward_reply,
                                               &frc);
+
   if (GNUNET_NO == frc.do_copy)
   {
     /* did not match any of the requests, free! */
@@ -1219,7 +1227,7 @@ void
 GDS_CLIENTS_process_get (uint32_t options,
                          enum GNUNET_BLOCK_Type type,
                          uint32_t hop_count,
-                         uint32_t desired_replication_level, 
+                         uint32_t desired_replication_level,
                          unsigned int path_length,
                          const struct GNUNET_PeerIdentity *path,
                          const struct GNUNET_HashCode * key)
@@ -1379,7 +1387,7 @@ void
 GDS_CLIENTS_process_put (uint32_t options,
                          enum GNUNET_BLOCK_Type type,
                          uint32_t hop_count,
-                         uint32_t desired_replication_level, 
+                         uint32_t desired_replication_level,
                          unsigned int path_length,
                          const struct GNUNET_PeerIdentity *path,
                          struct GNUNET_TIME_Absolute exp,