diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-05-14 13:45:34 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-05-14 13:45:34 +0000 |
commit | 6eb2fcd520b47ecb9e8f9f4fb090f4da0736eefa (patch) | |
tree | 9a835ba732525357563fa0ade31c5fa14b533081 /src/lockmanager | |
parent | 4b1be5f17f2f9132d3b6e44d0f438af49c51b090 (diff) | |
download | gnunet-6eb2fcd520b47ecb9e8f9f4fb090f4da0736eefa.tar.gz gnunet-6eb2fcd520b47ecb9e8f9f4fb090f4da0736eefa.zip |
-removed local function
Diffstat (limited to 'src/lockmanager')
-rw-r--r-- | src/lockmanager/gnunet-service-lockmanager.c | 71 | ||||
-rw-r--r-- | src/lockmanager/lockmanager_api.c | 10 |
2 files changed, 60 insertions, 21 deletions
diff --git a/src/lockmanager/gnunet-service-lockmanager.c b/src/lockmanager/gnunet-service-lockmanager.c index 974c14be1..18a5202a2 100644 --- a/src/lockmanager/gnunet-service-lockmanager.c +++ b/src/lockmanager/gnunet-service-lockmanager.c | |||
@@ -159,6 +159,28 @@ struct ClientList | |||
159 | 159 | ||
160 | 160 | ||
161 | /** | 161 | /** |
162 | * Structure for matching a lock | ||
163 | */ | ||
164 | struct LockMatch | ||
165 | { | ||
166 | /** | ||
167 | * The matched LockingRequest entry; Should be NULL if no entry is found | ||
168 | */ | ||
169 | struct Lock *matched_entry; | ||
170 | |||
171 | /** | ||
172 | * The locking domain name of the lock | ||
173 | */ | ||
174 | const char *domain_name; | ||
175 | |||
176 | /** | ||
177 | * The lock number | ||
178 | */ | ||
179 | uint32_t lock_num; | ||
180 | }; | ||
181 | |||
182 | |||
183 | /** | ||
162 | * Map of lock-keys to the 'struct LockList' entry for the key. | 184 | * Map of lock-keys to the 'struct LockList' entry for the key. |
163 | */ | 185 | */ |
164 | static struct GNUNET_CONTAINER_MultiHashMap *lock_map; | 186 | static struct GNUNET_CONTAINER_MultiHashMap *lock_map; |
@@ -197,6 +219,32 @@ get_key (const char *domain_name, | |||
197 | 219 | ||
198 | 220 | ||
199 | /** | 221 | /** |
222 | * Hashmap iterator for matching a lock | ||
223 | * | ||
224 | * @param cls the LockMatch structure | ||
225 | * @param key current key code | ||
226 | * @param value value in the hash map (struct Lock) | ||
227 | * @return GNUNET_YES if we should continue to | ||
228 | * iterate, | ||
229 | * GNUNET_NO if not. | ||
230 | */ | ||
231 | static int | ||
232 | match_iterator (void *cls, const GNUNET_HashCode *key, void *value) | ||
233 | { | ||
234 | struct LockMatch *match = cls; | ||
235 | struct Lock *lock = value; | ||
236 | |||
237 | if ( (match->lock_num == lock->lock_num) | ||
238 | && (0 == strcmp (match->domain_name, lock->domain_name)) ) | ||
239 | { | ||
240 | match->matched_entry = lock; | ||
241 | return GNUNET_NO; | ||
242 | } | ||
243 | return GNUNET_YES; | ||
244 | } | ||
245 | |||
246 | |||
247 | /** | ||
200 | * Function to search for a lock in the global lock hashmap | 248 | * Function to search for a lock in the global lock hashmap |
201 | * | 249 | * |
202 | * @param domain_name the name of the locking domain | 250 | * @param domain_name the name of the locking domain |
@@ -208,27 +256,18 @@ find_lock (const char *domain_name, | |||
208 | const uint32_t lock_num) | 256 | const uint32_t lock_num) |
209 | 257 | ||
210 | { | 258 | { |
211 | struct Lock *matched_lock; | 259 | struct LockMatch match; |
212 | struct GNUNET_HashCode key; | 260 | struct GNUNET_HashCode key; |
213 | 261 | ||
214 | matched_lock = NULL; | 262 | match.lock_num = lock_num; |
215 | int match_lock (void *cls, | 263 | match.domain_name = domain_name; |
216 | const GNUNET_HashCode *key, | 264 | match.matched_entry = NULL; |
217 | void *value) | ||
218 | { | ||
219 | matched_lock = value; | ||
220 | if ((lock_num == matched_lock->lock_num) | ||
221 | && (0 == strcmp (domain_name, matched_lock->domain_name))) | ||
222 | return GNUNET_NO; | ||
223 | matched_lock = NULL; | ||
224 | return GNUNET_YES; | ||
225 | } | ||
226 | get_key (domain_name, lock_num, &key); | 265 | get_key (domain_name, lock_num, &key); |
227 | GNUNET_CONTAINER_multihashmap_get_multiple (lock_map, | 266 | GNUNET_CONTAINER_multihashmap_get_multiple (lock_map, |
228 | &key, | 267 | &key, |
229 | &match_lock, | 268 | &match_iterator, |
230 | NULL); | 269 | &match); |
231 | return matched_lock; | 270 | return match.matched_entry; |
232 | } | 271 | } |
233 | 272 | ||
234 | 273 | ||
diff --git a/src/lockmanager/lockmanager_api.c b/src/lockmanager/lockmanager_api.c index 661064455..53f5365e4 100644 --- a/src/lockmanager/lockmanager_api.c +++ b/src/lockmanager/lockmanager_api.c | |||
@@ -104,7 +104,7 @@ struct GNUNET_LOCKMANAGER_LockingRequest | |||
104 | /** | 104 | /** |
105 | * Structure for matching a lock | 105 | * Structure for matching a lock |
106 | */ | 106 | */ |
107 | struct LockMatch | 107 | struct LockingRequestMatch |
108 | { | 108 | { |
109 | /** | 109 | /** |
110 | * The matched LockingRequest entry; Should be NULL if no entry is found | 110 | * The matched LockingRequest entry; Should be NULL if no entry is found |
@@ -146,9 +146,9 @@ get_key (const char *domain_name, | |||
146 | 146 | ||
147 | 147 | ||
148 | /** | 148 | /** |
149 | * Hashmap iterator for matching a lock | 149 | * Hashmap iterator for matching a LockingRequest |
150 | * | 150 | * |
151 | * @param cls the LockMatch structure | 151 | * @param cls the LockingRequestMatch structure |
152 | * @param key current key code | 152 | * @param key current key code |
153 | * @param value value in the hash map (struct GNUNET_LOCKMANAGER_LockingRequest) | 153 | * @param value value in the hash map (struct GNUNET_LOCKMANAGER_LockingRequest) |
154 | * @return GNUNET_YES if we should continue to | 154 | * @return GNUNET_YES if we should continue to |
@@ -158,7 +158,7 @@ get_key (const char *domain_name, | |||
158 | static int | 158 | static int |
159 | match_iterator (void *cls, const GNUNET_HashCode *key, void *value) | 159 | match_iterator (void *cls, const GNUNET_HashCode *key, void *value) |
160 | { | 160 | { |
161 | struct LockMatch *match = cls; | 161 | struct LockingRequestMatch *match = cls; |
162 | struct GNUNET_LOCKMANAGER_LockingRequest *lr = value; | 162 | struct GNUNET_LOCKMANAGER_LockingRequest *lr = value; |
163 | 163 | ||
164 | if ( (match->lock == lr->lock) && (0 == strcmp (match->domain, lr->domain)) ) | 164 | if ( (match->lock == lr->lock) && (0 == strcmp (match->domain, lr->domain)) ) |
@@ -186,7 +186,7 @@ hashmap_find_lockingrequest (const struct GNUNET_CONTAINER_MultiHashMap *map, | |||
186 | uint32_t lock) | 186 | uint32_t lock) |
187 | { | 187 | { |
188 | struct GNUNET_HashCode hash; | 188 | struct GNUNET_HashCode hash; |
189 | struct LockMatch lock_match; | 189 | struct LockingRequestMatch lock_match; |
190 | 190 | ||
191 | lock_match.matched_entry = NULL; | 191 | lock_match.matched_entry = NULL; |
192 | lock_match.domain = domain; | 192 | lock_match.domain = domain; |