gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r29220 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r29220 - gnunet/src/fs
Date: Thu, 12 Sep 2013 00:45:57 +0200

Author: grothoff
Date: 2013-09-12 00:45:57 +0200 (Thu, 12 Sep 2013)
New Revision: 29220

Modified:
   gnunet/src/fs/fs_api.c
   gnunet/src/fs/fs_file_information.c
   gnunet/src/fs/fs_publish.c
   gnunet/src/fs/fs_tree.c
Log:
-do not clean up reader more than once

Modified: gnunet/src/fs/fs_api.c
===================================================================
--- gnunet/src/fs/fs_api.c      2013-09-11 22:45:32 UTC (rev 29219)
+++ gnunet/src/fs/fs_api.c      2013-09-11 22:45:57 UTC (rev 29220)
@@ -1391,12 +1391,16 @@
  * @return NULL if srch was not found in this subtree
  */
 static struct GNUNET_FS_FileInformation *
-find_file_position (struct GNUNET_FS_FileInformation *pos, const char *srch)
+find_file_position (struct GNUNET_FS_FileInformation *pos, 
+                   const char *srch)
 {
   struct GNUNET_FS_FileInformation *r;
 
   while (NULL != pos)
   {
+    fprintf (stderr,
+            "CMP: %s %s\n",
+            srch, pos->serialization);
     if (0 == strcmp (srch, pos->serialization))
       return pos;
     if ( (GNUNET_YES == pos->is_directory) &&
@@ -1457,7 +1461,7 @@
  *
  * @param cls the 'struct GNUNET_FS_Handle*'
  * @param filename complete filename (absolute path)
- * @return GNUNET_OK (continue to iterate)
+ * @return #GNUNET_OK (continue to iterate)
  */
 static int
 deserialize_publish_file (void *cls, const char *filename)

Modified: gnunet/src/fs/fs_file_information.c
===================================================================
--- gnunet/src/fs/fs_file_information.c 2013-09-11 22:45:32 UTC (rev 29219)
+++ gnunet/src/fs/fs_file_information.c 2013-09-11 22:45:57 UTC (rev 29220)
@@ -426,8 +426,11 @@
   else
   {
     /* call clean-up function of the reader */
-    if (fi->data.file.reader != NULL)
-      fi->data.file.reader (fi->data.file.reader_cls, 0, 0, NULL, NULL);
+    if (NULL != fi->data.file.reader)
+    {
+      (void) fi->data.file.reader (fi->data.file.reader_cls, 0, 0, NULL, NULL);
+      fi->data.file.reader = NULL;
+    }
     /* clean up client-info */
     if (NULL != cleaner)
       cleaner (cleaner_cls, fi, fi->data.file.file_size, fi->meta,
@@ -446,7 +449,7 @@
   if (NULL != fi->meta)
     GNUNET_CONTAINER_meta_data_destroy (fi->meta);
   GNUNET_free_non_null (fi->serialization);
-  if (fi->te != NULL)
+  if (NULL != fi->te)
   {
     GNUNET_FS_tree_encoder_finish (fi->te, NULL, NULL);
     fi->te = NULL;

Modified: gnunet/src/fs/fs_publish.c
===================================================================
--- gnunet/src/fs/fs_publish.c  2013-09-11 22:45:32 UTC (rev 29219)
+++ gnunet/src/fs/fs_publish.c  2013-09-11 22:45:57 UTC (rev 29220)
@@ -349,7 +349,7 @@
   const char *dd;
 
   p = pc->fi_pos;
-  if (p->is_directory == GNUNET_YES)
+  if (GNUNET_YES == p->is_directory)
   {
     pt_size = GNUNET_MIN (max, p->data.dir.dir_size - offset);
     dd = p->data.dir.dir_data;
@@ -357,8 +357,16 @@
   }
   else
   {
-    if (UINT64_MAX == offset)
-      return p->data.file.reader (p->data.file.reader_cls, offset, 0, NULL, 
NULL);
+    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;
+      }
+      return 0;
+    }
     pt_size = GNUNET_MIN (max, p->data.file.file_size - offset);
     if (pt_size == 0)
       return 0;                 /* calling reader with pt_size==0

Modified: gnunet/src/fs/fs_tree.c
===================================================================
--- gnunet/src/fs/fs_tree.c     2013-09-11 22:45:32 UTC (rev 29219)
+++ gnunet/src/fs/fs_tree.c     2013-09-11 22:45:57 UTC (rev 29220)
@@ -429,7 +429,11 @@
 GNUNET_FS_tree_encoder_finish (struct GNUNET_FS_TreeEncoder *te,
                                struct GNUNET_FS_Uri **uri, char **emsg)
 {
-  (void) te->reader (te->cls, UINT64_MAX, 0, 0, NULL);
+  if (NULL != te->reader)
+  {
+    (void) te->reader (te->cls, UINT64_MAX, 0, 0, NULL);
+    te->reader =  NULL;
+  }
   GNUNET_assert (GNUNET_NO == te->in_next);
   if (uri != NULL)
     *uri = te->uri;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]