fixes
authorChristian Grothoff <christian@grothoff.org>
Fri, 14 May 2010 15:35:57 +0000 (15:35 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 14 May 2010 15:35:57 +0000 (15:35 +0000)
src/fs/fs_publish.c
src/fs/fs_test_lib_data.conf
src/fs/gnunet-service-fs.c
src/fs/test_fs_download.c
src/fs/test_gnunet_service_fs_p2p.c

index 4e2039ba099ee2c12ac1c13c5f8bae02f193b2d0..4d93579bd227bd16b8ecf008ec958971626ea5e3 100644 (file)
@@ -117,6 +117,7 @@ publish_cleanup (void *cls,
                 const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_FS_PublishContext *pc = cls;
+
   GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL);
   if (pc->namespace != NULL)
     GNUNET_FS_namespace_delete (pc->namespace, GNUNET_NO);
@@ -124,7 +125,10 @@ publish_cleanup (void *cls,
   GNUNET_free_non_null (pc->nuid);
   GNUNET_free_non_null (pc->serialization);
   if (pc->dsh != NULL)
-    GNUNET_DATASTORE_disconnect (pc->dsh, GNUNET_NO);
+    {
+      GNUNET_DATASTORE_disconnect (pc->dsh, GNUNET_NO);
+      pc->dsh = NULL;
+    }
   if (pc->client != NULL)
     GNUNET_CLIENT_disconnect (pc->client, GNUNET_NO);
   GNUNET_free (pc);
@@ -997,6 +1001,11 @@ fip_signal_suspend(void *cls,
   pi.status = GNUNET_FS_STATUS_PUBLISH_SUSPEND;
   GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, sc, fi, off));
   *client_info = NULL;
+  if (NULL != sc->dsh)
+    {
+      GNUNET_DATASTORE_disconnect (sc->dsh, GNUNET_NO);
+      sc->dsh = NULL;
+    }
   return GNUNET_OK;
 }
 
@@ -1021,12 +1030,10 @@ GNUNET_FS_publish_signal_suspend_ (void *cls)
                                      &fip_signal_suspend,
                                      pc);
   GNUNET_FS_end_top (pc->h, pc->top);
-  GNUNET_SCHEDULER_add_continuation (pc->h->sched,                                      
-                                    &publish_cleanup,
-                                    pc,
-                                    GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+  publish_cleanup (pc, NULL);
 }
 
+
 /**
  * Publish a file or directory.
  *
@@ -1152,6 +1159,11 @@ void
 GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc)
 {
   GNUNET_FS_end_top (pc->h, pc->top);
+  if (NULL != pc->dsh)
+    {
+      GNUNET_DATASTORE_disconnect (pc->dsh, GNUNET_NO);
+      pc->dsh = NULL;
+    }
   if (GNUNET_SCHEDULER_NO_TASK != pc->upload_task)
     {
       GNUNET_SCHEDULER_cancel (pc->h->sched, pc->upload_task);
@@ -1171,10 +1183,7 @@ GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc)
       pc->in_network_wait = GNUNET_SYSERR;
       return;
     }
-  GNUNET_SCHEDULER_add_continuation (pc->h->sched,                                      
-                                    &publish_cleanup,
-                                    pc,
-                                    GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+  publish_cleanup (pc, NULL);
 }
 
 
@@ -1285,7 +1294,11 @@ kb_put_cont (void *cls,
 
   if (GNUNET_OK != success)
     {
-      GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
+      if (NULL != pkc->dsh)
+       {
+         GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
+         pkc->dsh = NULL;
+       }
       GNUNET_free (pkc->cpy);
       GNUNET_free (pkc->kb);
       pkc->cont (pkc->cont_cls,
@@ -1326,7 +1339,10 @@ publish_ksk_cont (void *cls,
        (NULL == pkc->dsh) )
     {
       if (NULL != pkc->dsh)
-       GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
+       {
+         GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
+         pkc->dsh = NULL;
+       }
       GNUNET_free (pkc->cpy);
       GNUNET_free (pkc->kb);
       pkc->cont (pkc->cont_cls,
@@ -1452,7 +1468,10 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
       GNUNET_break (0);
       GNUNET_free (pkc->kb);
       if (pkc->dsh != NULL)
-       GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
+       {
+         GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
+         pkc->dsh = NULL;
+       }
       cont (cont_cls, NULL, _("Internal error."));
       GNUNET_free (pkc);
       return;
@@ -1518,7 +1537,10 @@ sb_put_cont (void *cls,
   struct PublishSksContext *psc = cls;
 
   if (NULL != psc->dsh)
-    GNUNET_DATASTORE_disconnect (psc->dsh, GNUNET_NO);
+    {
+      GNUNET_DATASTORE_disconnect (psc->dsh, GNUNET_NO);
+      psc->dsh = NULL;
+    }
   if (GNUNET_OK != success)
     psc->cont (psc->cont_cls,
               NULL,
@@ -1685,7 +1707,6 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
                        GNUNET_CONSTANTS_SERVICE_TIMEOUT,
                        &sb_put_cont,
                        psc);
-
   GNUNET_free (sb);
   GNUNET_free (sb_enc);
 }
index d65bce262f65b6a870264cb3501c58e7ddf8f14b..e7fea54506a2980e2f7dd5355e5dd419a10a56b2 100644 (file)
@@ -20,7 +20,7 @@ HOSTNAME = localhost
 DEFAULTSERVICES = 
 
 [datastore]
-#DEBUG = YES
+DEBUG = YES
 #PREFIX = valgrind --tool=memcheck --leak-check=yes
 #BINARY = /home/grothoff/bin/gnunet-service-datastore
 
@@ -52,7 +52,7 @@ TOTAL_QUOTA_OUT = 3932160
 PORT = 43471
 HOSTNAME = localhost
 #OPTIONS = -L DEBUG
-DEBUG = YES
+DEBUG = YES
 #PREFIX = valgrind --tool=memcheck --leak-check=yes
 #BINARY = /home/grothoff/bin/gnunet-service-fs
 #PREFIX = xterm -e gdb -x cmd --args 
index e85d99cfd8d29254acb1042e7c5cfed88e8d31f4..124bab521f594ed4983b0df2762abe4426fa3d5b 100644 (file)
@@ -2270,6 +2270,7 @@ process_local_reply (void *cls,
                                            anonymity, expiration, uid, 
                                            &process_local_reply,
                                            pr))
+      if (pr->qe != NULL)
        GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
       return;
     }
@@ -2291,7 +2292,8 @@ process_local_reply (void *cls,
                                gettext_noop ("# results filtered by query bloomfilter"),
                                1,
                                GNUNET_NO);
-      GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
+      if (pr->qe != NULL)
+       GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
       return;
     }
 #if DEBUG_FS
@@ -2332,7 +2334,8 @@ process_local_reply (void *cls,
   if ( (type == GNUNET_BLOCK_TYPE_DBLOCK) ||
        (type == GNUNET_BLOCK_TYPE_IBLOCK) ) 
     {
-      GNUNET_DATASTORE_get_next (dsh, GNUNET_NO);
+      if (pr->qe != NULL)
+       GNUNET_DATASTORE_get_next (dsh, GNUNET_NO);
       return;
     }
   if ( (pr->client_request_list == NULL) &&
@@ -2347,10 +2350,12 @@ process_local_reply (void *cls,
                                gettext_noop ("# processing result set cut short due to load"),
                                1,
                                GNUNET_NO);
-      GNUNET_DATASTORE_get_next (dsh, GNUNET_NO);
+      if (pr->qe != NULL)
+       GNUNET_DATASTORE_get_next (dsh, GNUNET_NO);
       return;
     }
-  GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
+  if (pr->qe != NULL)
+    GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
 }
 
 
index 0680952691fb53963a3ee6a9c6371cd1818a2da5..fdd0452c28b696f46adf5ca35e9f4e58f256a5bb 100644 (file)
@@ -103,6 +103,13 @@ abort_publish_task (void *cls,
     }
 }
 
+static void
+stop_fs_task (void *cls,
+             const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  GNUNET_FS_stop (fs);
+  fs = NULL;
+}
 
 static void
 abort_download_task (void *cls,
@@ -207,8 +214,9 @@ progress_cb (void *cls,
       GNUNET_assert (publish == event->value.publish.sc);
       GNUNET_assert (FILESIZE == event->value.publish.size);
       GNUNET_assert (1 == event->value.publish.anonymity);
-      GNUNET_FS_stop (fs);
-      fs = NULL;
+      GNUNET_SCHEDULER_add_now (sched,
+                               &stop_fs_task,
+                               NULL);
       break;
     case GNUNET_FS_STATUS_DOWNLOAD_START:
       GNUNET_assert (download == NULL);
index 7e3e02c7626a9b1c4a020a6f41f7e98c5787e8bc..92ac44dcc297fdc48caa32e8781f3b31f51648c5 100644 (file)
@@ -26,7 +26,7 @@
 #include "platform.h"
 #include "fs_test_lib.h"
 
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
 
 /**
  * File-size we use for testing.