bugs
authorChristian Grothoff <christian@grothoff.org>
Wed, 5 May 2010 13:39:20 +0000 (13:39 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 5 May 2010 13:39:20 +0000 (13:39 +0000)
src/fs/fs.c
src/fs/fs_publish.c
src/fs/fs_unindex.c

index 817b29d7f89d40cc67cd6f49b33aff5b2ae35019..00948916ec83ea4781237500ee66018620ae9ce1 100644 (file)
@@ -424,7 +424,7 @@ get_serialization_file_name (struct GNUNET_FS_Handle *h,
                                               &basename))
     return NULL;
   GNUNET_asprintf (&ret,
-                  "%s%s%s%s%s%s",
+                  "%s%s%s%s%s%s%s",
                   basename,
                   DIR_SEPARATOR_STR,
                   h->client_name,
@@ -466,7 +466,7 @@ get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h,
                                               &basename))
     return NULL;
   GNUNET_asprintf (&ret,
-                  "%s%s%s%s%s%s%s%s",
+                  "%s%s%s%s%s%s%s%s%s",
                   basename,
                   DIR_SEPARATOR_STR,
                   h->client_name,
@@ -524,8 +524,14 @@ get_write_handle (struct GNUNET_FS_Handle *h,
 
   fn = get_serialization_file_name (h, ext, ent);
   if (fn == NULL)
-    return NULL;
+    {
+      return NULL;
+    }
   ret = GNUNET_BIO_write_open (fn);
+  if (ret == NULL)
+    fprintf (stderr,
+            "Failed to create write handle for `%s' from `%s/%s'\n",
+            fn, ext, ent);
   GNUNET_free (fn);
   return ret;
 }
@@ -950,7 +956,7 @@ get_serialization_short_name (const char *fullname)
   nxt = fullname;
   /* FIXME: we could do this faster since we know
      the length of 'end'... */
-  while ('\0' != nxt)
+  while ('\0' != *nxt)
     {
       if (DIR_SEPARATOR == *nxt)
        end = nxt + 1;
@@ -1190,7 +1196,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation * fi)
       goto cleanup;
     }
   if (GNUNET_OK !=
-      GNUNET_BIO_write_string (wh, fi->next->serialization))
+      GNUNET_BIO_write_string (wh, (fi->next != NULL) ? fi->next->serialization : NULL))
     goto cleanup;  
   if (GNUNET_OK ==
       GNUNET_BIO_write_close (wh))
@@ -1429,6 +1435,8 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc)
       return;
     }
   wh = get_write_handle (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, pc->serialization);
+  if (wh == NULL)
+    goto cleanup;
   if ( (GNUNET_OK !=
        GNUNET_BIO_write_string (wh, pc->nid)) ||
        (GNUNET_OK !=
@@ -1483,6 +1491,8 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc)
   if (NULL == uc->serialization)
     return;
   wh = get_write_handle (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, uc->serialization);
+  if (wh == NULL)
+    goto cleanup;
   if ( (GNUNET_OK !=
        GNUNET_BIO_write_string (wh, uc->filename)) ||
        (GNUNET_OK !=
@@ -1736,6 +1746,8 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr)
                                : GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
                                sr->sc->serialization,
                                sr->serialization);
+  if (wh == NULL)
+    goto cleanup;
   uris = GNUNET_FS_uri_to_string (sr->uri);
   if ( (GNUNET_OK !=
        GNUNET_BIO_write_string (wh, uris)) ||
@@ -1804,6 +1816,8 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc)
   if (NULL == sc->serialization)
     return;
   wh = get_write_handle (sc->h, category, sc->serialization);
+  if (wh == NULL)
+    goto cleanup;
   GNUNET_assert ( (GNUNET_YES == GNUNET_FS_uri_test_ksk (sc->uri)) ||
                  (GNUNET_YES == GNUNET_FS_uri_test_sks (sc->uri)) );
   uris = GNUNET_FS_uri_to_string (sc->uri);
index ba2d095334c9a540e457cefaba5f9883cfc5655a..6364dac0ad158ce5fd5d2cc01be25c3cf4bf4ed8 100644 (file)
@@ -557,6 +557,7 @@ publish_content (struct GNUNET_FS_PublishContext *sc)
   uint64_t size;
 
   p = sc->fi_pos;
+  GNUNET_assert (p != NULL);
   if (NULL == p->te)
     {
       if (p->is_directory)
@@ -1062,13 +1063,13 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
       if (NULL != nuid)
        ret->nuid = GNUNET_strdup (nuid);
     }
-  GNUNET_FS_publish_sync_ (ret);
   /* signal start */
   GNUNET_FS_file_information_inspect (ret->fi,
                                      &fip_signal_start,
                                      ret);
   ret->fi_pos = ret->fi;
   ret->top = GNUNET_FS_make_top (h, &publish_signal_suspend, ret);
+  GNUNET_FS_publish_sync_ (ret);
   // FIXME: calculate space needed for "fi"
   // and reserve as first task (then trigger
   // "publish_main" from that continuation)!
index c5502d3fe3be6648bbe985a7ddcc0b99e1574610..d422546ca3328e263517c00be6d4ff27b80299fd 100644 (file)
@@ -454,6 +454,7 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h,
   pi.status = GNUNET_FS_STATUS_UNINDEX_START;
   pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
   GNUNET_FS_unindex_make_status_ (&pi, ret, 0);
+  /* FIXME: must be able to abort hashing here! */
   GNUNET_CRYPTO_hash_file (h->sched,
                           GNUNET_SCHEDULER_PRIORITY_IDLE,
                           filename,
@@ -476,7 +477,12 @@ void
 GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc)
 {  
   struct GNUNET_FS_ProgressInfo pi;
-
+  
+  /* FIXME: stop hashing (if still ongoing) */
+  /* FIXME: disconnect uc->client (if still connected) */
+  /* FIXME: disconnect from datastore (if still connected) */
+  /* FIXME: other termination operations? */
+  /* FIXME: must do same cleanup in 'unindex_signal_suspend'! */
   GNUNET_FS_end_top (uc->h, uc->top);
   if ( (uc->state != UNINDEX_STATE_COMPLETE) &&
        (uc->state != UNINDEX_STATE_ERROR) )