if (GNUNET_NO == rh->message->in_pending_queue)
{
+#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Retransmitting request related to %s to DHT %p\n",
GNUNET_h2s (key),
handle);
+#endif
GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail,
rh->message);
rh->message->in_pending_queue = GNUNET_YES;
{
struct GNUNET_DHT_Handle *handle = cls;
+#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Reconnecting with DHT %p\n",
handle);
+#endif
handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
if (handle->retry_time.rel_value < GNUNET_CONSTANTS_SERVICE_RETRY.rel_value)
handle->retry_time = GNUNET_CONSTANTS_SERVICE_RETRY;
handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
if (GNUNET_YES != try_connect (handle))
{
+#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG, "dht reconnect failed(!)\n");
+#endif
return;
}
GNUNET_CONTAINER_multihashmap_iterate (handle->active_requests,
handle->th = NULL;
if (buf == NULL)
{
+#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Transmission to DHT service failed! Reconnecting!\n");
+#endif
do_disconnect (handle);
return 0;
}
if (dht_msg->unique_id != get_handle->unique_id)
{
/* UID mismatch */
+#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Ignoring reply for %s: UID mismatch: %llu/%llu\n",
GNUNET_h2s (key),
dht_msg->unique_id, get_handle->unique_id);
+#endif
return GNUNET_YES;
}
msize = ntohs (dht_msg->header.size);
return GNUNET_NO;
}
data_length = msize - meta_length;
+#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Giving %u byte reply for %s to application\n",
(unsigned int) data_length,
GNUNET_h2s (key));
+#endif
put_path = (const struct GNUNET_PeerIdentity *) &dht_msg[1];
get_path = &put_path[put_path_length];
data = &get_path[get_path_length];
if (msg == NULL)
{
+#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Error receiving data from DHT service, reconnecting\n");
+#endif
do_disconnect (handle);
return;
}
return;
}
dht_msg = (const struct GNUNET_DHT_ClientResultMessage *) msg;
+#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received reply for `%s' from DHT service %p\n",
GNUNET_h2s (&dht_msg->key),
handle);
+#endif
GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_requests,
&dht_msg->key, &process_reply,
(void *) dht_msg);
GNUNET_break (0);
return NULL;
}
+#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Sending query for %s to DHT %p\n",
GNUNET_h2s (key),
handle);
+#endif
pending = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
get_msg = (struct GNUNET_DHT_ClientGetMessage *) &pending[1];
pending->msg = &get_msg->header;
handle = get_handle->message->handle;
get_msg =
(const struct GNUNET_DHT_ClientGetMessage *) get_handle->message->msg;
+#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Sending STOP for %s to DHT via %p\n",
GNUNET_h2s (&get_msg->key),
handle);
+#endif
/* generate STOP */
pending =
GNUNET_malloc (sizeof (struct PendingMessage) +
#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
+#define DEBUG_DHT GNUNET_EXTRA_LOGGING
+
/**
* Configuration we use.
*/
if (record->client != client)
return GNUNET_YES;
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Removing client %p's record for key %s\n",
client,
GNUNET_h2s (key));
+#endif
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (forward_map,
key, record));
struct ClientList *pos;
struct PendingMessage *reply;
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Local client %p disconnects\n",
client);
+#endif
pos = find_active_client (client);
GNUNET_CONTAINER_DLL_remove (client_head,
client_tail,
GNUNET_NO);
dht_msg = (const struct GNUNET_DHT_ClientPutMessage *) message;
/* give to local clients */
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Handling local PUT of %u-bytes for query %s\n",
size - sizeof (struct GNUNET_DHT_ClientPutMessage),
GNUNET_h2s (&dht_msg->key));
+#endif
GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
&dht_msg->key,
0, NULL,
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# GET requests received from clients"), 1,
GNUNET_NO);
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received request for %s from local client %p\n",
GNUNET_h2s (&get->key),
client);
+#endif
cqr = GNUNET_malloc (sizeof (struct ClientQueryRecord) + xquery_size);
cqr->key = get->key;
cqr->client = find_active_client (client);
if (record->unique_id != ctx->unique_id)
return GNUNET_YES;
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Removing client %p's record for key %s (by unique id)\n",
ctx->client->client_handle,
GNUNET_h2s (key));
+#endif
return remove_client_records (ctx->client, key, record);
}
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# GET STOP requests received from clients"), 1,
GNUNET_NO);
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client %p stopped request for key %s\n",
client,
GNUNET_h2s (&dht_stop_msg->key));
+#endif
ctx.client = find_active_client (client);
ctx.unique_id = dht_stop_msg->unique_id;
GNUNET_CONTAINER_multihashmap_get_multiple (forward_map,
if (buf == NULL)
{
/* client disconnected */
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client %p disconnected, pending messages will be discarded\n",
client->client_handle);
+#endif
return 0;
}
off = 0;
reply);
memcpy (&cbuf[off], reply->msg, msize);
GNUNET_free (reply);
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting %u bytes to client %p\n",
msize,
client->client_handle);
+#endif
off += msize;
}
process_pending_messages (client);
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitted %u/%u bytes to client %p\n",
(unsigned int) off,
(unsigned int) size,
client->client_handle);
+#endif
return off;
}
{
if ((client->pending_head == NULL) || (client->transmit_handle != NULL))
{
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Not asking for transmission to %p now: %s\n",
client->client_handle,
client->pending_head == NULL
? "no more messages"
: "request already pending");
+#endif
return;
}
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking for transmission of %u bytes to client %p\n",
ntohs (client->pending_head->
msg->size),
client->client_handle);
+#endif
client->transmit_handle =
GNUNET_SERVER_notify_transmit_ready (client->client_handle,
ntohs (client->pending_head->
if ( (record->type != GNUNET_BLOCK_TYPE_ANY) &&
(record->type != frc->type) )
{
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Record type missmatch, not passing request for key %s to local client\n",
GNUNET_h2s (key));
+#endif
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# Key match, type mismatches in REPLY to CLIENT"), 1,
GNUNET_NO);
&ch,
sizeof (GNUNET_HashCode)))
{
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Duplicate reply, not passing request for key %s to local client\n",
GNUNET_h2s (key));
+#endif
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# Duplicate REPLIES to CLIENT request dropped"), 1,
GNUNET_NO);
record->xquery_size,
frc->data,
frc->data_size);
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Evaluation result is %d for key %s for local client's query\n",
(int) eval,
GNUNET_h2s (key));
+#endif
switch (eval)
{
case GNUNET_BLOCK_EVALUATION_OK_LAST:
GNUNET_NO);
reply = (struct GNUNET_DHT_ClientResultMessage*) &pm[1];
reply->unique_id = record->unique_id;
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Queueing reply to query %s for client %p\n",
GNUNET_h2s (key),
record->client->client_handle);
+#endif
add_pending_message (record->client, pm);
if (GNUNET_YES == do_free)
remove_client_records (record->client, key, record);
if (datacache == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "%s request received, but have no datacache!\n",
+ _("%s request received, but have no datacache!\n"),
"PUT");
return;
}
ctx->xquery_size,
rdata,
rdata_size);
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found reply for query %s in datacache, evaluation result is %d\n",
GNUNET_h2s (key),
(int) eval);
+#endif
ctx->eval = eval;
switch (eval)
{
gettext_noop ("# Unsupported RESULTS found in datacache"), 1,
GNUNET_NO);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unsupported block type (%u) in local response!\n",
+ _("Unsupported block type (%u) in local response!\n"),
type);
break;
}
GNUNET_HashCode mh;
GNUNET_BLOCK_mingle_hash (key, ctx->bf_mutator, &mh);
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Adding known peer (%s) to bloomfilter for FIND PEER with mutation %u\n",
GNUNET_h2s (key),
ctx->bf_mutator);
+#endif
GNUNET_CONTAINER_bloomfilter_add (ctx->bloom, &mh);
return GNUNET_YES;
}
/* Check for connect to self message */
if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Connected %s to %s\n",
GNUNET_i2s (&my_identity),
GNUNET_h2s (&peer->hashPubKey));
+#endif
if (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_contains (all_known_peers,
&peer->hashPubKey))
/* Check for disconnect from self message */
if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Disconnected %s from %s\n",
GNUNET_i2s (&my_identity),
GNUNET_h2s (&peer->hashPubKey));
+#endif
to_remove =
GNUNET_CONTAINER_multihashmap_get (all_known_peers, &peer->hashPubKey);
if (NULL == to_remove)
}
else
{
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Excluded peer `%s' due to BF match in greedy routing for %s\n",
GNUNET_i2s (&pos->id),
GNUNET_h2s (key));
+#endif
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# Peers excluded from routing due to Bloomfilter"), 1,
GNUNET_NO);
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# Peers excluded from routing due to Bloomfilter"), 1,
GNUNET_NO);
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Excluded peer `%s' due to BF match in random routing for %s\n",
GNUNET_i2s (&pos->id),
GNUNET_h2s (key));
+#endif
pos = pos->next;
continue; /* Ignore bloomfiltered peers */
}
GNUNET_CONTAINER_bloomfilter_test (bloom, &nxt->id.hashPubKey));
GNUNET_CONTAINER_bloomfilter_add (bloom, &rtargets[off]->id.hashPubKey);
}
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Selected %u/%u peers at hop %u for %s (target was %u)\n",
off,
(unsigned int) hop_count,
GNUNET_h2s (key),
ret);
+#endif
if (0 == off)
{
GNUNET_free (rtargets);
struct GNUNET_PeerIdentity *pp;
GNUNET_assert (NULL != bf);
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Adding myself (%s) to PUT bloomfilter for %s\n",
GNUNET_i2s (&my_identity),
GNUNET_h2s (key));
+#endif
GNUNET_CONTAINER_bloomfilter_add (bf, &my_identity.hashPubKey);
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# PUT requests routed"), 1,
&targets);
if (0 == target_count)
{
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing PUT for %s terminates after %u hops at %s\n",
GNUNET_h2s (key),
(unsigned int) hop_count,
GNUNET_i2s (&my_identity));
+#endif
return;
}
msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size + sizeof (struct PeerPutMessage);
for (i=0;i<target_count;i++)
{
target = targets[i];
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing PUT for %s after %u hops to %s\n",
GNUNET_h2s (key),
(unsigned int) hop_count,
GNUNET_i2s (&target->id));
+#endif
pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
pending->importance = 0; /* FIXME */
pending->timeout = expiration_time;
target_count = get_target_peers (key, peer_bf, hop_count,
desired_replication_level,
&targets);
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Adding myself (%s) to GET bloomfilter for %s\n",
GNUNET_i2s (&my_identity),
GNUNET_h2s (key));
+#endif
GNUNET_CONTAINER_bloomfilter_add (peer_bf, &my_identity.hashPubKey);
if (0 == target_count)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Routing GET for %s terminates after %u hops at %s\n",
- GNUNET_h2s (key),
- (unsigned int) hop_count,
- GNUNET_i2s (&my_identity));
- return;
- }
+ {
+#if DEBUG_DHT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Routing GET for %s terminates after %u hops at %s\n",
+ GNUNET_h2s (key),
+ (unsigned int) hop_count,
+ GNUNET_i2s (&my_identity));
+#endif
+ return;
+ }
reply_bf_size = GNUNET_CONTAINER_bloomfilter_get_size (reply_bf);
msize = xquery_size + sizeof (struct PeerGetMessage) + reply_bf_size;
if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
for (i=0;i<target_count;i++)
{
target = targets[i];
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing GET for %s after %u hops to %s\n",
GNUNET_h2s (key),
(unsigned int) hop_count,
GNUNET_i2s (&target->id));
+#endif
pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
pending->importance = 0; /* FIXME */
pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT);
/* cannot verify, good luck */
break;
}
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"PUT for %s at %s\n",
GNUNET_h2s (&put->key),
GNUNET_i2s (&my_identity));
+#endif
bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter,
DHT_BLOOM_SIZE,
GNUNET_CONSTANTS_BLOOMFILTER_K);
&get->key,
xquery, xquery_size,
reply_bf, get->bf_mutator);
+#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"GET for %s at %s after %u hops\n",
GNUNET_h2s (&get->key),
GNUNET_i2s (&my_identity),
(unsigned int) ntohl (get->hop_count));
+#endif
/* local lookup (this may update the reply_bf) */
if ( (0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) ||
(am_closest_peer (&get->key,