-ensure stats queues do not grow too big
[oweals/gnunet.git] / src / gns / gnunet-service-gns.c
index 4495bb6b787b101d4786a2bc3c213655006b2cdf..e2bb0ad8c4f658fae2e78aa1bd54b8aa49986fac 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2011-2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2011-2013 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
@@ -14,8 +14,8 @@
 
      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.
 */
 /**
  * @file gns/gnunet-service-gns.c
@@ -260,15 +260,18 @@ static struct GNUNET_STATISTICS_Handle *statistics;
  * @param tc unused
  */
 static void
-shutdown_task (void *cls,
-               const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
 {
   struct ClientLookupHandle *clh;
   struct MonitorActivity *ma;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Shutting down!\n");
-  GNUNET_SERVER_notification_context_destroy (nc);
+  if (NULL != nc)
+  {
+    GNUNET_SERVER_notification_context_destroy (nc);
+    nc = NULL;
+  }
   while (NULL != (clh = clh_head))
   {
     GNUNET_SERVER_client_set_user_context (clh->client, NULL);
@@ -345,11 +348,9 @@ shutdown_task (void *cls,
  * Method called periodically that triggers iteration over authoritative records
  *
  * @param cls closure
- * @param tc task context
  */
 static void
-publish_zone_dht_next (void *cls,
-                       const struct GNUNET_SCHEDULER_TaskContext *tc)
+publish_zone_dht_next (void *cls)
 {
   zone_publish_task = NULL;
   GNUNET_NAMESTORE_zone_iterator_next (namestore_iter);
@@ -360,11 +361,9 @@ publish_zone_dht_next (void *cls,
  * Periodically iterate over our zone and store everything in dht
  *
  * @param cls NULL
- * @param tc task context
  */
 static void
-publish_zone_dht_start (void *cls,
-                       const struct GNUNET_SCHEDULER_TaskContext *tc);
+publish_zone_dht_start (void *cls);
 
 
 /**
@@ -511,7 +510,6 @@ perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
                         block_size,
                         block,
                         expire,
-                        DHT_OPERATION_TIMEOUT,
                         &dht_put_continuation,
                         pc_arg);
   GNUNET_free (block);
@@ -625,11 +623,9 @@ put_gns_record (void *cls,
  * Periodically iterate over all zones and store everything in DHT
  *
  * @param cls NULL
- * @param tc task context
  */
 static void
-publish_zone_dht_start (void *cls,
-                       const struct GNUNET_SCHEDULER_TaskContext *tc)
+publish_zone_dht_start (void *cls)
 {
   zone_publish_task = NULL;
 
@@ -710,9 +706,8 @@ send_lookup_response (void* cls,
   size_t len;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Sending `%s' message with %d results\n",
-              "LOOKUP_RESULT",
-             rd_count);
+             "Sending LOOKUP_RESULT message with %u results\n",
+             (unsigned int) rd_count);
 
   len = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
   rmsg = GNUNET_malloc (len + sizeof (struct GNUNET_GNS_ClientLookupResultMessage));
@@ -761,8 +756,7 @@ handle_lookup (void *cls,
   const struct GNUNET_GNS_ClientLookupMessage *sh_msg;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Received `%s' message\n",
-             "LOOKUP");
+             "Received LOOKUP message\n");
   msg_size = ntohs (message->size);
   if (msg_size < sizeof (struct GNUNET_GNS_ClientLookupMessage))
   {
@@ -876,9 +870,9 @@ monitor_sync_event (void *cls)
  */
 static void
 identity_intercept_cb (void *cls,
-                   struct GNUNET_IDENTITY_Ego *ego,
-                   void **ctx,
-                   const char *name)
+                       struct GNUNET_IDENTITY_Ego *ego,
+                       void **ctx,
+                       const char *name)
 {
   const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
   struct GNUNET_CRYPTO_EcdsaPublicKey dns_root;
@@ -893,8 +887,6 @@ identity_intercept_cb (void *cls,
   }
   GNUNET_IDENTITY_ego_get_public_key (ego,
                                      &dns_root);
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "DNS hijacking enabled. Connecting to DNS service.\n");
   if (GNUNET_SYSERR ==
       GNS_interceptor_init (&dns_root, cfg))
   {
@@ -986,6 +978,8 @@ run (void *cls,
   }
   else
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Looking for gns-intercept ego\n");
     identity_op = GNUNET_IDENTITY_get (identity_handle,
                                        "gns-intercept",
                                        &identity_intercept_cb,
@@ -1013,8 +1007,7 @@ run (void *cls,
                                               &monitor_sync_event,
                                               NULL);
   GNUNET_break (NULL != zmon);
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
-                               &shutdown_task, NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
 }