gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: clean up zone iteration log


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: clean up zone iteration logic
Date: Wed, 25 Apr 2018 18:48:34 +0200

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

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new c15e79511 clean up zone iteration logic
c15e79511 is described below

commit c15e7951180d954ca584a95206543e8997b3a7d4
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Apr 25 18:48:32 2018 +0200

    clean up zone iteration logic
---
 src/namestore/gnunet-service-namestore.c | 83 ++++++++------------------------
 src/namestore/gnunet-zoneimport.c        |  1 +
 2 files changed, 21 insertions(+), 63 deletions(-)

diff --git a/src/namestore/gnunet-service-namestore.c 
b/src/namestore/gnunet-service-namestore.c
index c5a37dcac..994eae2c8 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -1301,29 +1301,6 @@ handle_zone_to_name (void *cls,
 
 
 /**
- * Zone iteration processor result
- */
-enum ZoneIterationResult
-{
-  /**
-   * Iteration start.
-   */
-  IT_START = 0,
-
-  /**
-   * Found records,
-   * Continue to iterate with next iteration_next call
-   */
-  IT_SUCCESS_MORE_AVAILABLE = 1,
-
-  /**
-   * Iteration complete
-   */
-  IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE = 2
-};
-
-
-/**
  * Context for record remove operations passed from
  * #run_zone_iteration_round to #zone_iterate_proc as closure
  */
@@ -1339,15 +1316,6 @@ struct ZoneIterationProcResult
    */
   uint64_t limit;
 
-  /**
-   * Iteration result: iteration done?
-   * #IT_SUCCESS_MORE_AVAILABLE:  if there may be more results overall but
-   * we got one for now and have sent it to the client
-   * #IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE: if there are no further results,
-   * #IT_START: if we are still trying to find a result.
-   */
-  int res_iteration_finished;
-
 };
 
 
@@ -1375,21 +1343,22 @@ zone_iterate_proc (void *cls,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Iteration done\n");
-    proc->res_iteration_finished = IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE;
     return;
   }
   if ( (NULL == zone_key) ||
        (NULL == name) )
   {
     /* what is this!? should never happen */
-    proc->res_iteration_finished = IT_START;
     GNUNET_break (0);
     return;
   }
-  GNUNET_assert (proc->limit > 0);
-  proc->limit--;
   if (0 == proc->limit)
-    proc->res_iteration_finished = IT_SUCCESS_MORE_AVAILABLE;
+  {
+    /* what is this!? should never happen */
+    GNUNET_break (0);
+    return;
+  }
+  proc->limit--;
   send_lookup_response (proc->zi->nc,
                        proc->zi->request_id,
                        zone_key,
@@ -1426,36 +1395,25 @@ run_zone_iteration_round (struct ZoneIteration *zi,
   struct ZoneIterationProcResult proc;
   struct GNUNET_MQ_Envelope *env;
   struct RecordResultMessage *rrm;
-  int ret;
 
   memset (&proc,
           0,
           sizeof (proc));
   proc.zi = zi;
-  proc.res_iteration_finished = IT_START;
   proc.limit = limit;
-  while (IT_START == proc.res_iteration_finished)
-  {
-    if (GNUNET_SYSERR ==
-       (ret = GSN_database->iterate_records (GSN_database->cls,
-                                             (0 == memcmp (&zi->zone,
-                                                            &zero,
-                                                            sizeof (zero)))
-                                             ? NULL
-                                             : &zi->zone,
-                                             zi->offset,
-                                              limit,
-                                             &zone_iterate_proc,
-                                              &proc)))
-    {
-      GNUNET_break (0);
-      break;
-    }
-    if (GNUNET_NO == ret)
-      proc.res_iteration_finished = IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE;
-    zi->offset++;
-  }
-  if (IT_SUCCESS_MORE_AVAILABLE == proc.res_iteration_finished)
+  GNUNET_break (GNUNET_SYSERR !=
+                GSN_database->iterate_records (GSN_database->cls,
+                                               (0 == memcmp (&zi->zone,
+                                                             &zero,
+                                                             sizeof (zero)))
+                                               ? NULL
+                                               : &zi->zone,
+                                               zi->offset,
+                                               limit,
+                                               &zone_iterate_proc,
+                                               &proc));
+  zi->offset += (limit - proc.limit);
+  if (0 == proc.limit)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "More results available\n");
@@ -1520,8 +1478,7 @@ handle_iteration_stop (void *cls,
   uint32_t rid;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Received `%s' message\n",
-             "ZONE_ITERATION_STOP");
+             "Received ZONE_ITERATION_STOP message\n");
   rid = ntohl (zis_msg->gns_header.r_id);
   for (zi = nc->op_head; NULL != zi; zi = zi->next)
     if (zi->request_id == rid)
diff --git a/src/namestore/gnunet-zoneimport.c 
b/src/namestore/gnunet-zoneimport.c
index 356e740f1..779df695b 100644
--- a/src/namestore/gnunet-zoneimport.c
+++ b/src/namestore/gnunet-zoneimport.c
@@ -1515,6 +1515,7 @@ iterate_zones (void *cls)
                                            NULL);
     GNUNET_CONTAINER_multihashmap_destroy (ns_pending);
     ns_pending = NULL;
+    GNUNET_assert (NULL == t);
     t = GNUNET_SCHEDULER_add_now (&process_queue,
                                   NULL);
     return;

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



reply via email to

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