+/**
+ * Helper function to free resolver handle
+ *
+ * @param rh the handle to free
+ */
+static void
+free_resolver_handle (struct ResolverHandle* rh)
+{
+ struct AuthorityChain *ac;
+ struct AuthorityChain *ac_next;
+
+ if (NULL == rh)
+ return;
+
+ ac = rh->authority_chain_head;
+
+ while (NULL != ac)
+ {
+ ac_next = ac->next;
+ GNUNET_free(ac);
+ ac = ac_next;
+ }
+
+ if (NULL != rh->get_handle)
+ GNUNET_DHT_get_stop (rh->get_handle);
+
+ if (NULL != rh->dns_raw_packet)
+ GNUNET_free (rh->dns_raw_packet);
+
+ if (NULL != rh->namestore_task)
+ GNUNET_NAMESTORE_cancel (rh->namestore_task);
+ rh->namestore_task = NULL;
+
+ if (GNUNET_SCHEDULER_NO_TASK != rh->dns_read_task)
+ GNUNET_SCHEDULER_cancel (rh->dns_read_task);
+
+ if (GNUNET_SCHEDULER_NO_TASK != rh->timeout_task)
+ GNUNET_SCHEDULER_cancel (rh->timeout_task);
+
+ if (NULL != rh->dns_sock)
+ GNUNET_NETWORK_socket_close (rh->dns_sock);
+ if (NULL != rh->dns_resolver_handle)
+ GNUNET_RESOLVER_request_cancel (rh->dns_resolver_handle);
+
+ if (NULL != rh->rd.data)
+ GNUNET_free ((void*)(rh->rd.data));
+ GNUNET_free(rh);
+}
+
+
+/**
+ * finish shorten
+ *
+ * @param rh resolver handle
+ * @param nsh name shorten handle
+ */
+static void
+finish_shorten (struct ResolverHandle *rh,
+ struct NameShortenHandle *nsh);
+/**
+ * finish get auth
+ *
+ * @param rh resolver handle
+ * @param nah get name authority handle
+ */
+static void
+finish_get_auth (struct ResolverHandle *rh,
+ struct GetNameAuthorityHandle* rlh);