From: Christian Grothoff Date: Tue, 19 Jun 2012 21:14:47 +0000 (+0000) Subject: -starting a bit with namestore_api cleanup X-Git-Tag: initial-import-from-subversion-38251~12963 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=bc6e260a1452b0de53e5568e668228ec068e2680;p=oweals%2Fgnunet.git -starting a bit with namestore_api cleanup --- diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index e216ad767..83dc4dd33 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c @@ -54,17 +54,41 @@ struct GNUNET_NAMESTORE_QueueEntry */ struct GNUNET_NAMESTORE_QueueEntry *prev; + /** + * Main handle to access the namestore. + */ struct GNUNET_NAMESTORE_Handle *nsh; - uint32_t op_id; - + /** + * + */ GNUNET_NAMESTORE_ContinuationWithStatus cont; + + /** + * Closure for 'cont'. + */ void *cont_cls; + /** + * Function to call with the records we get back; or NULL. + */ GNUNET_NAMESTORE_RecordProcessor proc; + + /** + * Closure for 'proc'. + */ void *proc_cls; - char *data; /*stub data pointer*/ + /** + * stub data pointer (???) + */ + char *data; + + /** + * + */ + uint32_t op_id; + }; @@ -84,15 +108,46 @@ struct GNUNET_NAMESTORE_ZoneIterator */ struct GNUNET_NAMESTORE_ZoneIterator *prev; - uint32_t op_id; - + /** + * Main handle to access the namestore. + */ struct GNUNET_NAMESTORE_Handle *h; + + /** + * + */ GNUNET_NAMESTORE_RecordProcessor proc; + + /** + * Closure for 'proc'. + */ void* proc_cls; + + /** + * + */ struct GNUNET_CRYPTO_ShortHashCode zone; + + /** + * + */ uint32_t no_flags; + + /** + * + */ uint32_t flags; + + /** + * + */ + uint32_t op_id; + + /** + * + */ int has_zone; + }; @@ -147,38 +202,56 @@ struct GNUNET_NAMESTORE_Handle struct GNUNET_CLIENT_TransmitHandle *th; /** - * Reconnect task + * Head of linked list of pending messages to send to the service */ - GNUNET_SCHEDULER_TaskIdentifier reconnect_task; + struct PendingMessage * pending_head; /** - * Pending messages to send to the service + * Tail of linked list of pending messages to send to the service */ - - struct PendingMessage * pending_head; struct PendingMessage * pending_tail; /** - * Should we reconnect to service due to some serious error? + * Head of pending namestore queue entries */ - int reconnect; - + struct GNUNET_NAMESTORE_QueueEntry * op_head; /** - * Pending namestore queue entries + * Tail of pending namestore queue entries */ - struct GNUNET_NAMESTORE_QueueEntry * op_head; struct GNUNET_NAMESTORE_QueueEntry * op_tail; - uint32_t op_id; - /** - * Pending namestore zone iterator entries + * Head of pending namestore zone iterator entries */ struct GNUNET_NAMESTORE_ZoneIterator * z_head; + + /** + * Tail of pending namestore zone iterator entries + */ struct GNUNET_NAMESTORE_ZoneIterator * z_tail; + + /** + * Reconnect task + */ + GNUNET_SCHEDULER_TaskIdentifier reconnect_task; + + /** + * Should we reconnect to service due to some serious error? + */ + int reconnect; + + /** + * ??? + */ + uint32_t op_id; + }; + +/** + * ??? + */ struct GNUNET_NAMESTORE_SimpleRecord { /** @@ -191,13 +264,41 @@ struct GNUNET_NAMESTORE_SimpleRecord */ struct GNUNET_NAMESTORE_SimpleRecord *prev; + /** + * ??? + */ const char *name; + + /** + * ??? + */ const struct GNUNET_CRYPTO_ShortHashCode *zone; - uint32_t record_type; + + /** + * ??? + */ + const void *data; + + /** + * ??? + */ struct GNUNET_TIME_Absolute expiration; - enum GNUNET_NAMESTORE_RecordFlags flags; + + /** + * ??? + */ size_t data_size; - const void *data; + + /** + * ??? + */ + enum GNUNET_NAMESTORE_RecordFlags flags; + + /** + * ??? + */ + uint32_t record_type; + }; @@ -210,23 +311,15 @@ struct GNUNET_NAMESTORE_SimpleRecord static void force_reconnect (struct GNUNET_NAMESTORE_Handle *h); + static void handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, struct LookupNameResponseMessage * msg, size_t size) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n", - "LOOKUP_NAME_RESPONSE"); - struct GNUNET_NAMESTORE_Handle *h = qe->nsh; - - /* Operation done, remove */ - GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe); - - char *name; char * rd_tmp; - struct GNUNET_CRYPTO_RsaSignature *signature = NULL; struct GNUNET_TIME_Absolute expire; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key_tmp; @@ -237,6 +330,10 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, int contains_sig = GNUNET_NO; int rd_count = 0; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n", + "LOOKUP_NAME_RESPONSE"); + /* Operation done, remove */ + GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe); rd_len = ntohs (msg->rd_len); rd_count = ntohs (msg->rd_count); msg_len = ntohs (msg->gns_header.header.size); @@ -437,6 +534,7 @@ handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe, GNUNET_free (qe); } + static void handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, struct ZoneToNameResponseMessage* msg, @@ -559,6 +657,7 @@ manage_record_operations (struct GNUNET_NAMESTORE_QueueEntry *qe, } } + static void handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze, struct ZoneIterationResponseMessage *msg, @@ -653,6 +752,7 @@ manage_zone_operations (struct GNUNET_NAMESTORE_ZoneIterator *ze, } } + /** * Type of a function to call when we receive a message * from the service. @@ -870,6 +970,7 @@ force_reconnect (struct GNUNET_NAMESTORE_Handle *h) h); } + static uint32_t get_op_id (struct GNUNET_NAMESTORE_Handle *h) { @@ -878,6 +979,7 @@ get_op_id (struct GNUNET_NAMESTORE_Handle *h) return op_id; } + /** * Initialize the connection with the NAMESTORE service. * @@ -896,6 +998,7 @@ GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) return h; } + static void clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { @@ -1477,8 +1580,6 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, uint32_t rid = 0; GNUNET_assert (NULL != h); - - rid = get_op_id(h); it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator)); it->h = h; @@ -1523,8 +1624,6 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, msg->must_have_flags = ntohs (must_have_flags); msg->must_not_have_flags = ntohs (must_not_have_flags); - - /* transmit message */ GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe); do_transmit(h); @@ -1637,10 +1736,8 @@ GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe) struct GNUNET_NAMESTORE_Handle *h = qe->nsh; GNUNET_assert (qe != NULL); - GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, qe); GNUNET_free(qe); - } /* end of namestore_api.c */