gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] 03/03: update namestore monitor API users to use n


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 03/03: update namestore monitor API users to use new _next call where needed
Date: Sat, 05 May 2018 23:52:57 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

commit 645b26ba88218c4a2f9a022968a8c03e9035082d
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat May 5 23:18:00 2018 +0200

    update namestore monitor API users to use new _next call where needed
---
 src/namestore/gnunet-namestore.c                   | 62 ++++++++++++++++++----
 src/namestore/test_namestore_api_monitoring.c      |  5 +-
 .../test_namestore_api_monitoring_existing.c       | 55 +++++++++++++------
 src/zonemaster/gnunet-service-zonemaster.c         | 16 ++++++
 4 files changed, 110 insertions(+), 28 deletions(-)

diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index d329dcb3b..32b1a39d0 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -374,16 +374,12 @@ zone_iteration_error_cb (void *cls)
 /**
  * Process a record that was stored in the namestore.
  *
- * @param cls closure
- * @param zone_key private key of the zone
  * @param rname name that is being mapped (at most 255 characters long)
  * @param rd_len number of entries in @a rd array
  * @param rd array of records with data to store
  */
 static void
-display_record (void *cls,
-               const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
-               const char *rname,
+display_record (const char *rname,
                unsigned int rd_len,
                const struct GNUNET_GNSRECORD_Data *rd)
 {
@@ -393,8 +389,6 @@ display_record (void *cls,
   struct GNUNET_TIME_Absolute at;
   struct GNUNET_TIME_Relative rt;
 
-  (void) cls;
-  (void) zone_key;
   if ( (NULL != name) &&
        (0 != strcmp (name, rname)) )
   {
@@ -442,12 +436,62 @@ display_record (void *cls,
     GNUNET_free (s);
   }
   FPRINTF (stdout, "%s", "\n");
+}
+
+
+/**
+ * Process a record that was stored in the namestore.
+ *
+ * @param cls closure
+ * @param zone_key private key of the zone
+ * @param rname name that is being mapped (at most 255 characters long)
+ * @param rd_len number of entries in @a rd array
+ * @param rd array of records with data to store
+ */
+static void
+display_record_iterator (void *cls,
+                         const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
+                         const char *rname,
+                         unsigned int rd_len,
+                         const struct GNUNET_GNSRECORD_Data *rd)
+{
+  (void) cls;
+  (void) zone_key;
+  display_record (rname,
+                  rd_len,
+                  rd);
   GNUNET_NAMESTORE_zone_iterator_next (list_it,
                                        1);
 }
 
 
 /**
+ * Process a record that was stored in the namestore.
+ *
+ * @param cls closure
+ * @param zone_key private key of the zone
+ * @param rname name that is being mapped (at most 255 characters long)
+ * @param rd_len number of entries in @a rd array
+ * @param rd array of records with data to store
+ */
+static void
+display_record_monitor (void *cls,
+                        const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
+                        const char *rname,
+                        unsigned int rd_len,
+                        const struct GNUNET_GNSRECORD_Data *rd)
+{
+  (void) cls;
+  (void) zone_key;
+  display_record (rname,
+                  rd_len,
+                  rd);
+  GNUNET_NAMESTORE_zone_monitor_next (zm,
+                                      1);
+}
+
+
+/**
  * Function called once we are in sync in monitor mode.
  *
  * @param cls NULL
@@ -956,7 +1000,7 @@ identity_cb (void *cls,
                                                      &zone_pkey,
                                                      &zone_iteration_error_cb,
                                                      NULL,
-                                                     &display_record,
+                                                     &display_record_iterator,
                                                      NULL,
                                                      &zone_iteration_finished,
                                                      NULL);
@@ -1054,7 +1098,7 @@ identity_cb (void *cls,
                                               GNUNET_YES,
                                               &monitor_error_cb,
                                               NULL,
-                                             &display_record,
+                                             &display_record_monitor,
                                               NULL,
                                              &sync_cb,
                                              NULL);
diff --git a/src/namestore/test_namestore_api_monitoring.c 
b/src/namestore/test_namestore_api_monitoring.c
index f6d4fe226..cd38b2c80 100644
--- a/src/namestore/test_namestore_api_monitoring.c
+++ b/src/namestore/test_namestore_api_monitoring.c
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2013 GNUnet e.V.
+     Copyright (C) 2013, 2018 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
@@ -192,7 +192,8 @@ zone_proc (void *cls,
     GNUNET_break (0);
     fail = GNUNET_YES;
   }
-
+  GNUNET_NAMESTORE_zone_monitor_next (zm,
+                                      1);
   if (2 == ++returned_records)
   {
     if (endbadly_task != NULL)
diff --git a/src/namestore/test_namestore_api_monitoring_existing.c 
b/src/namestore/test_namestore_api_monitoring_existing.c
index 17f726eb1..f6a74609e 100644
--- a/src/namestore/test_namestore_api_monitoring_existing.c
+++ b/src/namestore/test_namestore_api_monitoring_existing.c
@@ -159,19 +159,24 @@ zone_proc (void *cls,
              "Comparing results name %s\n",
              name);
 
-  if (0 != memcmp (zone_key, privkey, sizeof (struct 
GNUNET_CRYPTO_EcdsaPrivateKey)))
+  if (0 != memcmp (zone_key,
+                   privkey,
+                   sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Monitoring returned wrong zone key\n");
     GNUNET_break (0);
     GNUNET_SCHEDULER_cancel (endbadly_task);
-    endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+    endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly,
+                                              NULL);
     return;
   }
 
   if (0 == strcmp (name, s_name_1))
   {
-    if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_1))
+    if (GNUNET_YES !=
+        GNUNET_GNSRECORD_records_cmp (rd,
+                                      s_rd_1))
     {
       GNUNET_break (0);
        fail = GNUNET_YES;
@@ -179,7 +184,9 @@ zone_proc (void *cls,
   }
   else if (0 == strcmp (name, s_name_2))
   {
-    if (GNUNET_YES != GNUNET_GNSRECORD_records_cmp(rd, s_rd_2))
+    if (GNUNET_YES !=
+        GNUNET_GNSRECORD_records_cmp (rd,
+                                      s_rd_2))
     {
       GNUNET_break (0);
        fail = GNUNET_YES;
@@ -192,7 +199,8 @@ zone_proc (void *cls,
        GNUNET_break (0);
     fail = GNUNET_YES;
   }
-
+  GNUNET_NAMESTORE_zone_monitor_next (zm,
+                                      1);
   if (2 == ++returned_records)
   {
     if (endbadly_task != NULL)
@@ -201,9 +209,11 @@ zone_proc (void *cls,
       endbadly_task = NULL;
     }
     if (GNUNET_YES == fail)
-      GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+      GNUNET_SCHEDULER_add_now (&endbadly,
+                                NULL);
     else
-       GNUNET_SCHEDULER_add_now (&end, NULL);
+      GNUNET_SCHEDULER_add_now (&end,
+                                NULL);
   }
 }
 
@@ -223,7 +233,9 @@ sync_cb (void *cls)
 
 
 static void
-put_cont (void *cls, int32_t success, const char *emsg)
+put_cont (void *cls,
+          int32_t success,
+          const char *emsg)
 {
   static int c = 0;
   char *label = cls;
@@ -238,11 +250,15 @@ put_cont (void *cls, int32_t success, const char *emsg)
   if (success == GNUNET_OK)
   {
     c++;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record %u: `%s'\n", c, 
label);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Created record %u: `%s'\n",
+                c,
+                label);
   }
   else
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Failed to created records\n");
     GNUNET_break (0);
     GNUNET_SCHEDULER_cancel (endbadly_task);
     endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
@@ -262,9 +278,11 @@ put_cont (void *cls, int32_t success, const char *emsg)
                                               NULL);
     if (NULL == zm)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone monitor\n");
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Failed to create zone monitor\n");
       GNUNET_break (0);
-      endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+      endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly,
+                                                NULL);
       return;
     }
   }
@@ -354,14 +372,17 @@ run (void *cls,
   GNUNET_assert (NULL != (ns_ops[0] = GNUNET_NAMESTORE_records_store(nsh, 
privkey, s_name_1,
                1, s_rd_1, &put_cont, s_name_1)));
 
-
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n");
   GNUNET_asprintf(&s_name_2, "dummy2");
   s_rd_2 = create_record(1);
-  GNUNET_assert (NULL != (ns_ops[1] = GNUNET_NAMESTORE_records_store(nsh, 
privkey, s_name_2,
-               1, s_rd_2, &put_cont, s_name_2)));
-
-
+  GNUNET_assert (NULL != (ns_ops[1] =
+                          GNUNET_NAMESTORE_records_store (nsh,
+                                                          privkey,
+                                                          s_name_2,
+                                                          1,
+                                                          s_rd_2,
+                                                          &put_cont,
+                                                          s_name_2)));
 }
 
 
diff --git a/src/zonemaster/gnunet-service-zonemaster.c 
b/src/zonemaster/gnunet-service-zonemaster.c
index 7129cf44f..cbb890589 100644
--- a/src/zonemaster/gnunet-service-zonemaster.c
+++ b/src/zonemaster/gnunet-service-zonemaster.c
@@ -60,6 +60,12 @@
 #define DHT_QUEUE_LIMIT 2000
 
 /**
+ * How many events may the namestore give us before it has to wait
+ * for us to keep up?
+ */
+#define NAMESTORE_QUEUE_LIMIT 50
+
+/**
  * The initial interval in milliseconds btween puts in
  * a zone iteration
  */
@@ -374,6 +380,8 @@ dht_put_monitor_continuation (void *cls)
 {
   struct DhtPutActivity *ma = cls;
 
+  GNUNET_NAMESTORE_zone_monitor_next (zmon,
+                                      1);
   ma_queue_length--;
   GNUNET_CONTAINER_DLL_remove (ma_head,
                                ma_tail,
@@ -924,7 +932,11 @@ handle_monitor_event (void *cls,
                                                 rd_count,
                                                 rd_public);
   if (0 == rd_public_count)
+  {
+    GNUNET_NAMESTORE_zone_monitor_next (zmon,
+                                        1);
     return; /* nothing to do */
+  }
   num_public_records++;
   ma = GNUNET_new (struct DhtPutActivity);
   ma->start_date = GNUNET_TIME_absolute_get ();
@@ -938,6 +950,8 @@ handle_monitor_event (void *cls,
   {
     /* PUT failed, do not remember operation */
     GNUNET_free (ma);
+    GNUNET_NAMESTORE_zone_monitor_next (zmon,
+                                        1);
     return;
   }
   GNUNET_CONTAINER_DLL_insert_tail (ma_head,
@@ -1097,6 +1111,8 @@ run (void *cls,
                                               NULL,
                                               &monitor_sync_event,
                                               NULL);
+  GNUNET_NAMESTORE_zone_monitor_next (zmon,
+                                      NAMESTORE_QUEUE_LIMIT - 1);
   GNUNET_break (NULL != zmon);
   GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
                                 NULL);

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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