aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-29 15:48:23 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-29 15:48:23 +0000
commit415c958a01ab6dac73b0109becbe8657b525af9c (patch)
tree27681936603f7aaaf019d3646def34be58c524ff /src/fs
parent09cc5834ba81348ce8d97ed6889204ad8d45150e (diff)
downloadgnunet-415c958a01ab6dac73b0109becbe8657b525af9c.tar.gz
gnunet-415c958a01ab6dac73b0109becbe8657b525af9c.zip
-misc bugfixes
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs_dirmetascan.c31
-rw-r--r--src/fs/fs_sharetree.c13
-rw-r--r--src/fs/gnunet-publish.c10
3 files changed, 43 insertions, 11 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,
diff --git a/src/fs/fs_sharetree.c b/src/fs/fs_sharetree.c
index 6c9642b9b..8660c8958 100644
--- a/src/fs/fs_sharetree.c
+++ b/src/fs/fs_sharetree.c
@@ -274,7 +274,12 @@ migrate_and_drop_keywords (void *cls, const GNUNET_HashCode * key, void *value)
274 struct KeywordCounter *counter = value; 274 struct KeywordCounter *counter = value;
275 275
276 if (counter->count >= tc->move_threshold) 276 if (counter->count >= tc->move_threshold)
277 GNUNET_FS_uri_ksk_add_keyword (tc->pos->ksk_uri, counter->value, GNUNET_NO); 277 {
278 if (NULL == tc->pos->ksk_uri)
279 tc->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &counter->value);
280 else
281 GNUNET_FS_uri_ksk_add_keyword (tc->pos->ksk_uri, counter->value, GNUNET_NO);
282 }
278 GNUNET_assert (GNUNET_YES == 283 GNUNET_assert (GNUNET_YES ==
279 GNUNET_CONTAINER_multihashmap_remove (tc->keywordcounter, 284 GNUNET_CONTAINER_multihashmap_remove (tc->keywordcounter,
280 key, 285 key,
@@ -360,7 +365,8 @@ share_tree_trim (struct TrimContext *tc,
360 for (pos = tree->children_head; NULL != pos; pos = pos->next) 365 for (pos = tree->children_head; NULL != pos; pos = pos->next)
361 { 366 {
362 GNUNET_CONTAINER_meta_data_iterate (pos->meta, &add_to_meta_counter, tc->metacounter); 367 GNUNET_CONTAINER_meta_data_iterate (pos->meta, &add_to_meta_counter, tc->metacounter);
363 GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &add_to_keyword_counter, tc->keywordcounter); 368 if (NULL != pos->ksk_uri)
369 GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &add_to_keyword_counter, tc->keywordcounter);
364 } 370 }
365 371
366 /* calculate threshold for moving keywords / meta data */ 372 /* calculate threshold for moving keywords / meta data */
@@ -370,7 +376,8 @@ share_tree_trim (struct TrimContext *tc,
370 for (pos = tree->children_head; NULL != pos; pos = pos->next) 376 for (pos = tree->children_head; NULL != pos; pos = pos->next)
371 { 377 {
372 tc->pos = pos; 378 tc->pos = pos;
373 GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &remove_high_frequency_keywords, tc); 379 if (NULL != pos->ksk_uri)
380 GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &remove_high_frequency_keywords, tc);
374 } 381 }
375 382
376 /* add high-frequency meta data and keywords to parent */ 383 /* add high-frequency meta data and keywords to parent */
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
index 33cba499e..15054a722 100644
--- a/src/fs/gnunet-publish.c
+++ b/src/fs/gnunet-publish.c
@@ -344,6 +344,7 @@ uri_ksk_continuation (void *cls, const struct GNUNET_FS_Uri *ksk_uri,
344 ctx = NULL; 344 ctx = NULL;
345} 345}
346 346
347
347static struct GNUNET_FS_FileInformation * 348static struct GNUNET_FS_FileInformation *
348get_file_information (struct GNUNET_FS_ShareTreeItem *item) 349get_file_information (struct GNUNET_FS_ShareTreeItem *item)
349{ 350{
@@ -356,7 +357,13 @@ get_file_information (struct GNUNET_FS_ShareTreeItem *item)
356 GNUNET_CONTAINER_meta_data_delete (item->meta, 357 GNUNET_CONTAINER_meta_data_delete (item->meta,
357 EXTRACTOR_METATYPE_MIMETYPE, NULL, 0); 358 EXTRACTOR_METATYPE_MIMETYPE, NULL, 0);
358 GNUNET_FS_meta_data_make_directory (item->meta); 359 GNUNET_FS_meta_data_make_directory (item->meta);
359 GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME, 360 if (NULL == item->ksk_uri)
361 {
362 const char *mime = GNUNET_FS_DIRECTORY_MIME;
363 item->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &mime);
364 }
365 else
366 GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME,
360 GNUNET_NO); 367 GNUNET_NO);
361 fi = GNUNET_FS_file_information_create_empty_directory ( 368 fi = GNUNET_FS_file_information_create_empty_directory (
362 ctx, NULL, item->ksk_uri, 369 ctx, NULL, item->ksk_uri,
@@ -467,6 +474,7 @@ directory_scan_cb (void *cls, struct GNUNET_FS_DirScanner *ds,
467 GNUNET_assert (0); 474 GNUNET_assert (0);
468 break; 475 break;
469 } 476 }
477 fflush (stdout);
470} 478}
471 479
472 480