aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-service-fs_pr.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-02-15 13:07:14 +0000
committerChristian Grothoff <christian@grothoff.org>2011-02-15 13:07:14 +0000
commite3d12cb6fa5ddfb181dcade2e06888619f384457 (patch)
treee06e3bee1b98f3d8b917a328085e27b1081f1398 /src/fs/gnunet-service-fs_pr.c
parent3294e6c66210cdcca65524593ce09bbf4db14c7f (diff)
downloadgnunet-e3d12cb6fa5ddfb181dcade2e06888619f384457.tar.gz
gnunet-e3d12cb6fa5ddfb181dcade2e06888619f384457.zip
stuff
Diffstat (limited to 'src/fs/gnunet-service-fs_pr.c')
-rw-r--r--src/fs/gnunet-service-fs_pr.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index 047c07587..d2248989f 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -182,10 +182,12 @@ refresh_bloomfilter (struct GSF_PendingRequest *pr)
182 * @param query key for the lookup 182 * @param query key for the lookup
183 * @param namespace namespace to lookup, NULL for no namespace 183 * @param namespace namespace to lookup, NULL for no namespace
184 * @param target preferred target for the request, NULL for none 184 * @param target preferred target for the request, NULL for none
185 * @param bf bloom filter for known replies, can be NULL 185 * @param bf_data raw data for bloom filter for known replies, can be NULL
186 * @param bf_size number of bytes in bf_data
186 * @param mingle mingle value for bf 187 * @param mingle mingle value for bf
187 * @param anonymity_level desired anonymity level 188 * @param anonymity_level desired anonymity level
188 * @param priority maximum outgoing cummulative request priority to use 189 * @param priority maximum outgoing cummulative request priority to use
190 * @param ttl current time-to-live for the request
189 * @param replies_seen hash codes of known local replies 191 * @param replies_seen hash codes of known local replies
190 * @param replies_seen_count size of the 'replies_seen' array 192 * @param replies_seen_count size of the 'replies_seen' array
191 * @param rh handle to call when we get a reply 193 * @param rh handle to call when we get a reply
@@ -198,10 +200,12 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
198 const GNUNET_HashCode *query, 200 const GNUNET_HashCode *query,
199 const GNUNET_HashCode *namespace, 201 const GNUNET_HashCode *namespace,
200 const struct GNUNET_PeerIdentity *target, 202 const struct GNUNET_PeerIdentity *target,
201 const struct GNUNET_CONTAINER_BloomFilter *bf, 203 const char *bf_data,
204 size_t bf_size,
202 int32_t mingle, 205 int32_t mingle,
203 uint32_t anonymity_level, 206 uint32_t anonymity_level,
204 uint32_t priority, 207 uint32_t priority,
208 int32_t ttl,
205 const GNUNET_HashCode *replies_seen, 209 const GNUNET_HashCode *replies_seen,
206 unsigned int replies_seen_count, 210 unsigned int replies_seen_count,
207 GSF_PendingRequestReplyHandler rh, 211 GSF_PendingRequestReplyHandler rh,
@@ -226,8 +230,16 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
226 pr->public_data.priority = priority; 230 pr->public_data.priority = priority;
227 pr->public_data.options = options; 231 pr->public_data.options = options;
228 pr->public_data.type = type; 232 pr->public_data.type = type;
233 pr->public_data.start_time = GNUNET_TIME_absolute_get ();
229 pr->rh = rh; 234 pr->rh = rh;
230 pr->rh_cls = rh_cls; 235 pr->rh_cls = rh_cls;
236 if (ttl >= 0)
237 pr->ttl = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
238 (uint32_t) ttl));
239 else
240 pr->ttl = GNUNET_TIME_absolute_subtract (pr->public_data.start_time,
241 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
242 (uint32_t) (- ttl)));
231 if (replies_seen_count > 0) 243 if (replies_seen_count > 0)
232 { 244 {
233 pr->replies_seen_size = replies_seen_count; 245 pr->replies_seen_size = replies_seen_count;
@@ -237,9 +249,11 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
237 replies_seen_count * sizeof (struct GNUNET_HashCode)); 249 replies_seen_count * sizeof (struct GNUNET_HashCode));
238 pr->replies_seen_count = replies_seen_count; 250 pr->replies_seen_count = replies_seen_count;
239 } 251 }
240 if (NULL != bf) 252 if (NULL != bf_data)
241 { 253 {
242 pr->bf = GNUNET_CONTAINER_bloomfilter_copy (bf); 254 pr->bf = GNUNET_CONTAINER_bloomfilter_init (bf_data,
255 bf_size,
256 BLOOMFILTER_K);
243 pr->mingle = mingle; 257 pr->mingle = mingle;
244 } 258 }
245 else if ( (replies_seen_count > 0) && 259 else if ( (replies_seen_count > 0) &&
@@ -254,11 +268,40 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
254 // FIXME: if not a local query, we also need to track the 268 // FIXME: if not a local query, we also need to track the
255 // total number of external queries we currently have and 269 // total number of external queries we currently have and
256 // bound it => need an additional heap! 270 // bound it => need an additional heap!
271
272 pr->hnode = GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap,
273 pr,
274 pr->start_time.abs_value + pr->ttl);
275
276
277
278 /* make sure we don't track too many requests */
279 if (GNUNET_CONTAINER_heap_get_size (requests_by_expiration_heap) > max_pending_requests)
280 {
281 pr = GNUNET_CONTAINER_heap_peek (requests_by_expiration_heap);
282 GNUNET_assert (pr != NULL);
283 destroy_pending_request (pr);
284 }
285
286
257 return pr; 287 return pr;
258} 288}
259 289
260 290
261/** 291/**
292 * Obtain the public data associated with a pending request
293 *
294 * @param pr pending request
295 * @return associated public data
296 */
297struct GSF_PendingRequestData *
298GSF_pending_request_get_data_ (struct GSF_PendingRequest *pr)
299{
300 return &pr->public_data;
301}
302
303
304/**
262 * Update a given pending request with additional replies 305 * Update a given pending request with additional replies
263 * that have been seen. 306 * that have been seen.
264 * 307 *