diff options
-rw-r--r-- | src/fs/fs.h | 12 | ||||
-rw-r--r-- | src/fs/fs_unindex.c | 115 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_indexing.c | 9 |
3 files changed, 65 insertions, 71 deletions
diff --git a/src/fs/fs.h b/src/fs/fs.h index 32b4181dd..a7ae457d5 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h | |||
@@ -1352,16 +1352,16 @@ enum UnindexState | |||
1352 | UNINDEX_STATE_HASHING = 0, | 1352 | UNINDEX_STATE_HASHING = 0, |
1353 | 1353 | ||
1354 | /** | 1354 | /** |
1355 | * We're notifying the FS service about | 1355 | * We're telling the datastore to delete |
1356 | * the unindexing. | 1356 | * the respective entries. |
1357 | */ | 1357 | */ |
1358 | UNINDEX_STATE_FS_NOTIFY = 1, | 1358 | UNINDEX_STATE_DS_REMOVE = 1, |
1359 | 1359 | ||
1360 | /** | 1360 | /** |
1361 | * We're telling the datastore to delete | 1361 | * We're notifying the FS service about |
1362 | * the respective entries. | 1362 | * the unindexing. |
1363 | */ | 1363 | */ |
1364 | UNINDEX_STATE_DS_REMOVE = 2, | 1364 | UNINDEX_STATE_FS_NOTIFY = 2, |
1365 | 1365 | ||
1366 | /** | 1366 | /** |
1367 | * We're done. | 1367 | * We're done. |
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index 220ec5870..b69610409 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c | |||
@@ -226,49 +226,6 @@ unindex_process (void *cls, | |||
226 | 226 | ||
227 | 227 | ||
228 | /** | 228 | /** |
229 | * Function called when the tree encoder has | ||
230 | * processed all blocks. Clean up. | ||
231 | * | ||
232 | * @param cls our unindexing context | ||
233 | * @param tc not used | ||
234 | */ | ||
235 | static void | ||
236 | unindex_finish (void *cls, | ||
237 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
238 | { | ||
239 | struct GNUNET_FS_UnindexContext *uc = cls; | ||
240 | char *emsg; | ||
241 | struct GNUNET_FS_Uri *uri; | ||
242 | struct GNUNET_FS_ProgressInfo pi; | ||
243 | |||
244 | GNUNET_FS_tree_encoder_finish (uc->tc, | ||
245 | &uri, | ||
246 | &emsg); | ||
247 | uc->tc = NULL; | ||
248 | if (uri != NULL) | ||
249 | GNUNET_FS_uri_destroy (uri); | ||
250 | GNUNET_DISK_file_close (uc->fh); | ||
251 | uc->fh = NULL; | ||
252 | GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO); | ||
253 | uc->dsh = NULL; | ||
254 | if (emsg != NULL) | ||
255 | { | ||
256 | uc->state = UNINDEX_STATE_ERROR; | ||
257 | uc->emsg = emsg; | ||
258 | signal_unindex_error (uc); | ||
259 | } | ||
260 | else | ||
261 | { | ||
262 | uc->state = UNINDEX_STATE_COMPLETE; | ||
263 | pi.status = GNUNET_FS_STATUS_UNINDEX_COMPLETED; | ||
264 | pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO; | ||
265 | GNUNET_FS_unindex_make_status_ (&pi, uc, uc->file_size); | ||
266 | } | ||
267 | GNUNET_FS_unindex_sync_ (uc); | ||
268 | } | ||
269 | |||
270 | |||
271 | /** | ||
272 | * Function called with the response from the | 229 | * Function called with the response from the |
273 | * FS service to our unindexing request. | 230 | * FS service to our unindexing request. |
274 | * | 231 | * |
@@ -280,6 +237,7 @@ process_fs_response (void *cls, | |||
280 | const struct GNUNET_MessageHeader *msg) | 237 | const struct GNUNET_MessageHeader *msg) |
281 | { | 238 | { |
282 | struct GNUNET_FS_UnindexContext *uc = cls; | 239 | struct GNUNET_FS_UnindexContext *uc = cls; |
240 | struct GNUNET_FS_ProgressInfo pi; | ||
283 | 241 | ||
284 | if (uc->client != NULL) | 242 | if (uc->client != NULL) |
285 | { | 243 | { |
@@ -291,7 +249,7 @@ process_fs_response (void *cls, | |||
291 | uc->state = UNINDEX_STATE_ERROR; | 249 | uc->state = UNINDEX_STATE_ERROR; |
292 | uc->emsg = GNUNET_strdup (_("Unexpected time for a response from `fs' service.")); | 250 | uc->emsg = GNUNET_strdup (_("Unexpected time for a response from `fs' service.")); |
293 | GNUNET_FS_unindex_sync_ (uc); | 251 | GNUNET_FS_unindex_sync_ (uc); |
294 | signal_unindex_error (uc); | 252 | signal_unindex_error (uc); |
295 | return; | 253 | return; |
296 | } | 254 | } |
297 | if (NULL == msg) | 255 | if (NULL == msg) |
@@ -310,9 +268,56 @@ process_fs_response (void *cls, | |||
310 | signal_unindex_error (uc); | 268 | signal_unindex_error (uc); |
311 | return; | 269 | return; |
312 | } | 270 | } |
313 | uc->state = UNINDEX_STATE_DS_REMOVE; | 271 | uc->state = UNINDEX_STATE_COMPLETE; |
272 | pi.status = GNUNET_FS_STATUS_UNINDEX_COMPLETED; | ||
273 | pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO; | ||
314 | GNUNET_FS_unindex_sync_ (uc); | 274 | GNUNET_FS_unindex_sync_ (uc); |
315 | GNUNET_FS_unindex_do_remove_ (uc); | 275 | GNUNET_FS_unindex_make_status_ (&pi, uc, uc->file_size); |
276 | } | ||
277 | |||
278 | |||
279 | /** | ||
280 | * Function called when the tree encoder has | ||
281 | * processed all blocks. Clean up. | ||
282 | * | ||
283 | * @param cls our unindexing context | ||
284 | * @param tc not used | ||
285 | */ | ||
286 | static void | ||
287 | unindex_finish (void *cls, | ||
288 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
289 | { | ||
290 | struct GNUNET_FS_UnindexContext *uc = cls; | ||
291 | char *emsg; | ||
292 | struct GNUNET_FS_Uri *uri; | ||
293 | struct UnindexMessage req; | ||
294 | |||
295 | GNUNET_FS_tree_encoder_finish (uc->tc, | ||
296 | &uri, | ||
297 | &emsg); | ||
298 | uc->tc = NULL; | ||
299 | if (uri != NULL) | ||
300 | GNUNET_FS_uri_destroy (uri); | ||
301 | GNUNET_DISK_file_close (uc->fh); | ||
302 | uc->fh = NULL; | ||
303 | GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO); | ||
304 | uc->dsh = NULL; | ||
305 | uc->state = UNINDEX_STATE_FS_NOTIFY; | ||
306 | GNUNET_FS_unindex_sync_ (uc); | ||
307 | uc->client = GNUNET_CLIENT_connect (uc->h->sched, | ||
308 | "fs", | ||
309 | uc->h->cfg); | ||
310 | req.header.size = htons (sizeof (struct UnindexMessage)); | ||
311 | req.header.type = htons (GNUNET_MESSAGE_TYPE_FS_UNINDEX); | ||
312 | req.reserved = 0; | ||
313 | req.file_id = uc->file_id; | ||
314 | GNUNET_break (GNUNET_OK == | ||
315 | GNUNET_CLIENT_transmit_and_get_response (uc->client, | ||
316 | &req.header, | ||
317 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | ||
318 | GNUNET_YES, | ||
319 | &process_fs_response, | ||
320 | uc)); | ||
316 | } | 321 | } |
317 | 322 | ||
318 | 323 | ||
@@ -370,7 +375,6 @@ GNUNET_FS_unindex_process_hash_ (void *cls, | |||
370 | const GNUNET_HashCode *file_id) | 375 | const GNUNET_HashCode *file_id) |
371 | { | 376 | { |
372 | struct GNUNET_FS_UnindexContext *uc = cls; | 377 | struct GNUNET_FS_UnindexContext *uc = cls; |
373 | struct UnindexMessage req; | ||
374 | 378 | ||
375 | uc->fhc = NULL; | 379 | uc->fhc = NULL; |
376 | if (uc->state != UNINDEX_STATE_HASHING) | 380 | if (uc->state != UNINDEX_STATE_HASHING) |
@@ -387,22 +391,9 @@ GNUNET_FS_unindex_process_hash_ (void *cls, | |||
387 | return; | 391 | return; |
388 | } | 392 | } |
389 | uc->file_id = *file_id; | 393 | uc->file_id = *file_id; |
390 | uc->state = UNINDEX_STATE_FS_NOTIFY; | 394 | uc->state = UNINDEX_STATE_DS_REMOVE; |
391 | GNUNET_FS_unindex_sync_ (uc); | 395 | GNUNET_FS_unindex_sync_ (uc); |
392 | uc->client = GNUNET_CLIENT_connect (uc->h->sched, | 396 | GNUNET_FS_unindex_do_remove_ (uc); |
393 | "fs", | ||
394 | uc->h->cfg); | ||
395 | req.header.size = htons (sizeof (struct UnindexMessage)); | ||
396 | req.header.type = htons (GNUNET_MESSAGE_TYPE_FS_UNINDEX); | ||
397 | req.reserved = 0; | ||
398 | req.file_id = *file_id; | ||
399 | GNUNET_break (GNUNET_OK == | ||
400 | GNUNET_CLIENT_transmit_and_get_response (uc->client, | ||
401 | &req.header, | ||
402 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | ||
403 | GNUNET_YES, | ||
404 | &process_fs_response, | ||
405 | uc)); | ||
406 | } | 397 | } |
407 | 398 | ||
408 | 399 | ||
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c index 39999be75..808f56a2c 100644 --- a/src/fs/gnunet-service-fs_indexing.c +++ b/src/fs/gnunet-service-fs_indexing.c | |||
@@ -206,7 +206,6 @@ read_index_list () | |||
206 | GNUNET_free (fn); | 206 | GNUNET_free (fn); |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | |||
210 | while ( (GNUNET_OK == | 209 | while ( (GNUNET_OK == |
211 | GNUNET_BIO_read (rh, | 210 | GNUNET_BIO_read (rh, |
212 | "Hash of indexed file", | 211 | "Hash of indexed file", |
@@ -478,7 +477,7 @@ GNUNET_FS_handle_unindex (void *cls, | |||
478 | struct IndexInfo *next; | 477 | struct IndexInfo *next; |
479 | struct GNUNET_SERVER_TransmitContext *tc; | 478 | struct GNUNET_SERVER_TransmitContext *tc; |
480 | int found; | 479 | int found; |
481 | 480 | ||
482 | um = (const struct UnindexMessage*) message; | 481 | um = (const struct UnindexMessage*) message; |
483 | found = GNUNET_NO; | 482 | found = GNUNET_NO; |
484 | prev = NULL; | 483 | prev = NULL; |
@@ -494,6 +493,10 @@ GNUNET_FS_handle_unindex (void *cls, | |||
494 | indexed_files = next; | 493 | indexed_files = next; |
495 | else | 494 | else |
496 | prev->next = next; | 495 | prev->next = next; |
496 | GNUNET_break (GNUNET_OK == | ||
497 | GNUNET_CONTAINER_multihashmap_remove (ifm, | ||
498 | &pos->file_id, | ||
499 | (void*) pos->filename)); | ||
497 | GNUNET_free (pos); | 500 | GNUNET_free (pos); |
498 | found = GNUNET_YES; | 501 | found = GNUNET_YES; |
499 | } | 502 | } |
@@ -621,7 +624,7 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, | |||
621 | GNUNET_h2s (&odb->file_id), | 624 | GNUNET_h2s (&odb->file_id), |
622 | fn, | 625 | fn, |
623 | (unsigned long long) off, | 626 | (unsigned long long) off, |
624 | STRERROR (errno)); | 627 | (fn == NULL) ? _("not indexed") : STRERROR (errno)); |
625 | if (fh != NULL) | 628 | if (fh != NULL) |
626 | GNUNET_DISK_file_close (fh); | 629 | GNUNET_DISK_file_close (fh); |
627 | GNUNET_DATASTORE_remove (dsh, | 630 | GNUNET_DATASTORE_remove (dsh, |