gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r20108 - gnunet/src/namestore


From: gnunet
Subject: [GNUnet-SVN] r20108 - gnunet/src/namestore
Date: Tue, 28 Feb 2012 11:18:27 +0100

Author: wachs
Date: 2012-02-28 11:18:27 +0100 (Tue, 28 Feb 2012)
New Revision: 20108

Modified:
   gnunet/src/namestore/gnunet-service-namestore.c
   gnunet/src/namestore/namestore_api.c
   gnunet/src/namestore/test_namestore_api_zone_iteration.c
Log:
- more zone iteration


Modified: gnunet/src/namestore/gnunet-service-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-service-namestore.c     2012-02-28 10:11:07 UTC 
(rev 20107)
+++ gnunet/src/namestore/gnunet-service-namestore.c     2012-02-28 10:18:27 UTC 
(rev 20108)
@@ -42,6 +42,8 @@
 
   struct GNUNET_NAMESTORE_Client * client;
 
+  GNUNET_HashCode zone;
+
   uint64_t op_id;
   uint32_t offset;
 
@@ -593,7 +595,6 @@
   zir_msg.op_id = htonl(zi->op_id);
   zir_msg.header.size = htons (sizeof (struct ZoneIterationResponseMessage));
 
-
   GNUNET_SERVER_notification_context_unicast (snc, zi->client->client, (const 
struct GNUNET_MessageHeader *) &zir_msg, GNUNET_NO);
 }
 
@@ -606,6 +607,7 @@
   struct ZoneIterationStartMessage * zis_msg = (struct 
ZoneIterationStartMessage *) message;
   struct GNUNET_NAMESTORE_Client *nc;
   struct GNUNET_NAMESTORE_ZoneIteration *zi;
+  int res;
 
   nc = client_lookup(client);
   if (nc == NULL)
@@ -619,10 +621,12 @@
   zi->op_id = ntohl (zis_msg->op_id);
   zi->offset = 0;
   zi->client = nc;
+  zi->zone = zis_msg->zone;
 
   GNUNET_CONTAINER_DLL_insert (nc->op_head, nc->op_tail, zi);
 
-  GSN_database->iterate_records (GSN_database->cls, &zis_msg->zone, NULL, 
zi->offset , &zone_iteration_proc, zi);
+  res = GSN_database->iterate_records (GSN_database->cls, &zis_msg->zone, 
NULL, zi->offset , &zone_iteration_proc, zi);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "iterate_records: %i\n", res);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
@@ -631,6 +635,38 @@
                           const struct GNUNET_MessageHeader * message)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", 
"ZONE_ITERATION_STOP");
+
+  struct GNUNET_NAMESTORE_Client *nc;
+  struct GNUNET_NAMESTORE_ZoneIteration *zi;
+  struct ZoneIterationStopMessage * zis_msg = (struct ZoneIterationStopMessage 
*) message;
+  uint32_t id;
+
+  nc = client_lookup(client);
+  if (nc == NULL)
+  {
+    GNUNET_break_op (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_OK);
+    return;
+  }
+
+  id = ntohl (zis_msg->op_id);
+  for (zi = nc->op_head; zi != NULL; zi = zi->next)
+  {
+    if (zi->op_id == id)
+      break;
+  }
+  if (zi == NULL)
+  {
+    GNUNET_break_op (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_OK);
+    return;
+  }
+
+  GNUNET_CONTAINER_DLL_remove(nc->op_head, nc->op_tail, zi);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopped zone iteration for zone 
`%s'\n", GNUNET_h2s (&zi->zone));
+  GNUNET_free (zi);
+
+  GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
 static void handle_iteration_next (void *cls,
@@ -671,7 +707,7 @@
     {&handle_iteration_start, NULL,
      GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, sizeof (struct 
ZoneIterationStartMessage)},
     {&handle_iteration_stop, NULL,
-     GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, 0},
+     GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, sizeof (struct 
ZoneIterationStopMessage)},
     {&handle_iteration_next, NULL,
      GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, 0},
     {NULL, NULL, 0, 0}

Modified: gnunet/src/namestore/namestore_api.c
===================================================================
--- gnunet/src/namestore/namestore_api.c        2012-02-28 10:11:07 UTC (rev 
20107)
+++ gnunet/src/namestore/namestore_api.c        2012-02-28 10:18:27 UTC (rev 
20108)
@@ -380,6 +380,13 @@
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n",
               "ZONE_ITERATION_RESPONSE");
+
+
+  if (ze->proc != NULL)
+  {
+    // FIXME
+    ze->proc(ze->proc_cls, NULL, GNUNET_TIME_absolute_get_forever(), "dummy", 
0, NULL, NULL);
+  }
 }
 
 

Modified: gnunet/src/namestore/test_namestore_api_zone_iteration.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_zone_iteration.c    2012-02-28 
10:11:07 UTC (rev 20107)
+++ gnunet/src/namestore/test_namestore_api_zone_iteration.c    2012-02-28 
10:18:27 UTC (rev 20108)
@@ -32,6 +32,7 @@
 static struct GNUNET_NAMESTORE_Handle * nsh;
 
 static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
+static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task;
 static struct GNUNET_OS_Process *arm;
 
 static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
@@ -76,6 +77,12 @@
 static void
 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  if (stopiteration_task != GNUNET_SCHEDULER_NO_TASK)
+  {
+    GNUNET_SCHEDULER_cancel (stopiteration_task);
+    stopiteration_task = GNUNET_SCHEDULER_NO_TASK;
+  }
+
   if (nsh != NULL)
     GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
   nsh = NULL;
@@ -94,12 +101,19 @@
 static void
 end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  if (stopiteration_task != GNUNET_SCHEDULER_NO_TASK)
+  {
+    GNUNET_SCHEDULER_cancel (stopiteration_task);
+    stopiteration_task = GNUNET_SCHEDULER_NO_TASK;
+  }
+
   if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
   {
     GNUNET_SCHEDULER_cancel (endbadly_task);
     endbadly_task = GNUNET_SCHEDULER_NO_TASK;
   }
 
+
   if (privkey != NULL)
     GNUNET_CRYPTO_rsa_key_free (privkey);
   privkey = NULL;
@@ -115,7 +129,17 @@
   res = 0;
 }
 
+static void
+stop_iteration (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  stopiteration_task = GNUNET_SCHEDULER_NO_TASK;
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping iteration for zone `%s'\n", 
GNUNET_h2s (&zone));
+  GNUNET_NAMESTORE_zone_iteration_stop (zi);
+
+  GNUNET_SCHEDULER_add_now (&end, NULL);
+}
+
 void zone_proc (void *cls,
                 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
                 struct GNUNET_TIME_Absolute expire,
@@ -125,7 +149,8 @@
                 const struct GNUNET_CRYPTO_RsaSignature *signature)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for zone `%s'\n", GNUNET_h2s 
(&zone));
-  endbadly_task = GNUNET_SCHEDULER_add_now (&end, NULL);
+
+  stopiteration_task = GNUNET_SCHEDULER_add_now (&stop_iteration, NULL);
 }
 
 static void




reply via email to

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