aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-10-06 11:43:44 +0000
committerChristian Grothoff <christian@grothoff.org>2010-10-06 11:43:44 +0000
commit7d2cbe5bd19ec95ada5a28a0134185ef29007b69 (patch)
tree0b569eff422f963b4fe8d7af4242f5ad70a5658e /src/fs
parentf22fda6b2ff4be4ed54fe4fa903718eff9e18786 (diff)
downloadgnunet-7d2cbe5bd19ec95ada5a28a0134185ef29007b69.tar.gz
gnunet-7d2cbe5bd19ec95ada5a28a0134185ef29007b69.zip
dht get integration
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs_publish.c2
-rw-r--r--src/fs/gnunet-service-fs.c96
2 files changed, 87 insertions, 11 deletions
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 6262dc604..ad2258b16 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -569,7 +569,7 @@ block_proc (void *cls,
569 GNUNET_DATASTORE_put (sc->dsh, 569 GNUNET_DATASTORE_put (sc->dsh,
570 (p->is_directory) ? 0 : sc->rid, 570 (p->is_directory) ? 0 : sc->rid,
571 query, 571 query,
572 sizeof(struct OnDemandBlock), 572 sizeof (struct OnDemandBlock),
573 &odb, 573 &odb,
574 GNUNET_BLOCK_TYPE_FS_ONDEMAND, 574 GNUNET_BLOCK_TYPE_FS_ONDEMAND,
575 p->priority, 575 p->priority,
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 2bfdeb674..610c6e6dd 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -445,6 +445,11 @@ struct PendingRequest
445 struct GNUNET_CORE_InformationRequestContext *irc; 445 struct GNUNET_CORE_InformationRequestContext *irc;
446 446
447 /** 447 /**
448 * Reference to DHT get operation for this request (or NULL).
449 */
450 struct GNUNET_DHT_GetHandle *dht_get;
451
452 /**
448 * Hash code of all replies that we have seen so far (only valid 453 * Hash code of all replies that we have seen so far (only valid
449 * if client is not NULL since we only track replies like this for 454 * if client is not NULL since we only track replies like this for
450 * our own clients). 455 * our own clients).
@@ -1023,7 +1028,7 @@ consider_migration_gathering ()
1023static void 1028static void
1024process_migration_content (void *cls, 1029process_migration_content (void *cls,
1025 const GNUNET_HashCode * key, 1030 const GNUNET_HashCode * key,
1026 uint32_t size, 1031 size_t size,
1027 const void *data, 1032 const void *data,
1028 enum GNUNET_BLOCK_Type type, 1033 enum GNUNET_BLOCK_Type type,
1029 uint32_t priority, 1034 uint32_t priority,
@@ -1194,6 +1199,11 @@ destroy_pending_request (struct PendingRequest *pr)
1194 GNUNET_DATASTORE_cancel (pr->qe); 1199 GNUNET_DATASTORE_cancel (pr->qe);
1195 pr->qe = NULL; 1200 pr->qe = NULL;
1196 } 1201 }
1202 if (pr->dht_get != NULL)
1203 {
1204 GNUNET_DHT_get_stop (pr->dht_get);
1205 pr->dht_get = NULL;
1206 }
1197 if (pr->client_request_list != NULL) 1207 if (pr->client_request_list != NULL)
1198 { 1208 {
1199 GNUNET_CONTAINER_DLL_remove (pr->client_request_list->client_list->rl_head, 1209 GNUNET_CONTAINER_DLL_remove (pr->client_request_list->client_list->rl_head,
@@ -2338,6 +2348,32 @@ bound_ttl (int32_t ttl_in, uint32_t prio)
2338 2348
2339 2349
2340/** 2350/**
2351 * Iterator called on each result obtained for a DHT
2352 * operation that expects a reply
2353 *
2354 * @param cls closure
2355 * @param exp when will this value expire
2356 * @param key key of the result
2357 * @param get_path NULL-terminated array of pointers
2358 * to the peers on reverse GET path (or NULL if not recorded)
2359 * @param put_path NULL-terminated array of pointers
2360 * to the peers on the PUT path (or NULL if not recorded)
2361 * @param type type of the result
2362 * @param size number of bytes in data
2363 * @param data pointer to the result data
2364 */
2365static void
2366process_dht_reply (void *cls,
2367 struct GNUNET_TIME_Absolute exp,
2368 const GNUNET_HashCode * key,
2369 const struct GNUNET_PeerIdentity * const *get_path,
2370 const struct GNUNET_PeerIdentity * const *put_path,
2371 enum GNUNET_BLOCK_Type type,
2372 size_t size,
2373 const void *data);
2374
2375
2376/**
2341 * We're processing a GET request and have decided 2377 * We're processing a GET request and have decided
2342 * to forward it to other peers. This function is called periodically 2378 * to forward it to other peers. This function is called periodically
2343 * and should forward the request to other peers until we have all 2379 * and should forward the request to other peers until we have all
@@ -2371,19 +2407,21 @@ forward_request_task (void *cls,
2371 if (GNUNET_YES == pr->local_only) 2407 if (GNUNET_YES == pr->local_only)
2372 return; /* configured to not do P2P search */ 2408 return; /* configured to not do P2P search */
2373 /* (0) try DHT */ 2409 /* (0) try DHT */
2374 if (0 == pr->anonymity_level) 2410 if ( (0 == pr->anonymity_level) &&
2411 (pr->type != GNUNET_BLOCK_TYPE_FS_DBLOCK) &&
2412 (pr->type != GNUNET_BLOCK_TYPE_FS_IBLOCK) )
2375 { 2413 {
2376#if 0
2377 /* DHT API needs fixing... */
2378 pr->dht_get = GNUNET_DHT_get_start (dht_handle, 2414 pr->dht_get = GNUNET_DHT_get_start (dht_handle,
2379 GNUNET_TIME_UNIT_FOREVER_REL, 2415 GNUNET_TIME_UNIT_FOREVER_REL,
2380 pr->type, 2416 pr->type,
2381 &pr->query, 2417 &pr->query,
2418 GNUNET_DHT_RO_NONE,
2419 pr->bf,
2420 pr->mingle,
2421 pr->namespace,
2422 (pr->namespace != NULL) ? sizeof (GNUNET_HashCode) : 0,
2382 &process_dht_reply, 2423 &process_dht_reply,
2383 pr, 2424 pr);
2384 FIXME,
2385 FIXME);
2386#endif
2387 } 2425 }
2388 /* (1) select target */ 2426 /* (1) select target */
2389 psc.pr = pr; 2427 psc.pr = pr;
@@ -2549,7 +2587,7 @@ struct ProcessReplyClosure
2549 const void *data; 2587 const void *data;
2550 2588
2551 /** 2589 /**
2552 * Who gave us this reply? NULL for local host. 2590 * Who gave us this reply? NULL for local host (or DHT)
2553 */ 2591 */
2554 struct ConnectedPeer *sender; 2592 struct ConnectedPeer *sender;
2555 2593
@@ -2816,6 +2854,44 @@ process_reply (void *cls,
2816 2854
2817 2855
2818/** 2856/**
2857 * Iterator called on each result obtained for a DHT
2858 * operation that expects a reply
2859 *
2860 * @param cls closure
2861 * @param exp when will this value expire
2862 * @param key key of the result
2863 * @param get_path NULL-terminated array of pointers
2864 * to the peers on reverse GET path (or NULL if not recorded)
2865 * @param put_path NULL-terminated array of pointers
2866 * to the peers on the PUT path (or NULL if not recorded)
2867 * @param type type of the result
2868 * @param size number of bytes in data
2869 * @param data pointer to the result data
2870 */
2871static void
2872process_dht_reply (void *cls,
2873 struct GNUNET_TIME_Absolute exp,
2874 const GNUNET_HashCode * key,
2875 const struct GNUNET_PeerIdentity * const *get_path,
2876 const struct GNUNET_PeerIdentity * const *put_path,
2877 enum GNUNET_BLOCK_Type type,
2878 size_t size,
2879 const void *data)
2880{
2881 struct PendingRequest *pr = cls;
2882 struct ProcessReplyClosure prq;
2883
2884 memset (&prq, 0, sizeof (prq));
2885 prq.data = data;
2886 prq.expiration = exp;
2887 prq.size = size;
2888 prq.type = type;
2889 process_reply (&prq, key, pr);
2890}
2891
2892
2893
2894/**
2819 * Continuation called to notify client about result of the 2895 * Continuation called to notify client about result of the
2820 * operation. 2896 * operation.
2821 * 2897 *
@@ -3093,7 +3169,7 @@ check_duplicate_request_client (void *cls,
3093static void 3169static void
3094process_local_reply (void *cls, 3170process_local_reply (void *cls,
3095 const GNUNET_HashCode * key, 3171 const GNUNET_HashCode * key,
3096 uint32_t size, 3172 size_t size,
3097 const void *data, 3173 const void *data,
3098 enum GNUNET_BLOCK_Type type, 3174 enum GNUNET_BLOCK_Type type,
3099 uint32_t priority, 3175 uint32_t priority,