From: Christian Grothoff Date: Sun, 29 Jan 2012 15:48:23 +0000 (+0000) Subject: -misc bugfixes X-Git-Tag: initial-import-from-subversion-38251~15023 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=415c958a01ab6dac73b0109becbe8657b525af9c;p=oweals%2Fgnunet.git -misc bugfixes --- 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, if (wr > 0) total += wr; } while ( (wr > 0) && (total < size) ); + if (wr <= 0) + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Failed to write to inter thread communication pipe: %s\n", + strerror (errno)); return (total == size) ? GNUNET_OK : GNUNET_SYSERR; } @@ -449,9 +453,11 @@ extract_files (struct GNUNET_FS_DirScanner *ds, } /* this is the expensive operation, *afterwards* we'll check for aborts */ + fprintf (stderr, "\tCalling extract on `%s'\n", item->filename); GNUNET_FS_meta_data_extract_from_file (item->meta, item->filename, ds->plugins); + fprintf (stderr, "\tExtract `%s' done\n", item->filename); /* having full filenames is too dangerous; always make sure we clean them up */ GNUNET_CONTAINER_meta_data_delete (item->meta, @@ -497,19 +503,25 @@ run_directory_scan_thread (void *cls) ds->filename_expanded, &ds->toplevel)) { - (void) write_progress (ds, "", GNUNET_NO, GNUNET_FS_DIRSCANNER_INTERNAL_ERROR); + (void) write_progress (ds, "", GNUNET_SYSERR, GNUNET_FS_DIRSCANNER_INTERNAL_ERROR); + GNUNET_DISK_pipe_close_end (ds->progress_pipe, GNUNET_DISK_PIPE_END_WRITE); return 0; } if (GNUNET_OK != - write_progress (ds, "", GNUNET_NO, GNUNET_FS_DIRSCANNER_ALL_COUNTED)) + write_progress (ds, "", GNUNET_SYSERR, GNUNET_FS_DIRSCANNER_ALL_COUNTED)) + { + GNUNET_DISK_pipe_close_end (ds->progress_pipe, GNUNET_DISK_PIPE_END_WRITE); return 0; + } if (GNUNET_OK != extract_files (ds, ds->toplevel)) { - (void) write_progress (ds, "", GNUNET_NO, GNUNET_FS_DIRSCANNER_INTERNAL_ERROR); + (void) write_progress (ds, "", GNUNET_SYSERR, GNUNET_FS_DIRSCANNER_INTERNAL_ERROR); + GNUNET_DISK_pipe_close_end (ds->progress_pipe, GNUNET_DISK_PIPE_END_WRITE); return 0; } - (void) write_progress (ds, "", GNUNET_NO, GNUNET_FS_DIRSCANNER_FINISHED); + (void) write_progress (ds, "", GNUNET_SYSERR, GNUNET_FS_DIRSCANNER_FINISHED); + GNUNET_DISK_pipe_close_end (ds->progress_pipe, GNUNET_DISK_PIPE_END_WRITE); return 0; } @@ -539,6 +551,10 @@ read_all (const struct GNUNET_DISK_FileHandle *in, if (rd > 0) total += rd; } while ( (rd > 0) && (total < size) ); + if (rd <= 0) + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Failed to read from inter thread communication pipe: %s\n", + strerror (errno)); return (total == size) ? GNUNET_OK : GNUNET_SYSERR; } @@ -560,7 +576,7 @@ read_progress_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) char *filename; ds->progress_read_task = GNUNET_SCHEDULER_NO_TASK; - if (! (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) + if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) { ds->progress_read_task = 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) } /* schedule task to keep reading (done here in case client calls abort or something similar) */ - if ( (reason != GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED) && + if ( (reason != GNUNET_FS_DIRSCANNER_FINISHED) && (reason != GNUNET_FS_DIRSCANNER_INTERNAL_ERROR) ) + { ds->progress_read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, ds->progress_read, &read_progress_task, ds); - + } /* read successfully, notify client about progress */ ds->progress_callback (ds->progress_callback_cls, 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) struct KeywordCounter *counter = value; if (counter->count >= tc->move_threshold) - GNUNET_FS_uri_ksk_add_keyword (tc->pos->ksk_uri, counter->value, GNUNET_NO); + { + if (NULL == tc->pos->ksk_uri) + tc->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &counter->value); + else + GNUNET_FS_uri_ksk_add_keyword (tc->pos->ksk_uri, counter->value, GNUNET_NO); + } GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (tc->keywordcounter, key, @@ -360,7 +365,8 @@ share_tree_trim (struct TrimContext *tc, for (pos = tree->children_head; NULL != pos; pos = pos->next) { GNUNET_CONTAINER_meta_data_iterate (pos->meta, &add_to_meta_counter, tc->metacounter); - GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &add_to_keyword_counter, tc->keywordcounter); + if (NULL != pos->ksk_uri) + GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &add_to_keyword_counter, tc->keywordcounter); } /* calculate threshold for moving keywords / meta data */ @@ -370,7 +376,8 @@ share_tree_trim (struct TrimContext *tc, for (pos = tree->children_head; NULL != pos; pos = pos->next) { tc->pos = pos; - GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &remove_high_frequency_keywords, tc); + if (NULL != pos->ksk_uri) + GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &remove_high_frequency_keywords, tc); } /* 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, ctx = NULL; } + static struct GNUNET_FS_FileInformation * get_file_information (struct GNUNET_FS_ShareTreeItem *item) { @@ -356,7 +357,13 @@ get_file_information (struct GNUNET_FS_ShareTreeItem *item) GNUNET_CONTAINER_meta_data_delete (item->meta, EXTRACTOR_METATYPE_MIMETYPE, NULL, 0); GNUNET_FS_meta_data_make_directory (item->meta); - GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME, + if (NULL == item->ksk_uri) + { + const char *mime = GNUNET_FS_DIRECTORY_MIME; + item->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &mime); + } + else + GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME, GNUNET_NO); fi = GNUNET_FS_file_information_create_empty_directory ( ctx, NULL, item->ksk_uri, @@ -467,6 +474,7 @@ directory_scan_cb (void *cls, struct GNUNET_FS_DirScanner *ds, GNUNET_assert (0); break; } + fflush (stdout); }