From: Matthias Wachs Date: Fri, 24 Feb 2012 12:43:42 +0000 (+0000) Subject: - changes X-Git-Tag: initial-import-from-subversion-38251~14669 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4597f567482bc7abf8f0199a7beb664d60216c3c;p=oweals%2Fgnunet.git - changes --- diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index af39a834c..16e42a7b1 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c @@ -43,6 +43,8 @@ struct GNUNET_NAMESTORE_QueueEntry struct GNUNET_NAMESTORE_QueueEntry *next; struct GNUNET_NAMESTORE_QueueEntry *prev; + struct GNUNET_NAMESTORE_Handle *nsh; + uint64_t op_id; GNUNET_NAMESTORE_ContinuationWithStatus cont; @@ -55,6 +57,23 @@ struct GNUNET_NAMESTORE_QueueEntry }; +/** + * 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 @@ struct GNUNET_NAMESTORE_Handle /** - * 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 @@ struct GNUNET_NAMESTORE_SimpleRecord const void *data; }; + /** * Disconnect from service and then reconnect. * @@ -398,6 +423,9 @@ GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *nsh, int drop) { struct PendingMessage *p; struct GNUNET_NAMESTORE_QueueEntry *q; + struct GNUNET_NAMESTORE_ZoneIterator *z; + + GNUNET_assert (nsh != NULL); while (NULL != (p = nsh->pending_head)) { @@ -411,6 +439,12 @@ GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *nsh, int drop) 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_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, 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_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h, 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_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h, 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_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h, 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_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, 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 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, void GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it) { + } @@ -735,6 +784,13 @@ GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator *it) 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 @@ GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it) 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 */