gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r17068 - gnunet/src/dht


From: gnunet
Subject: [GNUnet-SVN] r17068 - gnunet/src/dht
Date: Tue, 27 Sep 2011 21:11:47 +0200

Author: grothoff
Date: 2011-09-27 21:11:47 +0200 (Tue, 27 Sep 2011)
New Revision: 17068

Modified:
   gnunet/src/dht/Makefile.am
   gnunet/src/dht/gnunet-service-dht-new.c
   gnunet/src/dht/gnunet-service-dht.h
   gnunet/src/dht/gnunet-service-dht_clients.c
   gnunet/src/dht/gnunet-service-dht_datacache.c
   gnunet/src/dht/gnunet-service-dht_hello.c
   gnunet/src/dht/gnunet-service-dht_neighbours.c
   gnunet/src/dht/gnunet-service-dht_nse.c
   gnunet/src/dht/gnunet-service-dht_routing.c
   gnunet/src/dht/test_dht_api.c
   gnunet/src/dht/test_dht_api_peer1.conf
Log:
adding some stats

Modified: gnunet/src/dht/Makefile.am
===================================================================
--- gnunet/src/dht/Makefile.am  2011-09-27 17:34:12 UTC (rev 17067)
+++ gnunet/src/dht/Makefile.am  2011-09-27 19:11:47 UTC (rev 17068)
@@ -205,7 +205,7 @@
 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                          
 

Modified: gnunet/src/dht/gnunet-service-dht-new.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht-new.c     2011-09-27 17:34:12 UTC (rev 
17067)
+++ gnunet/src/dht/gnunet-service-dht-new.c     2011-09-27 19:11:47 UTC (rev 
17068)
@@ -67,7 +67,6 @@
 struct GNUNET_TRANSPORT_Handle *GDS_transport_handle;
 
 
-
 /**
  * Handle to get our current HELLO.
  */

Modified: gnunet/src/dht/gnunet-service-dht.h
===================================================================
--- gnunet/src/dht/gnunet-service-dht.h 2011-09-27 17:34:12 UTC (rev 17067)
+++ gnunet/src/dht/gnunet-service-dht.h 2011-09-27 19:11:47 UTC (rev 17068)
@@ -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 struct GNUNET_BLOCK_Context *GDS_block_context;
 
-
 /**
  * Handle for the statistics service.
  */

Modified: gnunet/src/dht/gnunet-service-dht_clients.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_clients.c 2011-09-27 17:34:12 UTC (rev 
17067)
+++ gnunet/src/dht/gnunet-service-dht_clients.c 2011-09-27 19:11:47 UTC (rev 
17068)
@@ -304,6 +304,9 @@
   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 @@
       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 @@
   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 @@
     (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 @@
              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);

Modified: gnunet/src/dht/gnunet-service-dht_datacache.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_datacache.c       2011-09-27 17:34:12 UTC 
(rev 17067)
+++ gnunet/src/dht/gnunet-service-dht_datacache.c       2011-09-27 19:11:47 UTC 
(rev 17068)
@@ -99,6 +99,9 @@
       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 @@
   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 @@
                         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 @@
     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 @@
 
   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;

Modified: gnunet/src/dht/gnunet-service-dht_hello.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_hello.c   2011-09-27 17:34:12 UTC (rev 
17067)
+++ gnunet/src/dht/gnunet-service-dht_hello.c   2011-09-27 19:11:47 UTC (rev 
17068)
@@ -80,6 +80,9 @@
   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);

Modified: gnunet/src/dht/gnunet-service-dht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_neighbours.c      2011-09-27 17:34:12 UTC 
(rev 17067)
+++ gnunet/src/dht/gnunet-service-dht_neighbours.c      2011-09-27 19:11:47 UTC 
(rev 17068)
@@ -515,6 +515,9 @@
                                        &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 @@
   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 @@
     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 @@
       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 @@
   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 @@
   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 @@
     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;i<target_count;i++)
   {
     target = targets[i];
@@ -1237,6 +1258,9 @@
   char *xq;
   size_t reply_bf_size;
   
+  GNUNET_STATISTICS_update (GDS_stats,
+                           gettext_noop ("# GET requests routed"), 1,
+                           GNUNET_NO);
   target_count = get_target_peers (key, peer_bf, hop_count,
                                   desired_replication_level,
                                   &targets);
@@ -1249,6 +1273,9 @@
     GNUNET_break (0);
     return;
   }
+  GNUNET_STATISTICS_update (GDS_stats,
+                           gettext_noop ("# Peers selected as targets for GET 
requests"), target_count,
+                           GNUNET_NO);
   /* forward request */
   for (i=0;i<target_count;i++)
   {
@@ -1338,6 +1365,9 @@
     /* peer disconnected in the meantime, drop reply */
     return;
   }
+  GNUNET_STATISTICS_update (GDS_stats,
+                           gettext_noop ("# REPLIES routed"), 1,
+                           GNUNET_NO);
   pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 
   pending->importance = 0; /* FIXME */
   pending->timeout = expiration_time;
@@ -1424,6 +1454,9 @@
       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 @@
     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 @@
   {
     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 @@
     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);

Modified: gnunet/src/dht/gnunet-service-dht_nse.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_nse.c     2011-09-27 17:34:12 UTC (rev 
17067)
+++ gnunet/src/dht/gnunet-service-dht_nse.c     2011-09-27 19:11:47 UTC (rev 
17068)
@@ -55,6 +55,9 @@
 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;
 }
 

Modified: gnunet/src/dht/gnunet-service-dht_routing.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_routing.c 2011-09-27 17:34:12 UTC (rev 
17067)
+++ gnunet/src/dht/gnunet-service-dht_routing.c 2011-09-27 19:11:47 UTC (rev 
17068)
@@ -216,6 +216,9 @@
   {
   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 @@
                                 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 @@
 
   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 @@
     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 @@
 
   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);

Modified: gnunet/src/dht/test_dht_api.c
===================================================================
--- gnunet/src/dht/test_dht_api.c       2011-09-27 17:34:12 UTC (rev 17067)
+++ gnunet/src/dht/test_dht_api.c       2011-09-27 19:11:47 UTC (rev 17068)
@@ -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 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
@@ -139,12 +137,6 @@
 #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))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping get request!\n");
@@ -163,197 +155,7 @@
  * @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 @@
   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 @@
   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 @@
 
   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);

Modified: gnunet/src/dht/test_dht_api_peer1.conf
===================================================================
--- gnunet/src/dht/test_dht_api_peer1.conf      2011-09-27 17:34:12 UTC (rev 
17067)
+++ gnunet/src/dht/test_dht_api_peer1.conf      2011-09-27 19:11:47 UTC (rev 
17068)
@@ -11,6 +11,7 @@
 ACCEPT_FROM = 127.0.0.1;
 HOSTNAME = localhost
 PORT = 2100
+BINARY = gnunet-service-dht-new
 
 [block]
 plugins = dht test




reply via email to

[Prev in Thread] Current Thread [Next in Thread]