[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r29478 - gnunet/src/dht
From: |
gnunet |
Subject: |
[GNUnet-SVN] r29478 - gnunet/src/dht |
Date: |
Mon, 23 Sep 2013 12:50:28 +0200 |
Author: grothoff
Date: 2013-09-23 12:50:28 +0200 (Mon, 23 Sep 2013)
New Revision: 29478
Modified:
gnunet/src/dht/dht.conf.in
gnunet/src/dht/gnunet-service-dht_clients.c
gnunet/src/dht/gnunet-service-dht_neighbours.c
Log:
add option to cache blocks from result messages as well
Modified: gnunet/src/dht/dht.conf.in
===================================================================
--- gnunet/src/dht/dht.conf.in 2013-09-23 09:19:19 UTC (rev 29477)
+++ gnunet/src/dht/dht.conf.in 2013-09-23 10:50:28 UTC (rev 29478)
@@ -21,6 +21,8 @@
# REJECT_FROM6 =
# PREFIX =
+# Should the DHT cache results that we are routing in the DATACACHE as well?
+CACHE_RESULTS = YES
# Special option to disable DHT calling 'try_connect' (for testing)
DISABLE_TRY_CONNECT = NO
Modified: gnunet/src/dht/gnunet-service-dht_clients.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_clients.c 2013-09-23 09:19:19 UTC (rev
29477)
+++ gnunet/src/dht/gnunet-service-dht_clients.c 2013-09-23 10:50:28 UTC (rev
29478)
@@ -312,7 +312,7 @@
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 @@
* @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 @@
* 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)
@@ -1021,8 +1024,9 @@
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 @@
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 @@
*
* @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 @@
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))
{
Modified: gnunet/src/dht/gnunet-service-dht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_neighbours.c 2013-09-23 09:19:19 UTC
(rev 29477)
+++ gnunet/src/dht/gnunet-service-dht_neighbours.c 2013-09-23 10:50:28 UTC
(rev 29478)
@@ -378,7 +378,13 @@
unsigned int peers_size;
};
+
/**
+ * Do we cache all results that we are routing in the local datacache?
+ */
+static int cache_results;
+
+/**
* Should routing details be logged to stderr (for debugging)?
*/
static int log_route_details_stderr;
@@ -444,7 +450,7 @@
* on error (same hashcode)
*/
static int
-find_bucket (const struct GNUNET_HashCode * hc)
+find_bucket (const struct GNUNET_HashCode *hc)
{
unsigned int bits;
@@ -462,7 +468,7 @@
/**
* Let GNUnet core know that we like the given peer.
*
- * @param cls the 'struct PeerInfo' of the peer
+ * @param cls the `struct PeerInfo` of the peer
* @param tc scheduler context.
*/
static void
@@ -535,10 +541,12 @@
* @param cls the 'struct BloomConstructorContext'.
* @param key peer identity to add to the bloom filter
* @param value value the peer information (unused)
- * @return GNUNET_YES (we should continue to iterate)
+ * @return #GNUNET_YES (we should continue to iterate)
*/
static int
-add_known_to_bloom (void *cls, const struct GNUNET_HashCode * key, void *value)
+add_known_to_bloom (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct BloomConstructorContext *ctx = cls;
struct GNUNET_HashCode mh;
@@ -678,7 +686,8 @@
* @param peer peer identity this notification is about
*/
static void
-handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
+handle_core_disconnect (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
{
struct PeerInfo *to_remove;
int current_bucket;
@@ -889,12 +898,15 @@
* Differences in the lower bits must count stronger than differences
* in the higher bits.
*
+ * @param target
+ * @param have
* @return 0 if have==target, otherwise a number
* that is larger as the distance between
* the two hash codes increases
*/
static unsigned int
-get_distance (const struct GNUNET_HashCode * target, const struct
GNUNET_HashCode * have)
+get_distance (const struct GNUNET_HashCode *target,
+ const struct GNUNET_HashCode *have)
{
unsigned int bucket;
unsigned int msb;
@@ -1757,7 +1769,7 @@
peer = bucket->head;
while (choice > 0)
{
- GNUNET_assert (peer != NULL);
+ GNUNET_assert (NULL != peer);
peer = peer->next;
choice--;
}
@@ -1788,8 +1800,8 @@
* @param cls closure
* @param peer sender of the request
* @param message message
- * @return GNUNET_OK to keep the connection open,
- * GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ * #GNUNET_SYSERR to close it (signal serious error)
*/
static int
handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
@@ -1930,7 +1942,7 @@
* @param cls closure
* @param message message
* @param peer peer identity this notification is about
- * @return GNUNET_YES (do not cut p2p connection)
+ * @return #GNUNET_YES (do not cut p2p connection)
*/
static int
handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer,
@@ -2051,7 +2063,20 @@
&prm->key,
data,
data_size);
+ if (GNUNET_YES == cache_results)
+ {
+ struct GNUNET_PeerIdentity xput_path[get_path_length + 1 +
put_path_length];
+ memcpy (xput_path, put_path, put_path_length * sizeof (struct
GNUNET_PeerIdentity));
+ memcpy (&xput_path[put_path_length],
+ xget_path,
+ get_path_length * sizeof (struct GNUNET_PeerIdentity));
+
+ GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh
(prm->expiration_time),
+ &prm->key,
+ get_path_length + put_path_length, xput_path,
+ type, data_size, data);
+ }
/* forward to other peers */
GDS_ROUTING_process (type, GNUNET_TIME_absolute_ntoh
(prm->expiration_time),
&prm->key, put_path_length, put_path, get_path_length,
@@ -2084,6 +2109,9 @@
GNUNET_CONFIGURATION_get_value_number (GDS_cfg, "DHT", "bucket_size",
&temp_config_num))
bucket_size = (unsigned int) temp_config_num;
+ cache_results
+ = GNUNET_CONFIGURATION_get_value_yesno (GDS_cfg, "DHT", "CACHE_RESULTS");
+
log_route_details_stderr =
(NULL != getenv("GNUNET_DHT_ROUTE_DEBUG")) ? GNUNET_YES : GNUNET_NO;
atsAPI = GNUNET_ATS_performance_init (GDS_cfg, NULL, NULL);
@@ -2104,7 +2132,7 @@
void
GDS_NEIGHBOURS_done ()
{
- if (coreAPI == NULL)
+ if (NULL == coreAPI)
return;
GNUNET_CORE_disconnect (coreAPI);
coreAPI = NULL;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r29478 - gnunet/src/dht,
gnunet <=