fixing publish persist test
authorChristian Grothoff <christian@grothoff.org>
Thu, 6 May 2010 13:30:17 +0000 (13:30 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 6 May 2010 13:30:17 +0000 (13:30 +0000)
src/fs/Makefile.am
src/fs/fs.c
src/fs/test_fs_publish.c
src/fs/test_fs_publish_persistence.c

index 57d41c82405f9a0add473e8a94f709ee5f02baf6..364172ec0d86b745126a348744338b0c1430e257 100644 (file)
@@ -152,6 +152,7 @@ TESTS = $(check_SCRIPTS) \
  test_fs_list_indexed \
  test_fs_namespace \
  test_fs_publish \
+ test_fs_publish_persistence \
  test_fs_search \
  test_fs_start_stop \
  test_fs_unindex \
index 78d29dff1cee9a5158ff396500f57da9d57936e9..f7d6a8dcd91df39af98147bc1515a319bc1c2d09 100644 (file)
@@ -1240,7 +1240,10 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation * fi)
           (GNUNET_OK !=
            GNUNET_BIO_write (wh, fi->data.dir.dir_data, (uint32_t) fi->data.dir.dir_size)) ||
           (GNUNET_OK !=
-           GNUNET_BIO_write_string (wh, fi->data.dir.entries->serialization)) )
+           GNUNET_BIO_write_string (wh, 
+                                    (fi->data.dir.entries == NULL) 
+                                    ?  NULL
+                                    : fi->data.dir.entries->serialization)) )
        {
          GNUNET_break (0);
          goto cleanup;
index 20e65aeace78ebb40062f13cbc42d1ead8cc6419..7df42a26f7246b129747162bffc34f0d26559c82 100644 (file)
@@ -67,8 +67,6 @@ static struct GNUNET_FS_Handle *fs;
 
 static struct GNUNET_FS_PublishContext *publish;
 
-static struct GNUNET_FS_PublishContext *publish;
-
 static char *fn1;
 
 static char *fn2;
@@ -103,12 +101,12 @@ progress_cb (void *cls,
       ret = event->value.publish.cctx;
       printf ("Publish complete,  %llu kbps.\n",
              (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024));
-      if (0 == strcmp ("list_indexed-context-dir", 
+      if (0 == strcmp ("publish-context-dir", 
                       event->value.publish.cctx))      
        GNUNET_SCHEDULER_add_continuation (sched,
                                           &abort_publish_task,
                                           NULL,
-                                          GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+                                          GNUNET_SCHEDULER_REASON_PREREQ_DONE);        
       break;
     case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
       ret = event->value.publish.cctx;
@@ -127,12 +125,16 @@ progress_cb (void *cls,
               "Error publishing file: %s\n",
               event->value.publish.specifics.error.message);
       err = 1;
-      if (0 == strcmp ("list_indexed-context-dir", 
+      if (0 == strcmp ("publish-context-dir", 
                       event->value.publish.cctx))              
-       GNUNET_SCHEDULER_add_continuation (sched,
-                                          &abort_publish_task,
-                                          NULL,
-                                          GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+       {
+         fprintf (stderr, "Scheduling abort task for error on `%s'\n",
+                  (const char*) event->value.publish.cctx);
+         GNUNET_SCHEDULER_add_continuation (sched,
+                                            &abort_publish_task,
+                                            NULL,
+                                            GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+       }
       break;
     case GNUNET_FS_STATUS_PUBLISH_START:
       ret = event->value.publish.cctx;
@@ -164,15 +166,9 @@ progress_cb (void *cls,
        GNUNET_assert (0);
       break;
     case GNUNET_FS_STATUS_PUBLISH_STOPPED:
-      if (0 == strcmp ("list_indexed-context-dir", 
+      if (0 == strcmp ("publish-context-dir", 
                       event->value.publish.cctx))      
-       {
-         GNUNET_assert (publish == event->value.publish.sc);
-         GNUNET_SCHEDULER_add_continuation (sched,
-                                            &abort_publish_task,
-                                            NULL,
-                                            GNUNET_SCHEDULER_REASON_PREREQ_DONE);
-       }
+       GNUNET_assert (publish == event->value.publish.sc);     
       break;
     default:
       printf ("Unexpected event: %d\n", 
index eb4002bbe96f59eadac7ff6e81bb053820394ac1..3e59d92be1984c4ae3bc8872004137c8180546c7 100644 (file)
@@ -149,7 +149,7 @@ progress_cb (void *cls,
       ret = event->value.publish.cctx;
       printf ("Publish complete,  %llu kbps.\n",
              (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024));
-      if (0 == strcmp ("list_indexed-context-dir", 
+      if (0 == strcmp ("publish-context-dir", 
                       event->value.publish.cctx))      
        GNUNET_SCHEDULER_add_continuation (sched,
                                           &abort_publish_task,
@@ -168,13 +168,24 @@ progress_cb (void *cls,
              (unsigned long long) event->value.publish.specifics.progress.offset);
 #endif
       break;
+    case GNUNET_FS_STATUS_PUBLISH_SUSPEND:
+      if  (event->value.publish.sc == publish)
+       publish = NULL;
+      break;
+    case GNUNET_FS_STATUS_PUBLISH_RESUME:
+      if (NULL == publish)
+       {
+         publish = event->value.publish.sc;
+         return "publish-context-dir";
+       }
+      break;
     case GNUNET_FS_STATUS_PUBLISH_ERROR:
       ret = event->value.publish.cctx;
       fprintf (stderr,
               "Error publishing file: %s\n",
               event->value.publish.specifics.error.message);
       err = 1;
-      if (0 == strcmp ("list_indexed-context-dir", 
+      if (0 == strcmp ("publish-context-dir", 
                       event->value.publish.cctx))              
        GNUNET_SCHEDULER_add_continuation (sched,
                                           &abort_publish_task,
@@ -183,6 +194,7 @@ progress_cb (void *cls,
       break;
     case GNUNET_FS_STATUS_PUBLISH_START:
       consider_restart (event->status);
+      publish = event->value.publish.sc;
       ret = event->value.publish.cctx;
       if (0 == strcmp ("publish-context1", 
                       event->value.publish.cctx))
@@ -213,15 +225,9 @@ progress_cb (void *cls,
       break;
     case GNUNET_FS_STATUS_PUBLISH_STOPPED:
       consider_restart (event->status);
-      if (0 == strcmp ("list_indexed-context-dir", 
+      if (0 == strcmp ("publish-context-dir", 
                       event->value.publish.cctx))      
-       {
-         GNUNET_assert (publish == event->value.publish.sc);
-         GNUNET_SCHEDULER_add_continuation (sched,
-                                            &abort_publish_task,
-                                            NULL,
-                                            GNUNET_SCHEDULER_REASON_PREREQ_DONE);
-       }
+       GNUNET_assert (publish == event->value.publish.sc);
       break;
     default:
       printf ("Unexpected event: %d\n", 
@@ -348,10 +354,10 @@ run (void *cls,
   GNUNET_CONTAINER_meta_data_destroy (meta);
   GNUNET_assert (NULL != fidir);
   start = GNUNET_TIME_absolute_get ();
-  publish = GNUNET_FS_publish_start (fs,
-                                    fidir,
-                                    NULL, NULL, NULL,
-                                    GNUNET_FS_PUBLISH_OPTION_NONE);
+  GNUNET_FS_publish_start (fs,
+                          fidir,
+                          NULL, NULL, NULL,
+                          GNUNET_FS_PUBLISH_OPTION_NONE);
   GNUNET_assert (publish != NULL);
 }