#include "gnunet_dht_service.h"
#include "dht.h"
-#define DEBUG_DHT_API GNUNET_EXTRA_LOGGING
-
#define LOG(kind,...) GNUNET_log_from (kind, "dht-api",__VA_ARGS__)
/**
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 (GNUNET_YES == head->free_on_send)
GNUNET_free (head);
process_pending_messages (handle);
-#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Forwarded request of %u bytes to DHT service\n", (unsigned int) tsize);
-#endif
if (GNUNET_NO == handle->in_receive)
{
-#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting to process replies from DHT\n");
-#endif
handle->in_receive = GNUNET_YES;
GNUNET_CLIENT_receive (handle->client, &service_message_handler, handle,
GNUNET_TIME_UNIT_FOREVER_REL);
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) +