aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_unindex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/fs_unindex.c')
-rw-r--r--src/fs/fs_unindex.c62
1 files changed, 51 insertions, 11 deletions
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c
index db0540607..349cc4251 100644
--- a/src/fs/fs_unindex.c
+++ b/src/fs/fs_unindex.c
@@ -243,6 +243,7 @@ unindex_finish (void *cls,
243 GNUNET_FS_tree_encoder_finish (uc->tc, 243 GNUNET_FS_tree_encoder_finish (uc->tc,
244 &uri, 244 &uri,
245 &emsg); 245 &emsg);
246 uc->tc = NULL;
246 if (uri != NULL) 247 if (uri != NULL)
247 GNUNET_FS_uri_destroy (uri); 248 GNUNET_FS_uri_destroy (uri);
248 GNUNET_DISK_file_close (uc->fh); 249 GNUNET_DISK_file_close (uc->fh);
@@ -251,11 +252,13 @@ unindex_finish (void *cls,
251 uc->dsh = NULL; 252 uc->dsh = NULL;
252 if (emsg != NULL) 253 if (emsg != NULL)
253 { 254 {
255 uc->state = UNINDEX_STATE_ERROR;
254 uc->emsg = emsg; 256 uc->emsg = emsg;
255 signal_unindex_error (uc); 257 signal_unindex_error (uc);
256 } 258 }
257 else 259 else
258 { 260 {
261 uc->state = UNINDEX_STATE_COMPLETE;
259 pi.status = GNUNET_FS_STATUS_UNINDEX_COMPLETED; 262 pi.status = GNUNET_FS_STATUS_UNINDEX_COMPLETED;
260 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO; 263 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
261 GNUNET_FS_unindex_make_status_ (&pi, uc, uc->file_size); 264 GNUNET_FS_unindex_make_status_ (&pi, uc, uc->file_size);
@@ -284,7 +287,10 @@ process_fs_response (void *cls,
284 } 287 }
285 if (uc->state != UNINDEX_STATE_FS_NOTIFY) 288 if (uc->state != UNINDEX_STATE_FS_NOTIFY)
286 { 289 {
287 GNUNET_FS_unindex_stop (uc); 290 uc->state = UNINDEX_STATE_ERROR;
291 uc->emsg = GNUNET_strdup (_("Unexpected time for a response from `fs' service."));
292 GNUNET_FS_unindex_sync_ (uc);
293 signal_unindex_error (uc);
288 return; 294 return;
289 } 295 }
290 if (NULL == msg) 296 if (NULL == msg)
@@ -416,6 +422,28 @@ GNUNET_FS_unindex_signal_suspend_ (void *cls)
416 GNUNET_CRYPTO_hash_file_cancel (uc->fhc); 422 GNUNET_CRYPTO_hash_file_cancel (uc->fhc);
417 uc->fhc = NULL; 423 uc->fhc = NULL;
418 } 424 }
425 if (uc->client != NULL)
426 {
427 GNUNET_CLIENT_disconnect (uc->client, GNUNET_NO);
428 uc->client = NULL;
429 }
430 if (NULL != uc->dsh)
431 {
432 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
433 uc->dsh = NULL;
434 }
435 if (NULL != uc->tc)
436 {
437 GNUNET_FS_tree_encoder_finish (uc->tc,
438 NULL,
439 NULL);
440 uc->tc = NULL;
441 }
442 if (uc->fh != NULL)
443 {
444 GNUNET_DISK_file_close (uc->fh);
445 uc->fh = NULL;
446 }
419 GNUNET_FS_end_top (uc->h, uc->top); 447 GNUNET_FS_end_top (uc->h, uc->top);
420 pi.status = GNUNET_FS_STATUS_UNINDEX_SUSPEND; 448 pi.status = GNUNET_FS_STATUS_UNINDEX_SUSPEND;
421 GNUNET_FS_unindex_make_status_ (&pi, uc, 449 GNUNET_FS_unindex_make_status_ (&pi, uc,
@@ -488,17 +516,29 @@ GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc)
488 GNUNET_CRYPTO_hash_file_cancel (uc->fhc); 516 GNUNET_CRYPTO_hash_file_cancel (uc->fhc);
489 uc->fhc = NULL; 517 uc->fhc = NULL;
490 } 518 }
491 /* FIXME: disconnect uc->client (if still connected) */ 519 if (uc->client != NULL)
492 /* FIXME: disconnect from datastore (if still connected) */
493 /* FIXME: other termination operations? */
494 /* FIXME: must do same cleanup in 'unindex_signal_suspend'! */
495 GNUNET_FS_end_top (uc->h, uc->top);
496 if ( (uc->state != UNINDEX_STATE_COMPLETE) &&
497 (uc->state != UNINDEX_STATE_ERROR) )
498 { 520 {
499 uc->state = UNINDEX_STATE_ABORTED; 521 GNUNET_CLIENT_disconnect (uc->client, GNUNET_NO);
500 return; 522 uc->client = NULL;
523 }
524 if (NULL != uc->dsh)
525 {
526 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
527 uc->dsh = NULL;
528 }
529 if (NULL != uc->tc)
530 {
531 GNUNET_FS_tree_encoder_finish (uc->tc,
532 NULL,
533 NULL);
534 uc->tc = NULL;
535 }
536 if (uc->fh != NULL)
537 {
538 GNUNET_DISK_file_close (uc->fh);
539 uc->fh = NULL;
501 } 540 }
541 GNUNET_FS_end_top (uc->h, uc->top);
502 if (uc->serialization != NULL) 542 if (uc->serialization != NULL)
503 { 543 {
504 GNUNET_FS_remove_sync_file_ (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, uc->serialization); 544 GNUNET_FS_remove_sync_file_ (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, uc->serialization);