aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-02-01 15:04:49 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-02-01 15:04:49 +0000
commit5e345b2ed520f16ccd5f86b7fbd552976c229a1d (patch)
tree2bbf8e48c3b3b44cd0c5b0b224bfb9eedb814d67 /src
parent87e5b49767f48d12ad2410fb77088838488896d1 (diff)
downloadgnunet-5e345b2ed520f16ccd5f86b7fbd552976c229a1d.tar.gz
gnunet-5e345b2ed520f16ccd5f86b7fbd552976c229a1d.zip
- fix
Diffstat (limited to 'src')
-rw-r--r--src/testbed/gnunet-service-testbed_cache.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/testbed/gnunet-service-testbed_cache.c b/src/testbed/gnunet-service-testbed_cache.c
index c75ae7dc4..72754121f 100644
--- a/src/testbed/gnunet-service-testbed_cache.c
+++ b/src/testbed/gnunet-service-testbed_cache.c
@@ -238,6 +238,11 @@ struct CacheEntry
238 * The id of the peer this entry corresponds to 238 * The id of the peer this entry corresponds to
239 */ 239 */
240 unsigned int peer_id; 240 unsigned int peer_id;
241
242 /**
243 * Is this entry in LRU cache queue?
244 */
245 unsigned int in_lru;
241}; 246};
242 247
243 248
@@ -309,7 +314,7 @@ close_handles (struct CacheEntry *entry)
309 struct ConnectNotifyContext *ctxt; 314 struct ConnectNotifyContext *ctxt;
310 315
311 GNUNET_assert (0 == entry->demand); 316 GNUNET_assert (0 == entry->demand);
312 if ((NULL != entry->next) || (NULL != entry->prev)) 317 if (GNUNET_YES == entry->in_lru)
313 { 318 {
314 GNUNET_assert (0 < lru_cache_size); 319 GNUNET_assert (0 < lru_cache_size);
315 GNUNET_CONTAINER_DLL_remove (lru_cache_head, lru_cache_tail, entry); 320 GNUNET_CONTAINER_DLL_remove (lru_cache_head, lru_cache_tail, entry);
@@ -695,11 +700,13 @@ cache_get_handle (unsigned int peer_id,
695 entry = cache_lookup (&key); 700 entry = cache_lookup (&key);
696 if (NULL != entry) 701 if (NULL != entry)
697 { 702 {
698 if (0 == entry->demand) 703 if (GNUNET_YES == entry->in_lru)
699 { 704 {
705 GNUNET_assert (0 == entry->demand);
700 GNUNET_assert (0 < lru_cache_size); 706 GNUNET_assert (0 < lru_cache_size);
701 GNUNET_CONTAINER_DLL_remove (lru_cache_head, lru_cache_tail, entry); 707 GNUNET_CONTAINER_DLL_remove (lru_cache_head, lru_cache_tail, entry);
702 lru_cache_size--; 708 lru_cache_size--;
709 entry->in_lru = GNUNET_NO;
703 } 710 }
704 switch (cgh->type) 711 switch (cgh->type)
705 { 712 {
@@ -859,9 +866,10 @@ GST_cache_get_handle_done (struct GSTCacheGetHandle *cgh)
859 } 866 }
860 GNUNET_free (cgh); 867 GNUNET_free (cgh);
861 if (0 == entry->demand) 868 if (0 == entry->demand)
862 { 869 {
863 GNUNET_CONTAINER_DLL_insert_tail (lru_cache_head, lru_cache_tail, entry); 870 GNUNET_CONTAINER_DLL_insert_tail (lru_cache_head, lru_cache_tail, entry);
864 lru_cache_size++; 871 lru_cache_size++;
872 entry->in_lru = GNUNET_YES;
865 if (lru_cache_size > lru_cache_threshold_size) 873 if (lru_cache_size > lru_cache_threshold_size)
866 close_handles (lru_cache_head); 874 close_handles (lru_cache_head);
867 } 875 }