aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-01-28 15:03:58 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-01-28 15:03:58 +0000
commit87af323234ce202f508d25b4ecf886a3e31a7560 (patch)
tree61b1e59ea3cc0694837414c68b74843e6cc9e6aa /src
parentb14575f3d89ba108f1120e379f2f8e92735e5298 (diff)
downloadgnunet-87af323234ce202f508d25b4ecf886a3e31a7560.tar.gz
gnunet-87af323234ce202f508d25b4ecf886a3e31a7560.zip
- rename "hello cache" to "cache"
Diffstat (limited to 'src')
-rw-r--r--src/testbed/gnunet-service-testbed.c2
-rw-r--r--src/testbed/gnunet-service-testbed.h6
-rw-r--r--src/testbed/gnunet-service-testbed_hc.c78
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c4
-rw-r--r--src/testbed/testbed.conf.in2
5 files changed, 46 insertions, 46 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index c15e9d80b..8fc512c13 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -2190,7 +2190,7 @@ testbed_run (void *cls, struct GNUNET_SERVER_Handle *server,
2190 } 2190 }
2191 GNUNET_assert (GNUNET_OK == 2191 GNUNET_assert (GNUNET_OK ==
2192 GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED", 2192 GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED",
2193 "HELLO_CACHE_SIZE", 2193 "CACHE_SIZE",
2194 &num)); 2194 &num));
2195 GST_cache_init ((unsigned int) num); 2195 GST_cache_init ((unsigned int) num);
2196 GNUNET_assert (GNUNET_OK == 2196 GNUNET_assert (GNUNET_OK ==
diff --git a/src/testbed/gnunet-service-testbed.h b/src/testbed/gnunet-service-testbed.h
index 417e5b90f..157adc2ea 100644
--- a/src/testbed/gnunet-service-testbed.h
+++ b/src/testbed/gnunet-service-testbed.h
@@ -653,7 +653,7 @@ GST_destroy_peer (struct Peer *peer);
653 * @return the HELLO message; NULL if not found 653 * @return the HELLO message; NULL if not found
654 */ 654 */
655const struct GNUNET_MessageHeader * 655const struct GNUNET_MessageHeader *
656GST_hello_cache_lookup (const struct GNUNET_PeerIdentity *id); 656GST_cache_lookup (const struct GNUNET_PeerIdentity *id);
657 657
658/** 658/**
659 * Caches the HELLO of the given peer. Updates the HELLO if it was already 659 * Caches the HELLO of the given peer. Updates the HELLO if it was already
@@ -663,8 +663,8 @@ GST_hello_cache_lookup (const struct GNUNET_PeerIdentity *id);
663 * @param hello the HELLO message 663 * @param hello the HELLO message
664 */ 664 */
665void 665void
666GST_hello_cache_add (const struct GNUNET_PeerIdentity *id, 666GST_cache_add (const struct GNUNET_PeerIdentity *id,
667 const struct GNUNET_MessageHeader *hello); 667 const struct GNUNET_MessageHeader *hello);
668 668
669 669
670/** 670/**
diff --git a/src/testbed/gnunet-service-testbed_hc.c b/src/testbed/gnunet-service-testbed_hc.c
index 4637f59af..d1198dab1 100644
--- a/src/testbed/gnunet-service-testbed_hc.c
+++ b/src/testbed/gnunet-service-testbed_hc.c
@@ -27,19 +27,19 @@
27#include "gnunet-service-testbed.h" 27#include "gnunet-service-testbed.h"
28 28
29/** 29/**
30 * Hello cache entry 30 * Cache entry
31 */ 31 */
32struct HelloCacheEntry 32struct CacheEntry
33{ 33{
34 /** 34 /**
35 * DLL next ptr for least recently used hello cache entries 35 * DLL next ptr for least recently used cache entries
36 */ 36 */
37 struct HelloCacheEntry *next; 37 struct CacheEntry *next;
38 38
39 /** 39 /**
40 * DLL prev ptr for least recently used hello cache entries 40 * DLL prev ptr for least recently used cache entries
41 */ 41 */
42 struct HelloCacheEntry *prev; 42 struct CacheEntry *prev;
43 43
44 /** 44 /**
45 * The key for this entry 45 * The key for this entry
@@ -53,42 +53,42 @@ struct HelloCacheEntry
53}; 53};
54 54
55/** 55/**
56 * Hashmap to maintain HELLO cache 56 * Hashmap to maintain cache
57 */ 57 */
58static struct GNUNET_CONTAINER_MultiHashMap *hello_cache; 58static struct GNUNET_CONTAINER_MultiHashMap *cache;
59 59
60/** 60/**
61 * DLL head for least recently used hello cache entries; least recently used 61 * DLL head for least recently used cache entries; least recently used
62 * cache items are at the head 62 * cache items are at the head
63 */ 63 */
64static struct HelloCacheEntry *lru_hcache_head; 64static struct CacheEntry *lru_hcache_head;
65 65
66/** 66/**
67 * DLL tail for least recently used hello cache entries; recently used cache 67 * DLL tail for least recently used cache entries; recently used cache
68 * items are at the tail 68 * items are at the tail
69 */ 69 */
70static struct HelloCacheEntry *lru_hcache_tail; 70static struct CacheEntry *lru_hcache_tail;
71 71
72/** 72/**
73 * The size of HELLO cache 73 * The size of cache
74 */ 74 */
75static unsigned int hello_cache_size; 75static unsigned int cache_size;
76 76
77 77
78/** 78/**
79 * Looks up in the hello cache and returns the HELLO of the given peer 79 * Looks up in the cache and returns the HELLO of the given peer
80 * 80 *
81 * @param id the peer identity of the peer whose HELLO has to be looked up 81 * @param id the peer identity of the peer whose HELLO has to be looked up
82 * @return the HELLO message; NULL if not found 82 * @return the HELLO message; NULL if not found
83 */ 83 */
84const struct GNUNET_MessageHeader * 84const struct GNUNET_MessageHeader *
85GST_hello_cache_lookup (const struct GNUNET_PeerIdentity *id) 85GST_cache_lookup (const struct GNUNET_PeerIdentity *id)
86{ 86{
87 struct HelloCacheEntry *entry; 87 struct CacheEntry *entry;
88 88
89 if (NULL == hello_cache) 89 if (NULL == cache)
90 return NULL; 90 return NULL;
91 entry = GNUNET_CONTAINER_multihashmap_get (hello_cache, &id->hashPubKey); 91 entry = GNUNET_CONTAINER_multihashmap_get (cache, &id->hashPubKey);
92 if (NULL == entry) 92 if (NULL == entry)
93 return NULL; 93 return NULL;
94 GNUNET_CONTAINER_DLL_remove (lru_hcache_head, lru_hcache_tail, entry); 94 GNUNET_CONTAINER_DLL_remove (lru_hcache_head, lru_hcache_tail, entry);
@@ -98,16 +98,16 @@ GST_hello_cache_lookup (const struct GNUNET_PeerIdentity *id)
98 98
99 99
100/** 100/**
101 * Removes the given hello cache centry from hello cache and frees its resources 101 * Removes the given cache entry from cache and frees its resources
102 * 102 *
103 * @param entry the entry to remove 103 * @param entry the entry to remove
104 */ 104 */
105static void 105static void
106GST_hello_cache_remove (struct HelloCacheEntry *entry) 106GST_cache_remove (struct CacheEntry *entry)
107{ 107{
108 GNUNET_CONTAINER_DLL_remove (lru_hcache_head, lru_hcache_tail, entry); 108 GNUNET_CONTAINER_DLL_remove (lru_hcache_head, lru_hcache_tail, entry);
109 GNUNET_assert (GNUNET_YES == 109 GNUNET_assert (GNUNET_YES ==
110 GNUNET_CONTAINER_multihashmap_remove (hello_cache, &entry->key, 110 GNUNET_CONTAINER_multihashmap_remove (cache, &entry->key,
111 entry)); 111 entry));
112 GNUNET_free (entry->hello); 112 GNUNET_free (entry->hello);
113 GNUNET_free (entry); 113 GNUNET_free (entry);
@@ -122,25 +122,25 @@ GST_hello_cache_remove (struct HelloCacheEntry *entry)
122 * @param hello the HELLO message 122 * @param hello the HELLO message
123 */ 123 */
124void 124void
125GST_hello_cache_add (const struct GNUNET_PeerIdentity *id, 125GST_cache_add (const struct GNUNET_PeerIdentity *id,
126 const struct GNUNET_MessageHeader *hello) 126 const struct GNUNET_MessageHeader *hello)
127{ 127{
128 struct HelloCacheEntry *entry; 128 struct CacheEntry *entry;
129 129
130 if (NULL == hello_cache) 130 if (NULL == cache)
131 return; 131 return;
132 entry = GNUNET_CONTAINER_multihashmap_get (hello_cache, &id->hashPubKey); 132 entry = GNUNET_CONTAINER_multihashmap_get (cache, &id->hashPubKey);
133 if (NULL == entry) 133 if (NULL == entry)
134 { 134 {
135 entry = GNUNET_malloc (sizeof (struct HelloCacheEntry)); 135 entry = GNUNET_malloc (sizeof (struct CacheEntry));
136 memcpy (&entry->key, &id->hashPubKey, sizeof (struct GNUNET_HashCode)); 136 memcpy (&entry->key, &id->hashPubKey, sizeof (struct GNUNET_HashCode));
137 if (GNUNET_CONTAINER_multihashmap_size (hello_cache) == hello_cache_size) 137 if (GNUNET_CONTAINER_multihashmap_size (cache) == cache_size)
138 { 138 {
139 GNUNET_assert (NULL != lru_hcache_head); 139 GNUNET_assert (NULL != lru_hcache_head);
140 GST_hello_cache_remove (lru_hcache_head); 140 GST_cache_remove (lru_hcache_head);
141 } 141 }
142 GNUNET_assert (GNUNET_OK == 142 GNUNET_assert (GNUNET_OK ==
143 GNUNET_CONTAINER_multihashmap_put (hello_cache, &entry->key, 143 GNUNET_CONTAINER_multihashmap_put (cache, &entry->key,
144 entry, 144 entry,
145 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); 145 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
146 } 146 }
@@ -164,10 +164,10 @@ GST_cache_init (unsigned int size)
164{ 164{
165 if (0 == size) 165 if (0 == size)
166 return; 166 return;
167 hello_cache_size = size; 167 cache_size = size;
168 if (size > 1) 168 if (size > 1)
169 size = size / 2; 169 size = size / 2;
170 hello_cache = GNUNET_CONTAINER_multihashmap_create (size, GNUNET_YES); 170 cache = GNUNET_CONTAINER_multihashmap_create (size, GNUNET_YES);
171} 171}
172 172
173 173
@@ -177,15 +177,15 @@ GST_cache_init (unsigned int size)
177void 177void
178GST_cache_clear () 178GST_cache_clear ()
179{ 179{
180 if (NULL != hello_cache) 180 if (NULL != cache)
181 GNUNET_assert (GNUNET_CONTAINER_multihashmap_size (hello_cache) <= 181 GNUNET_assert (GNUNET_CONTAINER_multihashmap_size (cache) <=
182 hello_cache_size); 182 cache_size);
183 while (NULL != lru_hcache_head) 183 while (NULL != lru_hcache_head)
184 GST_hello_cache_remove (lru_hcache_head); 184 GST_cache_remove (lru_hcache_head);
185 if (NULL != hello_cache) 185 if (NULL != cache)
186 { 186 {
187 GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (hello_cache)); 187 GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (cache));
188 GNUNET_CONTAINER_multihashmap_destroy (hello_cache); 188 GNUNET_CONTAINER_multihashmap_destroy (cache);
189 } 189 }
190} 190}
191 191
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index eb49ff992..ccfdf162d 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -792,7 +792,7 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello)
792 LOG_DEBUG ("0x%llx: Received HELLO of %s\n", occ->op_id, 792 LOG_DEBUG ("0x%llx: Received HELLO of %s\n", occ->op_id,
793 GNUNET_i2s (&occ->peer_identity)); 793 GNUNET_i2s (&occ->peer_identity));
794 occ->hello = GNUNET_malloc (msize); 794 occ->hello = GNUNET_malloc (msize);
795 GST_hello_cache_add (&occ->peer_identity, hello); 795 GST_cache_add (&occ->peer_identity, hello);
796 memcpy (occ->hello, hello, msize); 796 memcpy (occ->hello, hello, msize);
797 GNUNET_TRANSPORT_get_hello_cancel (occ->ghh); 797 GNUNET_TRANSPORT_get_hello_cancel (occ->ghh);
798 occ->ghh = NULL; 798 occ->ghh = NULL;
@@ -837,7 +837,7 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server,
837 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", occ->op_id, 837 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", occ->op_id,
838 GNUNET_i2s (&occ->peer_identity)); 838 GNUNET_i2s (&occ->peer_identity));
839 /* Lookup for HELLO in hello cache */ 839 /* Lookup for HELLO in hello cache */
840 if (NULL != (hello = GST_hello_cache_lookup (&occ->peer_identity))) 840 if (NULL != (hello = GST_cache_lookup (&occ->peer_identity)))
841 { 841 {
842 LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n", occ->op_id, 842 LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n", occ->op_id,
843 GNUNET_i2s (&occ->peer_identity)); 843 GNUNET_i2s (&occ->peer_identity));
diff --git a/src/testbed/testbed.conf.in b/src/testbed/testbed.conf.in
index 38d6e5857..ec05c769b 100644
--- a/src/testbed/testbed.conf.in
+++ b/src/testbed/testbed.conf.in
@@ -14,5 +14,5 @@ UNIX_MATCH_GID = YES
14MAX_PARALLEL_OPERATIONS = 1000 14MAX_PARALLEL_OPERATIONS = 1000
15MAX_PARALLEL_SERVICE_CONNECTIONS = 256 15MAX_PARALLEL_SERVICE_CONNECTIONS = 256
16MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 1 16MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 1
17HELLO_CACHE_SIZE = 30 17CACHE_SIZE = 30
18MAX_OPEN_FDS = 512 18MAX_OPEN_FDS = 512