gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r11229 - gnunet/src/fs
Date: Thu, 6 May 2010 15:30:17 +0200

Author: grothoff
Date: 2010-05-06 15:30:17 +0200 (Thu, 06 May 2010)
New Revision: 11229

Modified:
   gnunet/src/fs/Makefile.am
   gnunet/src/fs/fs.c
   gnunet/src/fs/test_fs_publish.c
   gnunet/src/fs/test_fs_publish_persistence.c
Log:
fixing publish persist test

Modified: gnunet/src/fs/Makefile.am
===================================================================
--- gnunet/src/fs/Makefile.am   2010-05-06 13:29:16 UTC (rev 11228)
+++ gnunet/src/fs/Makefile.am   2010-05-06 13:30:17 UTC (rev 11229)
@@ -152,6 +152,7 @@
  test_fs_list_indexed \
  test_fs_namespace \
  test_fs_publish \
+ test_fs_publish_persistence \
  test_fs_search \
  test_fs_start_stop \
  test_fs_unindex \

Modified: gnunet/src/fs/fs.c
===================================================================
--- gnunet/src/fs/fs.c  2010-05-06 13:29:16 UTC (rev 11228)
+++ gnunet/src/fs/fs.c  2010-05-06 13:30:17 UTC (rev 11229)
@@ -1240,7 +1240,10 @@
           (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;

Modified: gnunet/src/fs/test_fs_publish.c
===================================================================
--- gnunet/src/fs/test_fs_publish.c     2010-05-06 13:29:16 UTC (rev 11228)
+++ gnunet/src/fs/test_fs_publish.c     2010-05-06 13:30:17 UTC (rev 11229)
@@ -67,8 +67,6 @@
 
 static struct GNUNET_FS_PublishContext *publish;
 
-static struct GNUNET_FS_PublishContext *publish;
-
 static char *fn1;
 
 static char *fn2;
@@ -103,12 +101,12 @@
       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 @@
               "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 @@
        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", 

Modified: gnunet/src/fs/test_fs_publish_persistence.c
===================================================================
--- gnunet/src/fs/test_fs_publish_persistence.c 2010-05-06 13:29:16 UTC (rev 
11228)
+++ gnunet/src/fs/test_fs_publish_persistence.c 2010-05-06 13:30:17 UTC (rev 
11229)
@@ -149,7 +149,7 @@
       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 @@
              (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 @@
       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 @@
       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 @@
   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);
 }
 





reply via email to

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