[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9011 - gnunet/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9011 - gnunet/src/fs |
Date: |
Tue, 22 Sep 2009 12:16:24 -0600 |
Author: grothoff
Date: 2009-09-22 12:16:23 -0600 (Tue, 22 Sep 2009)
New Revision: 9011
Modified:
gnunet/src/fs/gnunet-service-fs.c
Log:
more clean up code
Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c 2009-09-22 17:59:32 UTC (rev 9010)
+++ gnunet/src/fs/gnunet-service-fs.c 2009-09-22 18:16:23 UTC (rev 9011)
@@ -534,6 +534,10 @@
*/
struct PendingRequest *req;
+ /**
+ * Client list with the head and tail of this DLL.
+ */
+ struct ClientList *cl;
};
@@ -1514,6 +1518,7 @@
clients = cl;
}
crl = GNUNET_malloc (sizeof (struct ClientRequestList));
+ crl->cl = cl;
GNUNET_CONTAINER_DLL_insert (cl->head, cl->tail, crl);
pr = GNUNET_malloc (sizeof (struct PendingRequest));
pr->client = lgc->client;
@@ -1732,9 +1737,8 @@
/**
- * Clean up the memory used by the PendingRequest
- * structure (except for the client or peer list
- * that the request may be part of).
+ * Clean up the memory used by the PendingRequest structure (except
+ * for the client or peer list that the request may be part of).
*
* @param pr request to clean up
*/
@@ -1742,15 +1746,25 @@
destroy_pending_request (struct PendingRequest *pr)
{
struct PendingReply *reply;
+ struct ClientList *cl;
GNUNET_CONTAINER_multihashmap_remove (requests_by_query,
&pr->query,
pr);
// FIXME: not sure how this can work (efficiently)
// also, what does the return value mean?
- if (pr->client != NULL)
- GNUNET_CONTAINER_heap_remove_node (requests_by_expiration,
- pr);
+ if (pr->client == NULL)
+ {
+ GNUNET_CONTAINER_heap_remove_node (requests_by_expiration,
+ pr);
+ }
+ else
+ {
+ cl = pr->crl_entry->cl;
+ GNUNET_CONTAINER_DLL_remove (cl->head,
+ cl->tail,
+ pr->crl_entry);
+ }
if (NULL != pr->bf)
GNUNET_CONTAINER_bloomfilter_free (pr->bf);
if (NULL != pr->cth)
@@ -1820,6 +1834,27 @@
/**
+ * Iterator over entries in the "requests_by_query" map
+ * that frees all the entries.
+ *
+ * @param cls closure, NULL
+ * @param key current key code (the query, unused)
+ * @param value value in the hash map, of type "struct PendingRequest*"
+ * @return GNUNET_YES (we should continue to iterate)
+ */
+static int
+destroy_pending_request_cb (void *cls,
+ const GNUNET_HashCode * key,
+ void *value)
+{
+ struct PendingRequest *pr = value;
+
+ destroy_pending_request (pr);
+ return GNUNET_YES;
+}
+
+
+/**
* Task run during shutdown.
*
* @param cls unused
@@ -1836,7 +1871,12 @@
GNUNET_DATASTORE_disconnect (dsh,
GNUNET_NO);
dsh = NULL;
- // FIXME: iterate over maps to free entries!
+ GNUNET_CONTAINER_multihashmap_iterate (requests_by_query,
+ &destroy_pending_request_cb,
+ NULL);
+ while (clients != NULL)
+ handle_client_disconnect (NULL,
+ clients->client);
GNUNET_CONTAINER_multihashmap_destroy (requests_by_query);
requests_by_query = NULL;
GNUNET_CONTAINER_multihashmap_destroy (requests_by_peer);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9011 - gnunet/src/fs,
gnunet <=