From: Christian Grothoff Date: Tue, 27 Sep 2011 19:11:47 +0000 (+0000) Subject: adding some stats X-Git-Tag: initial-import-from-subversion-38251~16918 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1b1df3463080c4f269394dac31854a024e8c2ec4;p=oweals%2Fgnunet.git adding some stats --- diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am index 5cad82062..161a498ec 100644 --- a/src/dht/Makefile.am +++ b/src/dht/Makefile.am @@ -205,7 +205,7 @@ test_dht_api_SOURCES = \ test_dht_api_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ $(top_builddir)/src/hello/libgnunethello.la \ - $(top_builddir)/src/dht/libgnunetdht.la + $(top_builddir)/src/dht/libgnunetdhtnew.la test_dht_api_DEPENDENCIES = \ libgnunetdht.la diff --git a/src/dht/gnunet-service-dht-new.c b/src/dht/gnunet-service-dht-new.c index 45c235d40..3e0f3c8d9 100644 --- a/src/dht/gnunet-service-dht-new.c +++ b/src/dht/gnunet-service-dht-new.c @@ -67,7 +67,6 @@ struct GNUNET_MessageHeader *GDS_my_hello; struct GNUNET_TRANSPORT_Handle *GDS_transport_handle; - /** * Handle to get our current HELLO. */ diff --git a/src/dht/gnunet-service-dht.h b/src/dht/gnunet-service-dht.h index 3a716acde..7cacdba7a 100644 --- a/src/dht/gnunet-service-dht.h +++ b/src/dht/gnunet-service-dht.h @@ -27,6 +27,8 @@ #define GNUNET_SERVICE_DHT_H #include "gnunet_util_lib.h" +#include "gnunet_statistics_service.h" +#include "gnunet_transport_service.h" /** * Configuration we use. @@ -39,7 +41,6 @@ extern const struct GNUNET_CONFIGURATION_Handle *GDS_cfg; */ extern struct GNUNET_BLOCK_Context *GDS_block_context; - /** * Handle for the statistics service. */ diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index bb57d83ef..fcfdfc7fd 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c @@ -304,6 +304,9 @@ transmit_request (struct ClientQueryRecord *cqr) int32_t reply_bf_mutator; struct GNUNET_CONTAINER_BloomFilter *reply_bf; + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# GET requests from clients injected into P2P network"), 1, + GNUNET_NO); reply_bf_mutator = (int32_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); reply_bf = GNUNET_BLOCK_construct_bloomfilter (reply_bf_mutator, @@ -385,6 +388,9 @@ handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_break (0); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); } + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# PUT requests received from clients"), 1, + GNUNET_NO); dht_msg = (const struct GNUNET_DHT_ClientPutMessage *) message; /* give to local clients */ GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (dht_msg->expiration), @@ -445,7 +451,9 @@ handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client, xquery_size = size - sizeof (struct GNUNET_DHT_ClientGetMessage); get = (const struct GNUNET_DHT_ClientGetMessage *) message; xquery = (const char*) &get[1]; - + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# GET requests received from clients"), 1, + GNUNET_NO); cqr = GNUNET_malloc (sizeof (struct ClientQueryRecord) + xquery_size); cqr->key = get->key; @@ -531,6 +539,9 @@ handle_dht_local_get_stop (void *cls, struct GNUNET_SERVER_Client *client, (const struct GNUNET_DHT_ClientGetStopMessage *) message; struct RemoveByUniqueIdContext ctx; + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# GET STOP requests received from clients"), 1, + GNUNET_NO); ctx.client = find_active_client (client); ctx.unique_id = dht_stop_msg->unique_id; GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, @@ -748,6 +759,9 @@ forward_reply (void *cls, const GNUNET_HashCode * key, void *value) sizeof (struct PendingMessage) + ntohs (frc->pm->msg->size)); pm->next = pm->prev = NULL; } + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# RESULTS queued for clients"), 1, + GNUNET_NO); reply = (struct GNUNET_DHT_ClientResultMessage*) &pm[1]; reply->unique_id = record->unique_id; add_pending_message (record->client, pm); diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c index 723dd02ca..1ba176e6e 100644 --- a/src/dht/gnunet-service-dht_datacache.c +++ b/src/dht/gnunet-service-dht_datacache.c @@ -99,6 +99,9 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, return; } /* Put size is actual data size plus struct overhead plus path length (if any) */ + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# ITEMS stored in datacache"), 1, + GNUNET_NO); pe = (struct DHTPutEntry *) buf; pe->data_size = htons (data_size); pe->path_length = htons ((uint16_t) put_path_length); @@ -202,6 +205,9 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp, case GNUNET_BLOCK_EVALUATION_OK_LAST: case GNUNET_BLOCK_EVALUATION_OK_MORE: /* forward to local clients */ + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Good RESULTS found in datacache"), 1, + GNUNET_NO); GDS_CLIENTS_handle_reply (exp, key, 0, NULL, @@ -213,8 +219,14 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp, 0, NULL, rdata, rdata_size); break; case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Duplicate RESULTS found in datacache"), 1, + GNUNET_NO); break; case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Invalid RESULTS found in datacache"), 1, + GNUNET_NO); break; case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: GNUNET_break (0); @@ -223,6 +235,9 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp, GNUNET_break_op (0); return GNUNET_SYSERR; case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED: + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Unsupported RESULTS found in datacache"), 1, + GNUNET_NO); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unsupported block type (%u) in local response!\n", type); @@ -255,6 +270,9 @@ GDS_DATACACHE_handle_get (const GNUNET_HashCode *key, if (datacache == NULL) return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# GET requests given to datacache"), 1, + GNUNET_NO); ctx.eval = GNUNET_BLOCK_EVALUATION_REQUEST_VALID; ctx.key = *key; ctx.xquery = xquery; diff --git a/src/dht/gnunet-service-dht_hello.c b/src/dht/gnunet-service-dht_hello.c index 2ee60c91f..db10bb68c 100644 --- a/src/dht/gnunet-service-dht_hello.c +++ b/src/dht/gnunet-service-dht_hello.c @@ -80,6 +80,9 @@ process_hello (void *cls, ex = GNUNET_HELLO_get_last_expiration (hello); if (GNUNET_TIME_absolute_get_remaining (ex).rel_value == 0) return; + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# HELLOs obtained from peerinfo"), 1, + GNUNET_NO); hm = GNUNET_CONTAINER_multihashmap_get (peer_to_hello, &peer->hashPubKey); GNUNET_free_non_null (hm); diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 96a43c23f..91caed95c 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c @@ -515,6 +515,9 @@ update_core_preference (void *cls, &update_core_preference, peer); return; } + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Preference updates given to core"), 1, + GNUNET_NO); peer->info_ctx = GNUNET_CORE_peer_change_preference (coreAPI, &peer->id, GNUNET_TIME_UNIT_FOREVER_REL, @@ -594,6 +597,9 @@ send_find_peer_message (void *cls, GNUNET_CONTAINER_multihashmap_iterate (all_known_peers, &add_known_to_bloom, &bcc); + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# FIND PEER messages initiated"), 1, + GNUNET_NO); // FIXME: pass priority!? GDS_NEIGHBOURS_handle_get (GNUNET_BLOCK_TYPE_DHT_HELLO, GNUNET_DHT_RO_FIND_PEER, @@ -639,6 +645,9 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, GNUNET_break (0); return; } + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Peers connected"), 1, + GNUNET_NO); peer_bucket = find_bucket (&peer->hashPubKey); GNUNET_assert ( (peer_bucket >= 0) && (peer_bucket < MAX_BUCKETS) ); ret = GNUNET_malloc (sizeof (struct PeerInfo)); @@ -692,6 +701,9 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) GNUNET_break (0); return; } + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Peers connected"), -1, + GNUNET_NO); GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (all_known_peers, &peer->hashPubKey, @@ -759,6 +771,9 @@ core_transmit_notify (void *cls, size_t size, void *buf) while ( (NULL != (pending = peer->head)) && (size - off >= (msize = ntohs (pending->msg->size))) ) { + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Bytes transmitted to other peers"), msize, + GNUNET_NO); memcpy (&cbuf[off], pending->msg, msize); off += msize; peer->pending_count--; @@ -1148,6 +1163,9 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type, struct PeerPutMessage *ppm; struct GNUNET_PeerIdentity *pp; + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# PUT requests routed"), 1, + GNUNET_NO); target_count = get_target_peers (key, bf, hop_count, desired_replication_level, &targets); @@ -1164,6 +1182,9 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type, GNUNET_break (0); return; } + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Peers selected as targets for PUT requests"), target_count, + GNUNET_NO); for (i=0;iimportance = 0; /* FIXME */ pending->timeout = expiration_time; @@ -1424,6 +1454,9 @@ handle_dht_p2p_put (void *cls, GNUNET_break_op (0); return GNUNET_YES; } + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# P2P PUT requests received"), 1, + GNUNET_NO); put_path = (const struct GNUNET_PeerIdentity*) &put[1]; payload = &put_path[putlen]; options = ntohl (put->options); @@ -1619,6 +1652,9 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer, GNUNET_break_op (0); return GNUNET_YES; } + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# P2P GET requests received"), 1, + GNUNET_NO); reply_bf_size = msize - (sizeof (struct PeerGetMessage) + xquery_size); type = ntohl (get->type); options = ntohl (get->options); @@ -1663,6 +1699,9 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer, { if ( (0 != (options & GNUNET_DHT_RO_FIND_PEER))) { + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# P2P FIND PEER requests processed"), 1, + GNUNET_NO); handle_find_peer (peer, &get->key, reply_bf, @@ -1740,6 +1779,9 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer, GNUNET_break_op (0); return GNUNET_YES; } + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# P2P RESULTS received"), 1, + GNUNET_NO); put_path = (const struct GNUNET_PeerIdentity*) &prm[1]; get_path = &put_path[put_path_length]; type = ntohl (prm->type); diff --git a/src/dht/gnunet-service-dht_nse.c b/src/dht/gnunet-service-dht_nse.c index b8cda34bd..94fecb413 100644 --- a/src/dht/gnunet-service-dht_nse.c +++ b/src/dht/gnunet-service-dht_nse.c @@ -55,6 +55,9 @@ static void update_network_size_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev) { + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Network size estimates received"), 1, + GNUNET_NO); log_of_network_size_estimate = logestimate; } diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c index 5a87f8b32..607c756c6 100644 --- a/src/dht/gnunet-service-dht_routing.c +++ b/src/dht/gnunet-service-dht_routing.c @@ -216,6 +216,9 @@ process (void *cls, { case GNUNET_BLOCK_EVALUATION_OK_MORE: case GNUNET_BLOCK_EVALUATION_OK_LAST: + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Good REPLIES matched against routing table"), 1, + GNUNET_NO); GDS_NEIGHBOURS_handle_reply (&rr->peer, pc->type, pc->expiration_time, @@ -228,15 +231,23 @@ process (void *cls, pc->data_size); break; case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Duplicate REPLIES matched against routing table"), 1, + GNUNET_NO); return GNUNET_OK; case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: - GNUNET_break_op (0); + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Invalid REPLIES matched against routing table"), 1, + GNUNET_NO); return GNUNET_SYSERR; case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID: GNUNET_break (0); return GNUNET_OK; case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED: + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Unsupported REPLIES matched against routing table"), 1, + GNUNET_NO); return GNUNET_SYSERR; default: GNUNET_break (0); @@ -317,6 +328,9 @@ GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, while (GNUNET_CONTAINER_heap_get_size (recent_heap) >= DHT_MAX_RECENT) { + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Entries removed from routing table"), 1, + GNUNET_NO); recent_req = GNUNET_CONTAINER_heap_peek (recent_heap); GNUNET_assert (recent_req != NULL); GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node); @@ -324,6 +338,9 @@ GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, GNUNET_free (recent_req); } + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Entries added to routing table"), 1, + GNUNET_NO); recent_req = GNUNET_malloc (sizeof (struct RecentRequest) + xquery_size); recent_req->peer = *sender; recent_req->key = *key; @@ -369,6 +386,9 @@ GDS_ROUTING_done () while (GNUNET_CONTAINER_heap_get_size (recent_heap) > 0) { + GNUNET_STATISTICS_update (GDS_stats, + gettext_noop ("# Entries removed from routing table"), 1, + GNUNET_NO); recent_req = GNUNET_CONTAINER_heap_peek (recent_heap); GNUNET_assert (recent_req != NULL); GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node); diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c index 7605d8499..a38da8c73 100644 --- a/src/dht/test_dht_api.c +++ b/src/dht/test_dht_api.c @@ -31,7 +31,7 @@ #include "gnunet_os_lib.h" #include "gnunet_program_lib.h" #include "gnunet_scheduler_lib.h" -#include "gnunet_dht_service.h" +#include "gnunet_dht_service_new.h" #include "gnunet_hello_lib.h" #define VERBOSE GNUNET_NO @@ -82,8 +82,6 @@ struct PeerContext struct GNUNET_DHT_Handle *dht_handle; struct GNUNET_PeerIdentity id; struct GNUNET_DHT_GetHandle *get_handle; - struct GNUNET_DHT_FindPeerHandle *find_peer_handle; - #if START_ARM struct GNUNET_OS_Process *arm_proc; #endif @@ -138,12 +136,6 @@ end_badly () fprintf (stderr, "Ending on an unhappy note.\n"); #endif - if ((retry_context.peer_ctx != NULL) && - (retry_context.peer_ctx->find_peer_handle != NULL)) - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping find peer request!\n"); - GNUNET_DHT_find_peer_stop (retry_context.peer_ctx->find_peer_handle); - } if ((retry_context.peer_ctx != NULL) && (retry_context.peer_ctx->get_handle != NULL)) { @@ -163,197 +155,7 @@ end_badly () * @param cls closure * @param tc context information (why was this task triggered now) */ -void -test_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - struct PeerContext *peer = cls; - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_find_peer_stop!\n"); - if ((tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0) - { - GNUNET_break (0); - GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); - return; - } - - GNUNET_assert (peer->dht_handle != NULL); - - GNUNET_DHT_find_peer_stop (peer->find_peer_handle); - peer->find_peer_handle = NULL; - -#if HAVE_MALICIOUS - GNUNET_DHT_set_malicious_getter (peer->dht_handle, GNUNET_TIME_UNIT_SECONDS, - NULL, NULL); - GNUNET_DHT_set_malicious_putter (peer->dht_handle, GNUNET_TIME_UNIT_SECONDS, - NULL, NULL); - GNUNET_DHT_set_malicious_dropper (peer->dht_handle, NULL, NULL); -#endif - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 1), &end, &p1); -} - - -/** - * Iterator called on each result obtained from a find peer - * operation - * - * @param cls closure (NULL) - * @param peer the peer we learned about - * @param reply response - */ -void -test_find_peer_processor (void *cls, const struct GNUNET_HELLO_Message *hello) -{ - struct RetryContext *retry_ctx = cls; - struct GNUNET_PeerIdentity peer; - - if (GNUNET_OK == GNUNET_HELLO_get_id (hello, &peer)) - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "test_find_peer_processor called (peer `%s'), stopping find peer request!\n", - GNUNET_i2s (&peer)); - - if (retry_ctx->retry_task != GNUNET_SCHEDULER_NO_TASK) - { - GNUNET_SCHEDULER_cancel (retry_ctx->retry_task); - retry_ctx->retry_task = GNUNET_SCHEDULER_NO_TASK; - } - - GNUNET_SCHEDULER_add_continuation (&test_find_peer_stop, &p1, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); - } - else - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "received find peer request, but hello_get_id failed!\n"); - } - -} - -/** - * Retry the find_peer task on timeout. (Forward declaration) - * - * @param cls closure - * @param tc context information (why was this task triggered now?) - */ -void -retry_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); - -/** - * Retry the find_peer task on timeout. - * - * @param cls closure - * @param tc context information (why was this task triggered now) - */ -void -retry_find_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - struct RetryContext *retry_ctx = cls; - GNUNET_HashCode hash; - - memset (&hash, 42, sizeof (GNUNET_HashCode)); - - if (GNUNET_TIME_absolute_get_remaining (retry_ctx->real_timeout).rel_value > - 0) - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "test_find_peer timed out, retrying!\n"); - retry_ctx->next_timeout = - GNUNET_TIME_relative_multiply (retry_ctx->next_timeout, 2); - retry_ctx->peer_ctx->find_peer_handle = - GNUNET_DHT_find_peer_start (retry_ctx->peer_ctx->dht_handle, - retry_ctx->next_timeout, &hash, - GNUNET_DHT_RO_NONE, - &test_find_peer_processor, retry_ctx); - } - else - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "test_find_peer timed out for good, failing!\n"); - - retry_ctx->peer_ctx->find_peer_handle = NULL; - } - - if (retry_ctx->peer_ctx->find_peer_handle == NULL) - { - GNUNET_break (0); - GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_now (&end_badly, &p1); - return; - } - retry_ctx->retry_task = - GNUNET_SCHEDULER_add_delayed (retry_ctx->next_timeout, - &retry_find_peer_stop, retry_ctx); -} - -/** - * Retry the find_peer task on timeout. - * - * @param cls closure - * @param tc context information (why was this task triggered now?) - */ -void -retry_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - struct RetryContext *retry_ctx = cls; - GNUNET_HashCode hash; - - memset (&hash, 42, sizeof (GNUNET_HashCode)); - - if (retry_ctx->peer_ctx->find_peer_handle != NULL) - { - GNUNET_DHT_find_peer_stop (retry_ctx->peer_ctx->find_peer_handle); - retry_ctx->peer_ctx->find_peer_handle = NULL; - } - GNUNET_SCHEDULER_add_now (&retry_find_peer, retry_ctx); -} - -/** - * Entry point for test of find_peer functionality. - * - * @param cls closure - * @param tc context information (why was this task triggered now) - */ -void -test_find_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - struct PeerContext *peer = cls; - GNUNET_HashCode hash; - - memset (&hash, 42, sizeof (GNUNET_HashCode)); - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_find_peer!\n"); - GNUNET_assert (peer->dht_handle != NULL); - - retry_context.real_timeout = GNUNET_TIME_relative_to_absolute (TOTAL_TIMEOUT); - retry_context.next_timeout = BASE_TIMEOUT; - retry_context.peer_ctx = peer; - - peer->find_peer_handle = - GNUNET_DHT_find_peer_start (peer->dht_handle, retry_context.next_timeout, - &hash, GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, - &test_find_peer_processor, &retry_context); - - if (peer->find_peer_handle == NULL) - { - GNUNET_break (0); - GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_now (&end_badly, &p1); - return; - } - retry_context.retry_task = - GNUNET_SCHEDULER_add_delayed (retry_context.next_timeout, - &retry_find_peer_stop, &retry_context); -} - -/** - * Signature of the main function of a task. - * - * @param cls closure - * @param tc context information (why was this task triggered now) - */ -void +static void test_get_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct PeerContext *peer = cls; @@ -369,14 +171,17 @@ test_get_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (peer->dht_handle != NULL); GNUNET_DHT_get_stop (peer->get_handle); peer->get_handle = NULL; - GNUNET_SCHEDULER_add_now (&test_find_peer, &p1); + GNUNET_SCHEDULER_add_now (&end, &p1); } -void + +static void test_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp, const GNUNET_HashCode * key, - const struct GNUNET_PeerIdentity *const *get_path, - const struct GNUNET_PeerIdentity *const *put_path, + const struct GNUNET_PeerIdentity *get_path, + unsigned int get_path_length, + const struct GNUNET_PeerIdentity *put_path, + unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, const void *data) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -409,8 +214,8 @@ test_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) peer->get_handle = GNUNET_DHT_get_start (peer->dht_handle, TOTAL_TIMEOUT, GNUNET_BLOCK_TYPE_TEST, &hash, - DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL, - 0, NULL, 0, &test_get_iterator, NULL); + 1, GNUNET_DHT_RO_NONE, NULL, + 0, &test_get_iterator, NULL); if (peer->get_handle == NULL) { @@ -445,7 +250,7 @@ test_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (peer->dht_handle != NULL); - GNUNET_DHT_put (peer->dht_handle, &hash, DEFAULT_PUT_REPLICATION, + GNUNET_DHT_put (peer->dht_handle, &hash, 1, GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_TEST, data_size, data, GNUNET_TIME_relative_to_absolute (TOTAL_TIMEOUT), TOTAL_TIMEOUT, &test_get, &p1); diff --git a/src/dht/test_dht_api_peer1.conf b/src/dht/test_dht_api_peer1.conf index ae0d2ff49..5c3c14ba3 100644 --- a/src/dht/test_dht_api_peer1.conf +++ b/src/dht/test_dht_api_peer1.conf @@ -11,6 +11,7 @@ ACCEPT_FROM6 = ::1; ACCEPT_FROM = 127.0.0.1; HOSTNAME = localhost PORT = 2100 +BINARY = gnunet-service-dht-new [block] plugins = dht test