diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-09-23 10:50:28 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-09-23 10:50:28 +0000 |
commit | 7bcb01815e30bab21204f1d974f727130b2a7884 (patch) | |
tree | 20baa8c7ab8f6d7e216200ca50730e558adc62aa /src/dht/gnunet-service-dht_clients.c | |
parent | e730bd4b9d68a38b3d4277f6222369de61da8225 (diff) | |
download | gnunet-7bcb01815e30bab21204f1d974f727130b2a7884.tar.gz gnunet-7bcb01815e30bab21204f1d974f727130b2a7884.zip |
add option to cache blocks from result messages as well
Diffstat (limited to 'src/dht/gnunet-service-dht_clients.c')
-rw-r--r-- | src/dht/gnunet-service-dht_clients.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index 70b1500cc..20fbba789 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c | |||
@@ -312,7 +312,7 @@ find_active_client (struct GNUNET_SERVER_Client *client) | |||
312 | return pos; | 312 | return pos; |
313 | pos = pos->next; | 313 | pos = pos->next; |
314 | } | 314 | } |
315 | ret = GNUNET_malloc (sizeof (struct ClientList)); | 315 | ret = GNUNET_new (struct ClientList); |
316 | ret->client_handle = client; | 316 | ret->client_handle = client; |
317 | GNUNET_CONTAINER_DLL_insert (client_head, client_tail, ret); | 317 | GNUNET_CONTAINER_DLL_insert (client_head, client_tail, ret); |
318 | return ret; | 318 | return ret; |
@@ -326,7 +326,7 @@ find_active_client (struct GNUNET_SERVER_Client *client) | |||
326 | * @param cls client to search for in source routes | 326 | * @param cls client to search for in source routes |
327 | * @param key current key code (ignored) | 327 | * @param key current key code (ignored) |
328 | * @param value value in the hash map, a ClientQueryRecord | 328 | * @param value value in the hash map, a ClientQueryRecord |
329 | * @return GNUNET_YES (we should continue to iterate) | 329 | * @return #GNUNET_YES (we should continue to iterate) |
330 | */ | 330 | */ |
331 | static int | 331 | static int |
332 | remove_client_records (void *cls, const struct GNUNET_HashCode * key, void *value) | 332 | 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 | |||
359 | * for the last call when the server is destroyed | 359 | * for the last call when the server is destroyed |
360 | */ | 360 | */ |
361 | static void | 361 | static void |
362 | handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | 362 | handle_client_disconnect (void *cls, |
363 | struct GNUNET_SERVER_Client *client) | ||
363 | { | 364 | { |
364 | struct ClientList *pos; | 365 | struct ClientList *pos; |
365 | struct PendingMessage *reply; | 366 | struct PendingMessage *reply; |
366 | struct ClientMonitorRecord *monitor; | 367 | struct ClientMonitorRecord *monitor; |
367 | 368 | ||
368 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Local client %p disconnects\n", client); | 369 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
370 | "Local client %p disconnects\n", | ||
371 | client); | ||
369 | pos = find_active_client (client); | 372 | pos = find_active_client (client); |
370 | GNUNET_CONTAINER_DLL_remove (client_head, client_tail, pos); | 373 | GNUNET_CONTAINER_DLL_remove (client_head, client_tail, pos); |
371 | if (pos->transmit_handle != NULL) | 374 | if (pos->transmit_handle != NULL) |
@@ -1021,8 +1024,9 @@ forward_reply (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
1021 | struct GNUNET_HashCode ch; | 1024 | struct GNUNET_HashCode ch; |
1022 | unsigned int i; | 1025 | unsigned int i; |
1023 | 1026 | ||
1024 | LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "XDHT CLIENT-RESULT %s @ %u\n", | 1027 | LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, |
1025 | GNUNET_h2s (key), getpid ()); | 1028 | "XDHT CLIENT-RESULT %s\n", |
1029 | GNUNET_h2s (key)); | ||
1026 | if ((record->type != GNUNET_BLOCK_TYPE_ANY) && (record->type != frc->type)) | 1030 | if ((record->type != GNUNET_BLOCK_TYPE_ANY) && (record->type != frc->type)) |
1027 | { | 1031 | { |
1028 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1032 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1108,7 +1112,8 @@ forward_reply (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
1108 | reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1]; | 1112 | reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1]; |
1109 | reply->unique_id = record->unique_id; | 1113 | reply->unique_id = record->unique_id; |
1110 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1114 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1111 | "Queueing reply to query %s for client %p\n", GNUNET_h2s (key), | 1115 | "Queueing reply to query %s for client %p\n", |
1116 | GNUNET_h2s (key), | ||
1112 | record->client->client_handle); | 1117 | record->client->client_handle); |
1113 | add_pending_message (record->client, pm); | 1118 | add_pending_message (record->client, pm); |
1114 | if (GNUNET_YES == do_free) | 1119 | if (GNUNET_YES == do_free) |
@@ -1124,12 +1129,12 @@ forward_reply (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
1124 | * | 1129 | * |
1125 | * @param expiration when will the reply expire | 1130 | * @param expiration when will the reply expire |
1126 | * @param key the query this reply is for | 1131 | * @param key the query this reply is for |
1127 | * @param get_path_length number of peers in 'get_path' | 1132 | * @param get_path_length number of peers in @a get_path |
1128 | * @param get_path path the reply took on get | 1133 | * @param get_path path the reply took on get |
1129 | * @param put_path_length number of peers in 'put_path' | 1134 | * @param put_path_length number of peers in @a put_path |
1130 | * @param put_path path the reply took on put | 1135 | * @param put_path path the reply took on put |
1131 | * @param type type of the reply | 1136 | * @param type type of the reply |
1132 | * @param data_size number of bytes in 'data' | 1137 | * @param data_size number of bytes in @a data |
1133 | * @param data application payload data | 1138 | * @param data application payload data |
1134 | */ | 1139 | */ |
1135 | void | 1140 | void |
@@ -1148,7 +1153,9 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration, | |||
1148 | struct GNUNET_PeerIdentity *paths; | 1153 | struct GNUNET_PeerIdentity *paths; |
1149 | size_t msize; | 1154 | size_t msize; |
1150 | 1155 | ||
1151 | LOG (GNUNET_ERROR_TYPE_DEBUG, "reply for key %s\n", GNUNET_h2s (key)); | 1156 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1157 | "reply for key %s\n", | ||
1158 | GNUNET_h2s (key)); | ||
1152 | 1159 | ||
1153 | if (NULL == GNUNET_CONTAINER_multihashmap_get (forward_map, key)) | 1160 | if (NULL == GNUNET_CONTAINER_multihashmap_get (forward_map, key)) |
1154 | { | 1161 | { |