gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r13151 - gnunet/src/dht
Date: Mon, 4 Oct 2010 22:29:29 +0200

Author: grothoff
Date: 2010-10-04 22:29:29 +0200 (Mon, 04 Oct 2010)
New Revision: 13151

Modified:
   gnunet/src/dht/Makefile.am
   gnunet/src/dht/gnunet-service-dht.c
Log:
block library initialization

Modified: gnunet/src/dht/Makefile.am
===================================================================
--- gnunet/src/dht/Makefile.am  2010-10-04 20:22:32 UTC (rev 13150)
+++ gnunet/src/dht/Makefile.am  2010-10-04 20:29:29 UTC (rev 13151)
@@ -106,6 +106,7 @@
   $(top_builddir)/src/core/libgnunetcore.la \
   $(top_builddir)/src/transport/libgnunettransport.la \
   $(top_builddir)/src/hello/libgnunethello.la \
+  $(top_builddir)/src/block/libgnunetblock.la \
   $(top_builddir)/src/datacache/libgnunetdatacache.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/dht/libgnunetdhtlog.la -lm

Modified: gnunet/src/dht/gnunet-service-dht.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht.c 2010-10-04 20:22:32 UTC (rev 13150)
+++ gnunet/src/dht/gnunet-service-dht.c 2010-10-04 20:29:29 UTC (rev 13151)
@@ -26,6 +26,7 @@
  */
 
 #include "platform.h"
+#include "gnunet_block_lib.h"
 #include "gnunet_client_lib.h"
 #include "gnunet_getopt_lib.h"
 #include "gnunet_os_lib.h"
@@ -654,12 +655,12 @@
 /**
  * Which kind of convergence will we be using?
  */
-enum ConvergenceOptions converge_option;
+static enum ConvergenceOptions converge_option;
 
 /**
  * Modifier for the convergence function
  */
-float converge_modifier;
+static float converge_modifier;
 
 /**
  * Recent requests by hash/uid and by time inserted.
@@ -870,13 +871,22 @@
 static unsigned int reply_counter;
 
 /**
+ * Our handle to the BLOCK library.
+ */
+static struct GNUNET_BLOCK_Context *block_context;
+
+
+/**
  * Forward declaration.
  */
-static size_t send_generic_reply (void *cls, size_t size, void *buf);
+static size_t 
+send_generic_reply (void *cls, size_t size, void *buf);
 
+
 /** Declare here so retry_core_send is aware of it */
-size_t core_transmit_notify (void *cls,
-                             size_t size, void *buf);
+static size_t 
+core_transmit_notify (void *cls,
+                     size_t size, void *buf);
 
 /**
  * Convert unique ID to hash code.
@@ -1061,6 +1071,8 @@
   if (peer->send_task == GNUNET_SCHEDULER_NO_TASK)
     peer->send_task = GNUNET_SCHEDULER_add_now(sched, &try_core_send, peer);
 }
+
+
 /**
  * Called when core is ready to send a message we asked for
  * out to the destination.
@@ -1070,8 +1082,9 @@
  * @param buf where the callee should write the message
  * @return number of bytes written to buf
  */
-size_t core_transmit_notify (void *cls,
-                             size_t size, void *buf)
+static size_t 
+core_transmit_notify (void *cls,
+                     size_t size, void *buf)
 {
   struct PeerInfo *peer = cls;
   char *cbuf = buf;
@@ -4197,13 +4210,13 @@
 {
   int bucket_count;
   struct PeerInfo *pos;
+
   if (transport_handle != NULL)
-  {
-    GNUNET_free_non_null(my_hello);
-    GNUNET_TRANSPORT_get_hello_cancel(transport_handle, &process_hello, NULL);
-    GNUNET_TRANSPORT_disconnect(transport_handle);
-  }
-
+    {
+      GNUNET_free_non_null(my_hello);
+      GNUNET_TRANSPORT_get_hello_cancel(transport_handle, &process_hello, 
NULL);
+      GNUNET_TRANSPORT_disconnect(transport_handle);
+    }
   for (bucket_count = lowest_bucket; bucket_count < MAX_BUCKETS; 
bucket_count++)
     {
       while (k_buckets[bucket_count].head != NULL)
@@ -4223,6 +4236,7 @@
                   "%s:%s Disconnecting core!\n", my_short_id, "DHT");
 #endif
       GNUNET_CORE_disconnect (coreAPI);
+      coreAPI = NULL;
     }
   if (datacache != NULL)
     {
@@ -4231,17 +4245,25 @@
                   "%s:%s Destroying datacache!\n", my_short_id, "DHT");
 #endif
       GNUNET_DATACACHE_destroy (datacache);
+      datacache = NULL;
     }
-
   if (stats != NULL)
     {
       GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
+      stats = NULL;
     }
-
   if (dhtlog_handle != NULL)
-    GNUNET_DHTLOG_disconnect(dhtlog_handle);
-
+    {
+      GNUNET_DHTLOG_disconnect(dhtlog_handle);
+      dhtlog_handle = NULL;
+    }
+  if (block_context != NULL)
+    {
+      GNUNET_BLOCK_context_destroy (block_context);
+      block_context = NULL;
+    }
   GNUNET_free_non_null(my_short_id);
+  my_short_id = NULL;
 }
 
 
@@ -4304,6 +4326,7 @@
   {NULL, 0, 0}
 };
 
+
 /**
  * Method called whenever a peer connects.
  *
@@ -4347,6 +4370,7 @@
 #endif
 }
 
+
 /**
  * Method called whenever a peer disconnects.
  *
@@ -4375,6 +4399,7 @@
   delete_peer(to_remove, current_bucket);
 }
 
+
 /**
  * Process dht requests.
  *
@@ -4392,6 +4417,7 @@
   struct GNUNET_TIME_Relative next_send_time;
   unsigned long long temp_config_num;
   char *converge_modifier_buf;
+
   sched = scheduler;
   cfg = c;
   datacache = GNUNET_DATACACHE_create (sched, cfg, "dhtcache");
@@ -4418,8 +4444,9 @@
   if (transport_handle != NULL)
     GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL);
   else
-    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to connect to transport 
service!\n");
-
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 
+              "Failed to connect to transport service!\n");
+  block_context = GNUNET_BLOCK_context_create (cfg);
   lowest_bucket = MAX_BUCKETS - 1;
   forward_list.hashmap = 
GNUNET_CONTAINER_multihashmap_create(MAX_OUTSTANDING_FORWARDS / 10);
   forward_list.minHeap = 
GNUNET_CONTAINER_heap_create(GNUNET_CONTAINER_HEAP_ORDER_MIN);




reply via email to

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