aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-14 11:20:29 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-14 11:20:29 +0000
commitcced1cd7e8a319105177e29cc4f1720739e307bb (patch)
treefd712679c47946af449f03bf3684cc3bfa31388a
parent5e6ff76c94890e47b51f8bd555437c0ee181e851 (diff)
downloadgnunet-cced1cd7e8a319105177e29cc4f1720739e307bb.tar.gz
gnunet-cced1cd7e8a319105177e29cc4f1720739e307bb.zip
fixes
-rw-r--r--src/fs/Makefile.am1
-rw-r--r--src/fs/fs_namespace.c33
-rw-r--r--src/fs/fs_publish.c25
-rw-r--r--src/fs/gnunet-service-fs.c88
-rw-r--r--src/fs/gnunet-service-fs_drq.c10
-rw-r--r--src/fs/gnunet-service-fs_indexing.c53
-rw-r--r--src/fs/gnunet-service-fs_indexing.h4
7 files changed, 141 insertions, 73 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index 9c9fd7525..6c850a91d 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -94,7 +94,6 @@ gnunet_search_LDADD = \
94 94
95gnunet_service_fs_SOURCES = \ 95gnunet_service_fs_SOURCES = \
96 gnunet-service-fs.c \ 96 gnunet-service-fs.c \
97 gnunet-service-fs_drq.c gnunet-service-fs_drq.h \
98 gnunet-service-fs_indexing.c gnunet-service-fs_indexing.h 97 gnunet-service-fs_indexing.c gnunet-service-fs_indexing.h
99gnunet_service_fs_LDADD = \ 98gnunet_service_fs_LDADD = \
100 $(top_builddir)/src/fs/libgnunetfs.la \ 99 $(top_builddir)/src/fs/libgnunetfs.la \
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c
index 9e198adc2..e8b97bb19 100644
--- a/src/fs/fs_namespace.c
+++ b/src/fs/fs_namespace.c
@@ -79,6 +79,11 @@ struct AdvertisementContext
79 struct GNUNET_DATASTORE_Handle *dsh; 79 struct GNUNET_DATASTORE_Handle *dsh;
80 80
81 /** 81 /**
82 * Our scheduler.
83 */
84 struct GNUNET_SCHEDULER_Handle *sched;
85
86 /**
82 * Our KSK URI. 87 * Our KSK URI.
83 */ 88 */
84 struct GNUNET_FS_Uri *ksk_uri; 89 struct GNUNET_FS_Uri *ksk_uri;
@@ -126,6 +131,23 @@ struct AdvertisementContext
126 131
127 132
128/** 133/**
134 * Disconnect from the datastore.
135 *
136 * @param cls datastore handle
137 * @param tc scheduler context
138 */
139static void
140do_disconnect (void *cls,
141 const struct GNUNET_SCHEDULER_TaskContext *tc)
142{
143 struct GNUNET_DATASTORE_Handle *dsh = cls;
144
145 GNUNET_DATASTORE_disconnect (dsh,
146 GNUNET_NO);
147}
148
149
150/**
129 * Continuation called to notify client about result of the 151 * Continuation called to notify client about result of the
130 * operation. 152 * operation.
131 * 153 *
@@ -149,7 +171,10 @@ advertisement_cont (void *cls,
149 if (GNUNET_OK != success) 171 if (GNUNET_OK != success)
150 { 172 {
151 /* error! */ 173 /* error! */
152 GNUNET_DATASTORE_disconnect (ac->dsh, GNUNET_NO); 174 GNUNET_SCHEDULER_add_continuation (ac->sched,
175 &do_disconnect,
176 ac->dsh,
177 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
153 ac->cont (ac->cont_cls, NULL, msg); 178 ac->cont (ac->cont_cls, NULL, msg);
154 GNUNET_FS_uri_destroy (ac->ksk_uri); 179 GNUNET_FS_uri_destroy (ac->ksk_uri);
155 GNUNET_free (ac->pt); 180 GNUNET_free (ac->pt);
@@ -161,7 +186,10 @@ advertisement_cont (void *cls,
161 if (ac->pos == ac->ksk_uri->data.ksk.keywordCount) 186 if (ac->pos == ac->ksk_uri->data.ksk.keywordCount)
162 { 187 {
163 /* done! */ 188 /* done! */
164 GNUNET_DATASTORE_disconnect (ac->dsh, GNUNET_NO); 189 GNUNET_SCHEDULER_add_continuation (ac->sched,
190 &do_disconnect,
191 ac->dsh,
192 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
165 ac->cont (ac->cont_cls, ac->ksk_uri, NULL); 193 ac->cont (ac->cont_cls, ac->ksk_uri, NULL);
166 GNUNET_FS_uri_destroy (ac->ksk_uri); 194 GNUNET_FS_uri_destroy (ac->ksk_uri);
167 GNUNET_free (ac->pt); 195 GNUNET_free (ac->pt);
@@ -296,6 +324,7 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h,
296 ctx->cont = cont; 324 ctx->cont = cont;
297 ctx->cont_cls = cont_cls; 325 ctx->cont_cls = cont_cls;
298 ctx->dsh = dsh; 326 ctx->dsh = dsh;
327 ctx->sched = h->sched;
299 ctx->ksk_uri = GNUNET_FS_uri_dup (ksk_uri); 328 ctx->ksk_uri = GNUNET_FS_uri_dup (ksk_uri);
300 ctx->nb = nb; 329 ctx->nb = nb;
301 ctx->pt = pt; 330 ctx->pt = pt;
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index aa7f794be..4e2039ba0 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -109,11 +109,14 @@ GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
109/** 109/**
110 * Cleanup the publish context, we're done with it. 110 * Cleanup the publish context, we're done with it.
111 * 111 *
112 * @param pc struct to clean up after 112 * @param cls struct to clean up after
113 * @param tc scheduler context
113 */ 114 */
114static void 115static void
115publish_cleanup (struct GNUNET_FS_PublishContext *pc) 116publish_cleanup (void *cls,
117 const struct GNUNET_SCHEDULER_TaskContext *tc)
116{ 118{
119 struct GNUNET_FS_PublishContext *pc = cls;
117 GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL); 120 GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL);
118 if (pc->namespace != NULL) 121 if (pc->namespace != NULL)
119 GNUNET_FS_namespace_delete (pc->namespace, GNUNET_NO); 122 GNUNET_FS_namespace_delete (pc->namespace, GNUNET_NO);
@@ -146,9 +149,11 @@ ds_put_cont (void *cls,
146 149
147 if (GNUNET_SYSERR == pcc->sc->in_network_wait) 150 if (GNUNET_SYSERR == pcc->sc->in_network_wait)
148 { 151 {
149 /* we were aborted in the meantime, 152 /* we were aborted in the meantime, finish shutdown! */
150 finish shutdown! */ 153 GNUNET_SCHEDULER_add_continuation (pcc->sc->h->sched,
151 publish_cleanup (pcc->sc); 154 &publish_cleanup,
155 pcc->sc,
156 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
152 GNUNET_free (pcc); 157 GNUNET_free (pcc);
153 return; 158 return;
154 } 159 }
@@ -1016,7 +1021,10 @@ GNUNET_FS_publish_signal_suspend_ (void *cls)
1016 &fip_signal_suspend, 1021 &fip_signal_suspend,
1017 pc); 1022 pc);
1018 GNUNET_FS_end_top (pc->h, pc->top); 1023 GNUNET_FS_end_top (pc->h, pc->top);
1019 publish_cleanup (pc); 1024 GNUNET_SCHEDULER_add_continuation (pc->h->sched,
1025 &publish_cleanup,
1026 pc,
1027 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1020} 1028}
1021 1029
1022/** 1030/**
@@ -1163,7 +1171,10 @@ GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc)
1163 pc->in_network_wait = GNUNET_SYSERR; 1171 pc->in_network_wait = GNUNET_SYSERR;
1164 return; 1172 return;
1165 } 1173 }
1166 publish_cleanup (pc); 1174 GNUNET_SCHEDULER_add_continuation (pc->h->sched,
1175 &publish_cleanup,
1176 pc,
1177 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1167} 1178}
1168 1179
1169 1180
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 7e88f9d4e..e85d99cfd 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -43,7 +43,6 @@
43#include "gnunet_signatures.h" 43#include "gnunet_signatures.h"
44#include "gnunet_statistics_service.h" 44#include "gnunet_statistics_service.h"
45#include "gnunet_util_lib.h" 45#include "gnunet_util_lib.h"
46#include "gnunet-service-fs_drq.h"
47#include "gnunet-service-fs_indexing.h" 46#include "gnunet-service-fs_indexing.h"
48#include "fs.h" 47#include "fs.h"
49 48
@@ -89,6 +88,11 @@ static uint64_t max_pending_requests = (32 * 1024);
89 */ 88 */
90struct PendingMessage; 89struct PendingMessage;
91 90
91/**
92 * Our connection to the datastore.
93 */
94static struct GNUNET_DATASTORE_Handle *dsh;
95
92 96
93/** 97/**
94 * Function called upon completion of a transmission. 98 * Function called upon completion of a transmission.
@@ -472,10 +476,10 @@ struct PendingRequest
472 GNUNET_PEER_Id *used_pids; 476 GNUNET_PEER_Id *used_pids;
473 477
474 /** 478 /**
475 * Our entry in the DRQ (non-NULL while we wait for our 479 * Our entry in the queue (non-NULL while we wait for our
476 * turn to interact with the local database). 480 * turn to interact with the local database).
477 */ 481 */
478 struct DatastoreRequestQueue *drq; 482 struct GNUNET_DATASTORE_QueueEntry *qe;
479 483
480 /** 484 /**
481 * Size of the 'bf' (in bytes). 485 * Size of the 'bf' (in bytes).
@@ -696,10 +700,10 @@ destroy_pending_request (struct PendingRequest *pr)
696 (void) GNUNET_CONTAINER_multihashmap_remove (query_request_map, 700 (void) GNUNET_CONTAINER_multihashmap_remove (query_request_map,
697 &pr->query, 701 &pr->query,
698 pr); 702 pr);
699 if (pr->drq != NULL) 703 if (pr->qe != NULL)
700 { 704 {
701 GNUNET_FS_drq_get_cancel (pr->drq); 705 GNUNET_DATASTORE_cancel (pr->qe);
702 pr->drq = NULL; 706 pr->qe = NULL;
703 } 707 }
704 if (pr->client_request_list != NULL) 708 if (pr->client_request_list != NULL)
705 { 709 {
@@ -995,6 +999,9 @@ shutdown_task (void *cls,
995 GNUNET_STATISTICS_destroy (stats, GNUNET_NO); 999 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
996 stats = NULL; 1000 stats = NULL;
997 } 1001 }
1002 GNUNET_DATASTORE_disconnect (dsh,
1003 GNUNET_NO);
1004 dsh = NULL;
998 sched = NULL; 1005 sched = NULL;
999 cfg = NULL; 1006 cfg = NULL;
1000} 1007}
@@ -1852,13 +1859,13 @@ process_reply (void *cls,
1852 /* only possible reply, stop requesting! */ 1859 /* only possible reply, stop requesting! */
1853 while (NULL != pr->pending_head) 1860 while (NULL != pr->pending_head)
1854 destroy_pending_message_list_entry (pr->pending_head); 1861 destroy_pending_message_list_entry (pr->pending_head);
1855 if (pr->drq != NULL) 1862 if (pr->qe != NULL)
1856 { 1863 {
1857 if (pr->client_request_list != NULL) 1864 if (pr->client_request_list != NULL)
1858 GNUNET_SERVER_receive_done (pr->client_request_list->client_list->client, 1865 GNUNET_SERVER_receive_done (pr->client_request_list->client_list->client,
1859 GNUNET_YES); 1866 GNUNET_YES);
1860 GNUNET_FS_drq_get_cancel (pr->drq); 1867 GNUNET_DATASTORE_cancel (pr->qe);
1861 pr->drq = NULL; 1868 pr->qe = NULL;
1862 } 1869 }
1863 pr->do_remove = GNUNET_YES; 1870 pr->do_remove = GNUNET_YES;
1864 if (pr->task != GNUNET_SCHEDULER_NO_TASK) 1871 if (pr->task != GNUNET_SCHEDULER_NO_TASK)
@@ -2209,7 +2216,7 @@ process_local_reply (void *cls,
2209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2216 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2210 "Done processing local replies, forwarding request to other peers.\n"); 2217 "Done processing local replies, forwarding request to other peers.\n");
2211#endif 2218#endif
2212 pr->drq = NULL; 2219 pr->qe = NULL;
2213 if (pr->client_request_list != NULL) 2220 if (pr->client_request_list != NULL)
2214 { 2221 {
2215 GNUNET_SERVER_receive_done (pr->client_request_list->client_list->client, 2222 GNUNET_SERVER_receive_done (pr->client_request_list->client_list->client,
@@ -2263,7 +2270,7 @@ process_local_reply (void *cls,
2263 anonymity, expiration, uid, 2270 anonymity, expiration, uid,
2264 &process_local_reply, 2271 &process_local_reply,
2265 pr)) 2272 pr))
2266 GNUNET_FS_drq_get_next (GNUNET_YES); 2273 GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
2267 return; 2274 return;
2268 } 2275 }
2269 /* check for duplicates */ 2276 /* check for duplicates */
@@ -2284,7 +2291,7 @@ process_local_reply (void *cls,
2284 gettext_noop ("# results filtered by query bloomfilter"), 2291 gettext_noop ("# results filtered by query bloomfilter"),
2285 1, 2292 1,
2286 GNUNET_NO); 2293 GNUNET_NO);
2287 GNUNET_FS_drq_get_next (GNUNET_YES); 2294 GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
2288 return; 2295 return;
2289 } 2296 }
2290#if DEBUG_FS 2297#if DEBUG_FS
@@ -2315,7 +2322,7 @@ process_local_reply (void *cls,
2315 { 2322 {
2316 GNUNET_break (0); 2323 GNUNET_break (0);
2317 /* FIXME: consider removing the block? */ 2324 /* FIXME: consider removing the block? */
2318 GNUNET_FS_drq_get_next (GNUNET_YES); 2325 GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
2319 return; 2326 return;
2320 } 2327 }
2321 prq.type = type; 2328 prq.type = type;
@@ -2325,7 +2332,7 @@ process_local_reply (void *cls,
2325 if ( (type == GNUNET_BLOCK_TYPE_DBLOCK) || 2332 if ( (type == GNUNET_BLOCK_TYPE_DBLOCK) ||
2326 (type == GNUNET_BLOCK_TYPE_IBLOCK) ) 2333 (type == GNUNET_BLOCK_TYPE_IBLOCK) )
2327 { 2334 {
2328 GNUNET_FS_drq_get_next (GNUNET_NO); 2335 GNUNET_DATASTORE_get_next (dsh, GNUNET_NO);
2329 return; 2336 return;
2330 } 2337 }
2331 if ( (pr->client_request_list == NULL) && 2338 if ( (pr->client_request_list == NULL) &&
@@ -2340,10 +2347,10 @@ process_local_reply (void *cls,
2340 gettext_noop ("# processing result set cut short due to load"), 2347 gettext_noop ("# processing result set cut short due to load"),
2341 1, 2348 1,
2342 GNUNET_NO); 2349 GNUNET_NO);
2343 GNUNET_FS_drq_get_next (GNUNET_NO); 2350 GNUNET_DATASTORE_get_next (dsh, GNUNET_NO);
2344 return; 2351 return;
2345 } 2352 }
2346 GNUNET_FS_drq_get_next (GNUNET_YES); 2353 GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
2347} 2354}
2348 2355
2349 2356
@@ -2656,12 +2663,14 @@ handle_p2p_get (void *cls,
2656 type = GNUNET_BLOCK_TYPE_ANY; /* to get on-demand as well */ 2663 type = GNUNET_BLOCK_TYPE_ANY; /* to get on-demand as well */
2657 timeout = GNUNET_TIME_relative_multiply (BASIC_DATASTORE_REQUEST_DELAY, 2664 timeout = GNUNET_TIME_relative_multiply (BASIC_DATASTORE_REQUEST_DELAY,
2658 (pr->priority + 1)); 2665 (pr->priority + 1));
2659 pr->drq = GNUNET_FS_drq_get (&gm->query, 2666 pr->qe = GNUNET_DATASTORE_get (dsh,
2660 type, 2667 &gm->query,
2661 &process_local_reply, 2668 type,
2662 pr, 2669 (unsigned int) preference, 64 /* FIXME */,
2663 timeout, 2670
2664 GNUNET_NO); 2671 timeout,
2672 &process_local_reply,
2673 pr);
2665 2674
2666 /* Are multiple results possible? If so, start processing remotely now! */ 2675 /* Are multiple results possible? If so, start processing remotely now! */
2667 switch (pr->type) 2676 switch (pr->type)
@@ -2852,12 +2861,13 @@ handle_start_search (void *cls,
2852 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); 2861 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
2853 if (type == GNUNET_BLOCK_TYPE_DBLOCK) 2862 if (type == GNUNET_BLOCK_TYPE_DBLOCK)
2854 type = GNUNET_BLOCK_TYPE_ANY; /* get on-demand blocks too! */ 2863 type = GNUNET_BLOCK_TYPE_ANY; /* get on-demand blocks too! */
2855 pr->drq = GNUNET_FS_drq_get (&sm->query, 2864 pr->qe = GNUNET_DATASTORE_get (dsh,
2856 type, 2865 &sm->query,
2857 &process_local_reply, 2866 type,
2858 pr, 2867 -3, -1,
2859 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 2868 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
2860 GNUNET_YES); 2869 &process_local_reply,
2870 pr);
2861} 2871}
2862 2872
2863 2873
@@ -2937,9 +2947,13 @@ main_init (struct GNUNET_SCHEDULER_Handle *s,
2937 requests_by_expiration_heap = NULL; 2947 requests_by_expiration_heap = NULL;
2938 GNUNET_CONTAINER_multihashmap_destroy (peer_request_map); 2948 GNUNET_CONTAINER_multihashmap_destroy (peer_request_map);
2939 peer_request_map = NULL; 2949 peer_request_map = NULL;
2940 2950 if (dsh != NULL)
2951 {
2952 GNUNET_DATASTORE_disconnect (dsh, GNUNET_NO);
2953 dsh = NULL;
2954 }
2941 return GNUNET_SYSERR; 2955 return GNUNET_SYSERR;
2942 } 2956 }
2943 GNUNET_SERVER_disconnect_notify (server, 2957 GNUNET_SERVER_disconnect_notify (server,
2944 &handle_client_disconnect, 2958 &handle_client_disconnect,
2945 NULL); 2959 NULL);
@@ -2969,11 +2983,19 @@ run (void *cls,
2969 active_migration = GNUNET_CONFIGURATION_get_value_yesno (cfg, 2983 active_migration = GNUNET_CONFIGURATION_get_value_yesno (cfg,
2970 "FS", 2984 "FS",
2971 "ACTIVEMIGRATION"); 2985 "ACTIVEMIGRATION");
2972 if ( (GNUNET_OK != GNUNET_FS_drq_init (sched, cfg)) || 2986 dsh = GNUNET_DATASTORE_connect (cfg,
2973 (GNUNET_OK != GNUNET_FS_indexing_init (sched, cfg)) || 2987 sched);
2988 if (dsh == NULL)
2989 {
2990 GNUNET_SCHEDULER_shutdown (sched);
2991 return;
2992 }
2993 if ( (GNUNET_OK != GNUNET_FS_indexing_init (sched, cfg, dsh)) ||
2974 (GNUNET_OK != main_init (sched, server, cfg)) ) 2994 (GNUNET_OK != main_init (sched, server, cfg)) )
2975 { 2995 {
2976 GNUNET_SCHEDULER_shutdown (sched); 2996 GNUNET_SCHEDULER_shutdown (sched);
2997 GNUNET_DATASTORE_disconnect (dsh, GNUNET_NO);
2998 dsh = NULL;
2977 return; 2999 return;
2978 } 3000 }
2979} 3001}
diff --git a/src/fs/gnunet-service-fs_drq.c b/src/fs/gnunet-service-fs_drq.c
index ab6c9ad21..b549c6707 100644
--- a/src/fs/gnunet-service-fs_drq.c
+++ b/src/fs/gnunet-service-fs_drq.c
@@ -113,10 +113,6 @@ static struct DatastoreRequestQueue *drq_head;
113 */ 113 */
114static struct DatastoreRequestQueue *drq_tail; 114static struct DatastoreRequestQueue *drq_tail;
115 115
116/**
117 * Our connection to the datastore.
118 */
119static struct GNUNET_DATASTORE_Handle *dsh;
120 116
121/** 117/**
122 * Pointer to the currently actively running request, 118 * Pointer to the currently actively running request,
@@ -295,9 +291,6 @@ shutdown_task (void *cls,
295 "DRQ shutdown initiated\n"); 291 "DRQ shutdown initiated\n");
296#endif 292#endif
297 GNUNET_assert (NULL != dsh); 293 GNUNET_assert (NULL != dsh);
298 GNUNET_DATASTORE_disconnect (dsh,
299 GNUNET_NO);
300 dsh = NULL;
301 while (NULL != (drq = drq_head)) 294 while (NULL != (drq = drq_head))
302 { 295 {
303 drq_head = drq->next; 296 drq_head = drq->next;
@@ -465,7 +458,6 @@ drq_remove_cont (void *cls,
465 rc->cont (rc->cont_cls, 458 rc->cont (rc->cont_cls,
466 success, 459 success,
467 msg); 460 msg);
468 GNUNET_DATASTORE_disconnect (rc->rmdsh, GNUNET_NO);
469 GNUNET_free (rc); 461 GNUNET_free (rc);
470} 462}
471 463
@@ -494,8 +486,6 @@ GNUNET_FS_drq_remove (const GNUNET_HashCode *key,
494 struct GNUNET_DATASTORE_Handle *rmdsh; 486 struct GNUNET_DATASTORE_Handle *rmdsh;
495 struct RemoveContext *rc; 487 struct RemoveContext *rc;
496 488
497 rmdsh = GNUNET_DATASTORE_connect (cfg,
498 sched);
499 if (rmdsh == NULL) 489 if (rmdsh == NULL)
500 { 490 {
501 GNUNET_break (0); 491 GNUNET_break (0);
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c
index f8593ffd4..363bdea41 100644
--- a/src/fs/gnunet-service-fs_indexing.c
+++ b/src/fs/gnunet-service-fs_indexing.c
@@ -101,6 +101,12 @@ static struct GNUNET_SCHEDULER_Handle *sched;
101 */ 101 */
102static const struct GNUNET_CONFIGURATION_Handle *cfg; 102static const struct GNUNET_CONFIGURATION_Handle *cfg;
103 103
104/**
105 * Datastore handle. Created and destroyed by code in
106 * gnunet-service-fs (this is an alias).
107 */
108static struct GNUNET_DATASTORE_Handle *dsh;
109
104 110
105/** 111/**
106 * Write the current index information list to disk. 112 * Write the current index information list to disk.
@@ -575,12 +581,14 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
575 if (size != sizeof (struct OnDemandBlock)) 581 if (size != sizeof (struct OnDemandBlock))
576 { 582 {
577 GNUNET_break (0); 583 GNUNET_break (0);
578 GNUNET_FS_drq_remove (key, 584 GNUNET_DATASTORE_remove (dsh,
579 size, 585 key,
580 data, 586 size,
581 &remove_cont, 587 data,
582 NULL, 588 -1, -1,
583 GNUNET_TIME_UNIT_FOREVER_REL); 589 GNUNET_TIME_UNIT_FOREVER_REL,
590 &remove_cont,
591 NULL);
584 return GNUNET_SYSERR; 592 return GNUNET_SYSERR;
585 } 593 }
586 odb = (const struct OnDemandBlock*) data; 594 odb = (const struct OnDemandBlock*) data;
@@ -608,12 +616,14 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
608 STRERROR (errno)); 616 STRERROR (errno));
609 if (fh != NULL) 617 if (fh != NULL)
610 GNUNET_DISK_file_close (fh); 618 GNUNET_DISK_file_close (fh);
611 GNUNET_FS_drq_remove (key, 619 GNUNET_DATASTORE_remove (dsh,
612 size, 620 key,
613 data, 621 size,
614 &remove_cont, 622 data,
615 NULL, 623 -1, -1,
616 GNUNET_TIME_UNIT_FOREVER_REL); 624 GNUNET_TIME_UNIT_FOREVER_REL,
625 &remove_cont,
626 NULL);
617 return GNUNET_SYSERR; 627 return GNUNET_SYSERR;
618 } 628 }
619 GNUNET_DISK_file_close (fh); 629 GNUNET_DISK_file_close (fh);
@@ -637,12 +647,14 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
637 _("Indexed file `%s' changed at offset %llu\n"), 647 _("Indexed file `%s' changed at offset %llu\n"),
638 fn, 648 fn,
639 (unsigned long long) off); 649 (unsigned long long) off);
640 GNUNET_FS_drq_remove (key, 650 GNUNET_DATASTORE_remove (dsh,
641 size, 651 key,
642 data, 652 size,
643 &remove_cont, 653 data,
644 NULL, 654 -1, -1,
645 GNUNET_TIME_UNIT_FOREVER_REL); 655 GNUNET_TIME_UNIT_FOREVER_REL,
656 &remove_cont,
657 NULL);
646 return GNUNET_SYSERR; 658 return GNUNET_SYSERR;
647 } 659 }
648#if DEBUG_FS 660#if DEBUG_FS
@@ -692,13 +704,16 @@ shutdown_task (void *cls,
692 * 704 *
693 * @param s scheduler to use 705 * @param s scheduler to use
694 * @param c configuration to use 706 * @param c configuration to use
707 * @param d datastore to use
695 */ 708 */
696int 709int
697GNUNET_FS_indexing_init (struct GNUNET_SCHEDULER_Handle *s, 710GNUNET_FS_indexing_init (struct GNUNET_SCHEDULER_Handle *s,
698 const struct GNUNET_CONFIGURATION_Handle *c) 711 const struct GNUNET_CONFIGURATION_Handle *c,
712 struct GNUNET_DATASTORE_Handle *d)
699{ 713{
700 sched = s; 714 sched = s;
701 cfg = c; 715 cfg = c;
716 dsh = d;
702 ifm = GNUNET_CONTAINER_multihashmap_create (128); 717 ifm = GNUNET_CONTAINER_multihashmap_create (128);
703 GNUNET_SCHEDULER_add_delayed (sched, 718 GNUNET_SCHEDULER_add_delayed (sched,
704 GNUNET_TIME_UNIT_FOREVER_REL, 719 GNUNET_TIME_UNIT_FOREVER_REL,
diff --git a/src/fs/gnunet-service-fs_indexing.h b/src/fs/gnunet-service-fs_indexing.h
index 37df50042..489e9d3f9 100644
--- a/src/fs/gnunet-service-fs_indexing.h
+++ b/src/fs/gnunet-service-fs_indexing.h
@@ -112,11 +112,13 @@ GNUNET_FS_handle_unindex (void *cls,
112 * 112 *
113 * @param s scheduler to use 113 * @param s scheduler to use
114 * @param c configuration to use 114 * @param c configuration to use
115 * @param d datastore to use
115 * @return GNUNET_OK on success 116 * @return GNUNET_OK on success
116 */ 117 */
117int 118int
118GNUNET_FS_indexing_init (struct GNUNET_SCHEDULER_Handle *s, 119GNUNET_FS_indexing_init (struct GNUNET_SCHEDULER_Handle *s,
119 const struct GNUNET_CONFIGURATION_Handle *c); 120 const struct GNUNET_CONFIGURATION_Handle *c,
121 struct GNUNET_DATASTORE_Handle *d);
120 122
121 123
122#endif 124#endif