From dbaf8fc3075e00b95eaf8ced5a5d07d59ed61ca5 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 14 Sep 2013 14:16:46 +0000 Subject: [PATCH] -more complete fix for #3034 --- src/fs/fs_api.c | 2 +- src/fs/fs_file_information.c | 6 +++--- src/fs/fs_publish.c | 13 ++++++------- src/fs/fs_tree.c | 13 +++++++------ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index e5707c804..d61ef0016 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c @@ -496,7 +496,7 @@ GNUNET_FS_make_file_reader_context_ (const char *filename) { struct FileInfo *fi; - fi = GNUNET_malloc (sizeof (struct FileInfo)); + fi = GNUNET_new (struct FileInfo); fi->filename = GNUNET_STRINGS_filename_expand (filename); if (NULL == fi->filename) { diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index da4e85b78..b1ec1ed5d 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c @@ -123,7 +123,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, return NULL; } fi = GNUNET_FS_make_file_reader_context_ (filename); - if (fi == NULL) + if (NULL == fi) { GNUNET_break (0); return NULL; @@ -261,7 +261,7 @@ GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h, * Test if a given entry represents a directory. * * @param ent check if this FI represents a directory - * @return GNUNET_YES if so, GNUNET_NO if not + * @return #GNUNET_YES if so, #GNUNET_NO if not */ int GNUNET_FS_file_information_is_directory (const struct GNUNET_FS_FileInformation @@ -409,7 +409,7 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi, int no; no = GNUNET_NO; - if (fi->is_directory == GNUNET_YES) + if (GNUNET_YES == fi->is_directory) { /* clean up directory */ while (NULL != (pos = fi->data.dir.entries)) diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index c554c8bb2..73af99ce9 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -345,8 +345,8 @@ block_reader (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) { struct GNUNET_FS_PublishContext *pc = cls; struct GNUNET_FS_FileInformation *p; - size_t pt_size; const char *dd; + size_t pt_size; p = pc->fi_pos; if (GNUNET_YES == p->is_directory) @@ -359,16 +359,15 @@ block_reader (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) { if (UINT64_MAX == offset) { - if (NULL != p->data.file.reader) - { - pt_size = p->data.file.reader (p->data.file.reader_cls, offset, 0, NULL, NULL); - p->data.file.reader = NULL; - return pt_size; + if (&GNUNET_FS_data_reader_file_ == p->data.file.reader) + { + /* force closing the file to avoid keeping too many files open */ + p->data.file.reader (p->data.file.reader_cls, offset, 0, NULL, NULL); } return 0; } pt_size = GNUNET_MIN (max, p->data.file.file_size - offset); - if (pt_size == 0) + if (0 == pt_size) return 0; /* calling reader with pt_size==0 * might free buf, so don't! */ if (pt_size != diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c index b27fea57f..762989824 100644 --- a/src/fs/fs_tree.c +++ b/src/fs/fs_tree.c @@ -250,13 +250,13 @@ GNUNET_FS_tree_calculate_block_size (uint64_t fsize, uint64_t offset, /** - * Initialize a tree encoder. This function will call "proc" and + * Initialize a tree encoder. This function will call @a proc and * "progress" on each block in the tree. Once all blocks have been - * processed, "cont" will be scheduled. The "reader" will be called + * processed, "cont" will be scheduled. The @a reader will be called * to obtain the (plaintext) blocks for the file. Note that this - * function will not actually call "proc". The client must - * call "GNUNET_FS_tree_encoder_next" to trigger encryption (and - * calling of "proc") for the each block. + * function will not actually call @a proc. The client must + * call #GNUNET_FS_tree_encoder_next to trigger encryption (and + * calling of @a proc) for the each block. * * @param h the global FS context * @param size overall size of the file to encode @@ -268,7 +268,8 @@ GNUNET_FS_tree_calculate_block_size (uint64_t fsize, uint64_t offset, */ struct GNUNET_FS_TreeEncoder * GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, uint64_t size, - void *cls, GNUNET_FS_DataReader reader, + void *cls, + GNUNET_FS_DataReader reader, GNUNET_FS_TreeBlockProcessor proc, GNUNET_FS_TreeProgressCallback progress, GNUNET_SCHEDULER_Task cont) -- 2.25.1