gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r20004 - gnunet/src/namestore
Date: Fri, 24 Feb 2012 13:43:42 +0100

Author: wachs
Date: 2012-02-24 13:43:42 +0100 (Fri, 24 Feb 2012)
New Revision: 20004

Modified:
   gnunet/src/namestore/namestore_api.c
Log:
- changes


Modified: gnunet/src/namestore/namestore_api.c
===================================================================
--- gnunet/src/namestore/namestore_api.c        2012-02-24 12:15:57 UTC (rev 
20003)
+++ gnunet/src/namestore/namestore_api.c        2012-02-24 12:43:42 UTC (rev 
20004)
@@ -43,6 +43,8 @@
   struct GNUNET_NAMESTORE_QueueEntry *next;
   struct GNUNET_NAMESTORE_QueueEntry *prev;
 
+  struct GNUNET_NAMESTORE_Handle *nsh;
+
   uint64_t op_id;
 
   GNUNET_NAMESTORE_ContinuationWithStatus cont;
@@ -56,6 +58,23 @@
 
 
 /**
+ * Zone iterator
+ */
+struct GNUNET_NAMESTORE_ZoneIterator
+{
+  struct GNUNET_NAMESTORE_ZoneIterator *next;
+  struct GNUNET_NAMESTORE_ZoneIterator *prev;
+
+  struct GNUNET_NAMESTORE_Handle *h;
+  GNUNET_NAMESTORE_RecordProcessor proc;
+  void* proc_cls;
+  const GNUNET_HashCode * zone;
+  uint32_t no_flags;
+  uint32_t flags;
+};
+
+
+/**
  * Message in linked list we should send to the service.  The
  * actual binary message follows this struct.
  */
@@ -124,13 +143,18 @@
 
 
   /**
-   * Pending namestore operations
+   * Pending namestore queue entries
    */
-
   struct GNUNET_NAMESTORE_QueueEntry * op_head;
   struct GNUNET_NAMESTORE_QueueEntry * op_tail;
 
   uint64_t op_id;
+
+  /**
+   * Pending namestore zone iterator entries
+   */
+  struct GNUNET_NAMESTORE_ZoneIterator * z_head;
+  struct GNUNET_NAMESTORE_ZoneIterator * z_tail;
 };
 
 struct GNUNET_NAMESTORE_SimpleRecord
@@ -154,6 +178,7 @@
   const void *data;
 };
 
+
 /**
  * Disconnect from service and then reconnect.
  *
@@ -398,7 +423,10 @@
 {
   struct PendingMessage *p;
   struct GNUNET_NAMESTORE_QueueEntry *q;
+  struct GNUNET_NAMESTORE_ZoneIterator *z;
 
+  GNUNET_assert (nsh != NULL);
+
   while (NULL != (p = nsh->pending_head))
   {
     GNUNET_CONTAINER_DLL_remove (nsh->pending_head, nsh->pending_tail, p);
@@ -411,6 +439,12 @@
     GNUNET_free (q);
   }
 
+  while (NULL != (z = nsh->z_head))
+  {
+    GNUNET_CONTAINER_DLL_remove (nsh->z_head, nsh->z_tail, z);
+    GNUNET_free (z);
+  }
+
   if (NULL != nsh->client)
   {
     GNUNET_CLIENT_disconnect (nsh->client, GNUNET_NO);
@@ -462,6 +496,7 @@
   GNUNET_assert (NULL != h);
 
   qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
+  qe->nsh = h;
   qe->cont = cont;
   qe->cont_cls = cont_cls;
   enqeue_namestore_operation(h, qe);
@@ -538,6 +573,7 @@
   GNUNET_assert (NULL != h);
 
   qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
+  qe->nsh = h;
   qe->cont = cont;
   qe->cont_cls = cont_cls;
   enqeue_namestore_operation(h, qe);
@@ -583,6 +619,7 @@
   GNUNET_assert (NULL != h);
 
   qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
+  qe->nsh = h;
   qe->cont = cont;
   qe->cont_cls = cont_cls;
   enqeue_namestore_operation(h, qe);
@@ -641,6 +678,7 @@
   GNUNET_assert (NULL != h);
 
   qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
+  qe->nsh = h;
   qe->proc = proc;
   qe->proc_cls = proc_cls;
   enqeue_namestore_operation(h, qe);
@@ -711,7 +749,17 @@
                                       GNUNET_NAMESTORE_RecordProcessor proc,
                                       void *proc_cls)
 {
-  return NULL;
+  struct GNUNET_NAMESTORE_ZoneIterator *it;
+
+  GNUNET_assert (h != NULL);
+
+  it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator));
+  it->h = h;
+  it->proc = proc;
+  it->proc_cls = proc;
+  GNUNET_CONTAINER_DLL_insert(h->z_head, h->z_tail, it);
+
+  return it;
 }
 
 
@@ -724,6 +772,7 @@
 void
 GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it)
 {
+
 }
 
 
@@ -735,6 +784,13 @@
 void
 GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
 {
+  struct GNUNET_NAMESTORE_Handle * nsh;
+  GNUNET_assert (it != NULL);
+
+  nsh = it->h;
+  GNUNET_CONTAINER_DLL_remove (nsh->z_head, nsh->z_tail, it);
+  GNUNET_free (it);
+
 }
 
 
@@ -747,8 +803,13 @@
 void
 GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe)
 {
-  if (qe)
-    GNUNET_free(qe);
+  struct GNUNET_NAMESTORE_Handle *nsh = qe->nsh;
+
+  GNUNET_assert (qe != NULL);
+
+  GNUNET_CONTAINER_DLL_remove(nsh->op_head, nsh->op_tail, qe);
+  GNUNET_free(qe);
+
 }
 
 /* end of namestore_api.c */




reply via email to

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