/*
This file is part of GNUnet.
- (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2009, 2010, 2011 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
#include "dht.h"
+/**
+ * Should routing details be logged to stderr (for debugging)?
+ */
+#define LOG_TRAFFIC(kind,...) GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__)
+
+#define LOG(kind,...) GNUNET_log_from (kind, "dht-clients",__VA_ARGS__)
+
/**
* Linked list of messages to send to clients.
*/
/**
- * Entry in the DHT routing table for a client's GET request.
+ * Entry in the local forwarding map for a client's GET request.
*/
struct ClientQueryRecord
{
* Previous element in DLL.
*/
struct ClientMonitorRecord *prev;
-
+
/**
* Type of blocks that are of interest
*/
static struct ClientMonitorRecord *monitor_tail;
/**
- * Hashmap for fast key based lookup, maps keys to 'struct ClientQueryRecord' entries.
+ * Hashmap for fast key based lookup, maps keys to `struct ClientQueryRecord` entries.
*/
static struct GNUNET_CONTAINER_MultiHashMap *forward_map;
/**
* Task that re-transmits requests (using retry_heap).
*/
-static GNUNET_SCHEDULER_TaskIdentifier retry_task;
+static struct GNUNET_SCHEDULER_Task * retry_task;
/**
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;
* @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)
* 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)
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);
peer_bf =
GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE,
GNUNET_CONSTANTS_BLOOMFILTER_K);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Initiating GET for %s, replication %u, already have %u replies\n",
+ GNUNET_h2s (&cqr->key),
+ cqr->replication,
+ cqr->seen_replies_count);
GDS_NEIGHBOURS_handle_get (cqr->type, cqr->msg_options, cqr->replication,
0 /* hop count */ ,
&cqr->key, cqr->xquery, cqr->xquery_size, reply_bf,
GNUNET_CONTAINER_bloomfilter_free (reply_bf);
GNUNET_CONTAINER_bloomfilter_free (peer_bf);
- /* exponential back-off for retries, max 1h */
- cqr->retry_frequency =
- GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_HOURS,
- GNUNET_TIME_relative_multiply
- (cqr->retry_frequency, 2));
+ /* exponential back-off for retries.
+ * max GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD (15 min) */
+ cqr->retry_frequency = GNUNET_TIME_STD_BACKOFF (cqr->retry_frequency);
cqr->retry_time = GNUNET_TIME_relative_to_absolute (cqr->retry_frequency);
}
* itself (unless the heap is empty).
*
* @param cls unused
- * @param tc scheduler context
*/
static void
-transmit_next_request_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+transmit_next_request_task (void *cls)
{
struct ClientQueryRecord *cqr;
struct GNUNET_TIME_Relative delay;
- retry_task = GNUNET_SCHEDULER_NO_TASK;
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- return;
+ retry_task = NULL;
while (NULL != (cqr = GNUNET_CONTAINER_heap_remove_root (retry_heap)))
{
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);
transmit_request (cqr);
cqr->hnode =
GNUNET_CONTAINER_heap_insert (retry_heap, cqr,
- cqr->retry_time.abs_value);
+ cqr->retry_time.abs_value_us);
}
}
("# PUT requests received from clients"), 1,
GNUNET_NO);
dht_msg = (const struct GNUNET_DHT_ClientPutMessage *) message;
+ LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "R5N CLIENT-PUT %s\n",
+ GNUNET_h2s_full (&dht_msg->key));
/* give to local clients */
- 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));
+ 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));
GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
&dht_msg->key, 0, NULL, 0, NULL,
ntohl (dht_msg->type),
&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));
/**
- * Handler for any generic DHT messages, calls the appropriate handler
- * depending on message type, sends confirmation if responses aren't otherwise
- * expected.
+ * Handler for DHT GET messages from the client.
*
* @param cls closure for the service
* @param client the client we received this message from
gettext_noop
("# GET requests received from clients"), 1,
GNUNET_NO);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received request for %s from local client %p\n",
- GNUNET_h2s (&get->key), client);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received GET request for %s from local client %p, xq: %.*s\n",
+ GNUNET_h2s (&get->key), client, xquery_size, xquery);
+
+ LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "R5N CLIENT-GET %s\n",
+ GNUNET_h2s_full (&get->key));
+
+
cqr = GNUNET_malloc (sizeof (struct ClientQueryRecord) + xquery_size);
cqr->key = get->key;
cqr->client = find_active_client (client);
cqr->xquery = (void *) &cqr[1];
memcpy (&cqr[1], xquery, xquery_size);
cqr->hnode = GNUNET_CONTAINER_heap_insert (retry_heap, cqr, 0);
- cqr->retry_frequency = GNUNET_TIME_UNIT_MILLISECONDS;
+ cqr->retry_frequency = GNUNET_TIME_UNIT_SECONDS;
cqr->retry_time = GNUNET_TIME_absolute_get ();
cqr->unique_id = get->unique_id;
cqr->xquery_size = xquery_size;
cqr->replication = ntohl (get->desired_replication_level);
cqr->msg_options = ntohl (get->options);
cqr->type = ntohl (get->type);
+ // FIXME use cqr->key, set multihashmap create to GNUNET_YES
GNUNET_CONTAINER_multihashmap_put (forward_map, &get->key, cqr,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
GDS_CLIENTS_process_get (ntohl (get->options),
GDS_NEIGHBOURS_get_id(),
&get->key);
/* start remote requests */
- if (GNUNET_SCHEDULER_NO_TASK != retry_task)
+ if (NULL != retry_task)
GNUNET_SCHEDULER_cancel (retry_task);
retry_task = GNUNET_SCHEDULER_add_now (&transmit_next_request_task, NULL);
/* perform local lookup */
}
+/**
+ * Closure for 'find_by_unique_id'.
+ */
+struct FindByUniqueIdContext
+{
+ /**
+ * Where to store the result, if found.
+ */
+ struct ClientQueryRecord *cqr;
+
+ uint64_t unique_id;
+};
+
+
+/**
+ * Function called for each existing DHT record for the given
+ * query. Checks if it matches the UID given in the closure
+ * and if so returns the entry as a result.
+ *
+ * @param cls the search context
+ * @param key query for the lookup (not used)
+ * @param value the 'struct ClientQueryRecord'
+ * @return GNUNET_YES to continue iteration (result not yet found)
+ */
+static int
+find_by_unique_id (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
+{
+ struct FindByUniqueIdContext *fui_ctx = cls;
+ struct ClientQueryRecord *cqr = value;
+
+ if (cqr->unique_id != fui_ctx->unique_id)
+ return GNUNET_YES;
+ fui_ctx->cqr = cqr;
+ return GNUNET_NO;
+}
+
+
+/**
+ * Handler for "GET result seen" messages from the client.
+ *
+ * @param cls closure for the service
+ * @param client the client we received this message from
+ * @param message the actual message received
+ */
+static void
+handle_dht_local_get_result_seen (void *cls, struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
+{
+ const struct GNUNET_DHT_ClientGetResultSeenMessage *seen;
+ uint16_t size;
+ unsigned int hash_count;
+ unsigned int old_count;
+ const struct GNUNET_HashCode *hc;
+ struct FindByUniqueIdContext fui_ctx;
+ struct ClientQueryRecord *cqr;
+
+ size = ntohs (message->size);
+ if (size < sizeof (struct GNUNET_DHT_ClientGetResultSeenMessage))
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ seen = (const struct GNUNET_DHT_ClientGetResultSeenMessage *) message;
+ hash_count = (size - sizeof (struct GNUNET_DHT_ClientGetResultSeenMessage)) / sizeof (struct GNUNET_HashCode);
+ if (size != sizeof (struct GNUNET_DHT_ClientGetResultSeenMessage) + hash_count * sizeof (struct GNUNET_HashCode))
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ hc = (const struct GNUNET_HashCode*) &seen[1];
+ fui_ctx.unique_id = seen->unique_id;
+ fui_ctx.cqr = NULL;
+ GNUNET_CONTAINER_multihashmap_get_multiple (forward_map,
+ &seen->key,
+ &find_by_unique_id,
+ &fui_ctx);
+ if (NULL == (cqr = fui_ctx.cqr))
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ /* finally, update 'seen' list */
+ old_count = cqr->seen_replies_count;
+ GNUNET_array_grow (cqr->seen_replies,
+ cqr->seen_replies_count,
+ cqr->seen_replies_count + hash_count);
+ memcpy (&cqr->seen_replies[old_count],
+ hc,
+ sizeof (struct GNUNET_HashCode) * hash_count);
+}
+
+
/**
* Closure for 'remove_by_unique_id'.
*/
*
*/
static void
-handle_dht_local_get_stop (void *cls, struct GNUNET_SERVER_Client *client,
+handle_dht_local_get_stop (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_DHT_ClientGetStopMessage *dht_stop_msg =
gettext_noop
("# GET STOP requests received from clients"), 1,
GNUNET_NO);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p stopped request for key %s\n",
- client, GNUNET_h2s (&dht_stop_msg->key));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received GET STOP request for %s from local client %p\n",
+ GNUNET_h2s (&dht_stop_msg->key),
+ client);
ctx.client = find_active_client (client);
ctx.unique_id = dht_stop_msg->unique_id;
GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, &dht_stop_msg->key,
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);
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);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
+
/**
* Handler for monitor stop messages
*
}
r = r->next;
}
-
+
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
reply);
memcpy (&cbuf[off], reply->msg, msize);
GNUNET_free (reply);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting %u bytes to client %p\n",
- msize, client->client_handle);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting %u bytes to client %p\n",
+ (unsigned int) msize,
+ client->client_handle);
off += msize;
}
process_pending_messages (client);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitted %u/%u bytes to client %p\n",
- (unsigned int) off, (unsigned int) size, client->client_handle);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitted %u/%u bytes to client %p\n",
+ (unsigned int) off,
+ (unsigned int) size,
+ client->client_handle);
return off;
}
/**
- * Closure for 'forward_reply'
+ * Closure for #forward_reply()
*/
struct ForwardReplyContext
{
size_t data_size;
/**
- * Do we need to copy 'pm' because it was already used?
+ * Do we need to copy @a pm because it was already used?
*/
int do_copy;
* @param cls the 'struct ForwardReplyContext'
* @param key current key
* @param value value in the hash map, a ClientQueryRecord
- * @return GNUNET_YES (we should continue to iterate),
- * if the result is mal-formed, GNUNET_NO
+ * @return #GNUNET_YES (we should continue to iterate),
+ * if the result is mal-formed, #GNUNET_NO
*/
static int
-forward_reply (void *cls, const struct GNUNET_HashCode * key, void *value)
+forward_reply (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct ForwardReplyContext *frc = cls;
struct ClientQueryRecord *record = value;
struct GNUNET_HashCode ch;
unsigned int i;
+ LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
+ "R5N CLIENT-RESULT %s\n",
+ GNUNET_h2s_full (key));
if ((record->type != GNUNET_BLOCK_TYPE_ANY) && (record->type != frc->type))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Record type missmatch, not passing request for key %s to local client\n",
- GNUNET_h2s (key));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Record type missmatch, not passing request for key %s to local client\n",
+ GNUNET_h2s (key));
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop
("# Key match, type mismatches in REPLY to CLIENT"),
for (i = 0; i < record->seen_replies_count; i++)
if (0 == memcmp (&record->seen_replies[i], &ch, sizeof (struct GNUNET_HashCode)))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Duplicate reply, not passing request for key %s to local client\n",
- GNUNET_h2s (key));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Duplicate reply, not passing request for key %s to local client\n",
+ GNUNET_h2s (key));
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop
("# Duplicate REPLIES to CLIENT request dropped"),
return GNUNET_YES; /* duplicate */
}
eval =
- GNUNET_BLOCK_evaluate (GDS_block_context, record->type, key, NULL, 0,
- record->xquery, record->xquery_size, frc->data,
+ GNUNET_BLOCK_evaluate (GDS_block_context,
+ record->type,
+ GNUNET_BLOCK_EO_NONE,
+ key,
+ NULL,
+ 0,
+ record->xquery,
+ record->xquery_size,
+ frc->data,
frc->data_size);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Evaluation result is %d for key %s for local client's query\n",
- (int) eval, GNUNET_h2s (key));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Evaluation result is %d for key %s for local client's query\n",
+ (int) eval,
+ GNUNET_h2s (key));
switch (eval)
{
case GNUNET_BLOCK_EVALUATION_OK_LAST:
case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
GNUNET_break (0);
return GNUNET_NO;
+ case GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT:
+ return GNUNET_YES;
case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Unsupported block type (%u) in request!\n"), record->type);
GNUNET_NO);
reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1];
reply->unique_id = record->unique_id;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Queueing reply to query %s for client %p\n", GNUNET_h2s (key),
- record->client->client_handle);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "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)
remove_client_records (record->client, key, record);
*
* @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
GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
- const struct GNUNET_HashCode * key,
+ const struct GNUNET_HashCode *key,
unsigned int get_path_length,
const struct GNUNET_PeerIdentity *get_path,
unsigned int put_path_length,
if (NULL == GNUNET_CONTAINER_multihashmap_get (forward_map, key))
{
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "No matching client for reply for key %s\n",
+ GNUNET_h2s (key));
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop
("# REPLIES ignored for CLIENTS (no match)"), 1,
(get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity);
if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Could not pass reply to client, message too big!\n"));
+ GNUNET_break (0);
return;
}
- pm = (struct PendingMessage *) GNUNET_malloc (msize +
- sizeof (struct PendingMessage));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Forwarding reply for key %s to client\n",
+ GNUNET_h2s (key));
+
+ pm = GNUNET_malloc (msize + sizeof (struct PendingMessage));
reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1];
pm->msg = &reply->header;
reply->header.size = htons ((uint16_t) msize);
frc.data = data;
frc.data_size = data_size;
frc.type = type;
- GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, key, &forward_reply,
+ 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! */
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)
msize = path_length * sizeof (struct GNUNET_PeerIdentity);
msize += sizeof (struct GNUNET_DHT_MonitorGetMessage);
msize += sizeof (struct PendingMessage);
- pm = (struct PendingMessage *) GNUNET_malloc (msize);
+ pm = GNUNET_malloc (msize);
mmsg = (struct GNUNET_DHT_MonitorGetMessage *) &pm[1];
pm->msg = &mmsg->header;
mmsg->header.size = htons (msize - sizeof (struct PendingMessage));
* @param exp Expiration time of the data.
* @param key Key of the data.
* @param data Pointer to the result data.
- * @param size Number of bytes in data.
+ * @param size Number of bytes in @a data.
*/
void
GDS_CLIENTS_process_get_resp (enum GNUNET_BLOCK_Type type,
* sizeof (struct GNUNET_PeerIdentity);
msize += sizeof (struct GNUNET_DHT_MonitorGetRespMessage);
msize += sizeof (struct PendingMessage);
- pm = (struct PendingMessage *) GNUNET_malloc (msize);
+ pm = GNUNET_malloc (msize);
mmsg = (struct GNUNET_DHT_MonitorGetRespMessage *) &pm[1];
pm->msg = (struct GNUNET_MessageHeader *) mmsg;
mmsg->header.size = htons (msize - sizeof (struct PendingMessage));
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,
msize += path_length * sizeof (struct GNUNET_PeerIdentity);
msize += sizeof (struct GNUNET_DHT_MonitorPutMessage);
msize += sizeof (struct PendingMessage);
- pm = (struct PendingMessage *) GNUNET_malloc (msize);
+ pm = GNUNET_malloc (msize);
mmsg = (struct GNUNET_DHT_MonitorPutMessage *) &pm[1];
pm->msg = (struct GNUNET_MessageHeader *) mmsg;
mmsg->header.size = htons (msize - sizeof (struct PendingMessage));
msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1];
if (path_length > 0)
{
- memcpy (msg_path, path,
+ memcpy (msg_path,
+ path,
path_length * sizeof (struct GNUNET_PeerIdentity));
}
mmsg->expiration_time = GNUNET_TIME_absolute_hton(exp);
* @param server the initialized server
*/
void
-GDS_CLIENTS_init (struct GNUNET_SERVER_Handle *server)
+GDS_CLIENTS_init ()
{
static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = {
{&handle_dht_local_put, NULL,
{&handle_dht_local_monitor_stop, NULL,
GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP,
sizeof (struct GNUNET_DHT_MonitorStartStopMessage)},
+ {&handle_dht_local_get_result_seen, NULL,
+ GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN, 0},
{NULL, NULL, 0, 0}
};
- forward_map = GNUNET_CONTAINER_multihashmap_create (1024);
+
+ forward_map = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO);
retry_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
- GNUNET_SERVER_add_handlers (server, plugin_handlers);
- GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
+ GNUNET_SERVER_resume (GDS_server);
+ GNUNET_SERVER_add_handlers (GDS_server,
+ plugin_handlers);
+ GNUNET_SERVER_disconnect_notify (GDS_server,
+ &handle_client_disconnect,
+ NULL);
}
{
GNUNET_assert (client_head == NULL);
GNUNET_assert (client_tail == NULL);
- if (GNUNET_SCHEDULER_NO_TASK != retry_task)
+ if (NULL != retry_task)
{
GNUNET_SCHEDULER_cancel (retry_task);
- retry_task = GNUNET_SCHEDULER_NO_TASK;
+ retry_task = NULL;
}
if (NULL != retry_heap)
{