diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-29 15:48:23 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-29 15:48:23 +0000 |
commit | 415c958a01ab6dac73b0109becbe8657b525af9c (patch) | |
tree | 27681936603f7aaaf019d3646def34be58c524ff /src/fs/fs_dirmetascan.c | |
parent | 09cc5834ba81348ce8d97ed6889204ad8d45150e (diff) | |
download | gnunet-415c958a01ab6dac73b0109becbe8657b525af9c.tar.gz gnunet-415c958a01ab6dac73b0109becbe8657b525af9c.zip |
-misc bugfixes
Diffstat (limited to 'src/fs/fs_dirmetascan.c')
-rw-r--r-- | src/fs/fs_dirmetascan.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/fs/fs_dirmetascan.c b/src/fs/fs_dirmetascan.c index dc1cb1647..50b8273d3 100644 --- a/src/fs/fs_dirmetascan.c +++ b/src/fs/fs_dirmetascan.c | |||
@@ -217,6 +217,10 @@ write_all (const struct GNUNET_DISK_FileHandle *out, | |||
217 | if (wr > 0) | 217 | if (wr > 0) |
218 | total += wr; | 218 | total += wr; |
219 | } while ( (wr > 0) && (total < size) ); | 219 | } while ( (wr > 0) && (total < size) ); |
220 | if (wr <= 0) | ||
221 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
222 | "Failed to write to inter thread communication pipe: %s\n", | ||
223 | strerror (errno)); | ||
220 | return (total == size) ? GNUNET_OK : GNUNET_SYSERR; | 224 | return (total == size) ? GNUNET_OK : GNUNET_SYSERR; |
221 | } | 225 | } |
222 | 226 | ||
@@ -449,9 +453,11 @@ extract_files (struct GNUNET_FS_DirScanner *ds, | |||
449 | } | 453 | } |
450 | 454 | ||
451 | /* this is the expensive operation, *afterwards* we'll check for aborts */ | 455 | /* this is the expensive operation, *afterwards* we'll check for aborts */ |
456 | fprintf (stderr, "\tCalling extract on `%s'\n", item->filename); | ||
452 | GNUNET_FS_meta_data_extract_from_file (item->meta, | 457 | GNUNET_FS_meta_data_extract_from_file (item->meta, |
453 | item->filename, | 458 | item->filename, |
454 | ds->plugins); | 459 | ds->plugins); |
460 | fprintf (stderr, "\tExtract `%s' done\n", item->filename); | ||
455 | 461 | ||
456 | /* having full filenames is too dangerous; always make sure we clean them up */ | 462 | /* having full filenames is too dangerous; always make sure we clean them up */ |
457 | GNUNET_CONTAINER_meta_data_delete (item->meta, | 463 | GNUNET_CONTAINER_meta_data_delete (item->meta, |
@@ -497,19 +503,25 @@ run_directory_scan_thread (void *cls) | |||
497 | ds->filename_expanded, | 503 | ds->filename_expanded, |
498 | &ds->toplevel)) | 504 | &ds->toplevel)) |
499 | { | 505 | { |
500 | (void) write_progress (ds, "", GNUNET_NO, GNUNET_FS_DIRSCANNER_INTERNAL_ERROR); | 506 | (void) write_progress (ds, "", GNUNET_SYSERR, GNUNET_FS_DIRSCANNER_INTERNAL_ERROR); |
507 | GNUNET_DISK_pipe_close_end (ds->progress_pipe, GNUNET_DISK_PIPE_END_WRITE); | ||
501 | return 0; | 508 | return 0; |
502 | } | 509 | } |
503 | if (GNUNET_OK != | 510 | if (GNUNET_OK != |
504 | write_progress (ds, "", GNUNET_NO, GNUNET_FS_DIRSCANNER_ALL_COUNTED)) | 511 | write_progress (ds, "", GNUNET_SYSERR, GNUNET_FS_DIRSCANNER_ALL_COUNTED)) |
512 | { | ||
513 | GNUNET_DISK_pipe_close_end (ds->progress_pipe, GNUNET_DISK_PIPE_END_WRITE); | ||
505 | return 0; | 514 | return 0; |
515 | } | ||
506 | if (GNUNET_OK != | 516 | if (GNUNET_OK != |
507 | extract_files (ds, ds->toplevel)) | 517 | extract_files (ds, ds->toplevel)) |
508 | { | 518 | { |
509 | (void) write_progress (ds, "", GNUNET_NO, GNUNET_FS_DIRSCANNER_INTERNAL_ERROR); | 519 | (void) write_progress (ds, "", GNUNET_SYSERR, GNUNET_FS_DIRSCANNER_INTERNAL_ERROR); |
520 | GNUNET_DISK_pipe_close_end (ds->progress_pipe, GNUNET_DISK_PIPE_END_WRITE); | ||
510 | return 0; | 521 | return 0; |
511 | } | 522 | } |
512 | (void) write_progress (ds, "", GNUNET_NO, GNUNET_FS_DIRSCANNER_FINISHED); | 523 | (void) write_progress (ds, "", GNUNET_SYSERR, GNUNET_FS_DIRSCANNER_FINISHED); |
524 | GNUNET_DISK_pipe_close_end (ds->progress_pipe, GNUNET_DISK_PIPE_END_WRITE); | ||
513 | return 0; | 525 | return 0; |
514 | } | 526 | } |
515 | 527 | ||
@@ -539,6 +551,10 @@ read_all (const struct GNUNET_DISK_FileHandle *in, | |||
539 | if (rd > 0) | 551 | if (rd > 0) |
540 | total += rd; | 552 | total += rd; |
541 | } while ( (rd > 0) && (total < size) ); | 553 | } while ( (rd > 0) && (total < size) ); |
554 | if (rd <= 0) | ||
555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
556 | "Failed to read from inter thread communication pipe: %s\n", | ||
557 | strerror (errno)); | ||
542 | return (total == size) ? GNUNET_OK : GNUNET_SYSERR; | 558 | return (total == size) ? GNUNET_OK : GNUNET_SYSERR; |
543 | } | 559 | } |
544 | 560 | ||
@@ -560,7 +576,7 @@ read_progress_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
560 | char *filename; | 576 | char *filename; |
561 | 577 | ||
562 | ds->progress_read_task = GNUNET_SCHEDULER_NO_TASK; | 578 | ds->progress_read_task = GNUNET_SCHEDULER_NO_TASK; |
563 | if (! (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) | 579 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) |
564 | { | 580 | { |
565 | ds->progress_read_task | 581 | ds->progress_read_task |
566 | = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 582 | = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
@@ -604,13 +620,14 @@ read_progress_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
604 | } | 620 | } |
605 | /* schedule task to keep reading (done here in case client calls | 621 | /* schedule task to keep reading (done here in case client calls |
606 | abort or something similar) */ | 622 | abort or something similar) */ |
607 | if ( (reason != GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED) && | 623 | if ( (reason != GNUNET_FS_DIRSCANNER_FINISHED) && |
608 | (reason != GNUNET_FS_DIRSCANNER_INTERNAL_ERROR) ) | 624 | (reason != GNUNET_FS_DIRSCANNER_INTERNAL_ERROR) ) |
625 | { | ||
609 | ds->progress_read_task | 626 | ds->progress_read_task |
610 | = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 627 | = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
611 | ds->progress_read, | 628 | ds->progress_read, |
612 | &read_progress_task, ds); | 629 | &read_progress_task, ds); |
613 | 630 | } | |
614 | /* read successfully, notify client about progress */ | 631 | /* read successfully, notify client about progress */ |
615 | ds->progress_callback (ds->progress_callback_cls, | 632 | ds->progress_callback (ds->progress_callback_cls, |
616 | ds, | 633 | ds, |