fixing block reconstruction start/shutdown code
[oweals/gnunet.git] / src / fs / fs_namespace.c
index 8e13df9bc5e345346b0fcb99fa69cd81c2c2d6b7..91502e1de2ae030e2ca55809896e9a393e97b741 100644 (file)
@@ -224,7 +224,7 @@ read_update_information_graph (struct GNUNET_FS_Namespace *ns)
          GNUNET_break (0);
          GNUNET_free (emsg);
          GNUNET_free (n->id);
-         GNUNET_free (n->update);
+         GNUNET_free_non_null (n->update);
          GNUNET_CONTAINER_meta_data_destroy (n->md);
          GNUNET_free (n);
          break;
@@ -264,11 +264,6 @@ struct AdvertisementContext
    */
   struct GNUNET_DATASTORE_Handle *dsh;
 
-  /**
-   * Our scheduler.
-   */
-  struct GNUNET_SCHEDULER_Handle *sched;
-
   /**
    * Our KSK URI.
    */ 
@@ -357,11 +352,11 @@ advertisement_cont (void *cls,
   if (GNUNET_OK != success)
     {
       /* error! */
-      GNUNET_SCHEDULER_add_continuation (ac->sched,
-                                        &do_disconnect,
+      GNUNET_SCHEDULER_add_continuation (&do_disconnect,
                                         ac->dsh,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
-      ac->cont (ac->cont_cls, NULL, msg);
+      if (ac->cont != NULL)
+       ac->cont (ac->cont_cls, NULL, msg);
       GNUNET_FS_uri_destroy (ac->ksk_uri);
       GNUNET_free (ac->pt);
       GNUNET_free (ac->nb);
@@ -372,11 +367,11 @@ advertisement_cont (void *cls,
   if (ac->pos == ac->ksk_uri->data.ksk.keywordCount)
     {
       /* done! */
-      GNUNET_SCHEDULER_add_continuation (ac->sched,
-                                        &do_disconnect,
+      GNUNET_SCHEDULER_add_continuation (&do_disconnect,
                                         ac->dsh,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
-      ac->cont (ac->cont_cls, ac->ksk_uri, NULL);
+      if (ac->cont != NULL)
+       ac->cont (ac->cont_cls, ac->ksk_uri, NULL);
       GNUNET_FS_uri_destroy (ac->ksk_uri);
       GNUNET_free (ac->pt);
       GNUNET_free (ac->nb);
@@ -414,7 +409,7 @@ advertisement_cont (void *cls,
                        &query,
                        ac->pt_size + sizeof (struct NBlock),
                        ac->nb,
-                       GNUNET_BLOCK_TYPE_NBLOCK,
+                       GNUNET_BLOCK_TYPE_FS_NBLOCK,
                        ac->priority,
                        ac->anonymity,
                        ac->expiration,
@@ -499,7 +494,7 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h,
   nb->ns_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK);
   nb->ksk_purpose.size = htonl (size - sizeof (struct GNUNET_CRYPTO_RsaSignature));
   nb->ksk_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG);
-  dsh = GNUNET_DATASTORE_connect (h->cfg, h->sched);
+  dsh = GNUNET_DATASTORE_connect (h->cfg);
   if (NULL == dsh)
     {
       GNUNET_free (nb);
@@ -511,7 +506,6 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h,
   ctx->cont = cont;
   ctx->cont_cls = cont_cls;
   ctx->dsh = dsh;
-  ctx->sched = h->sched;
   ctx->ksk_uri = GNUNET_FS_uri_dup (ksk_uri);
   ctx->nb = nb;
   ctx->pt = pt;
@@ -775,9 +769,10 @@ sb_put_cont (void *cls,
     }
   if (GNUNET_OK != success)
     {
-      psc->cont (psc->cont_cls,
-                NULL,
-                msg);
+      if (psc->cont != NULL)
+       psc->cont (psc->cont_cls,
+                  NULL,
+                  msg);
     }
   else
     {
@@ -804,9 +799,10 @@ sb_put_cont (void *cls,
          psc->nsn = NULL;
          write_update_information_graph (psc->namespace);
        }
-      psc->cont (psc->cont_cls,
-                psc->uri,
-                NULL);
+      if (psc->cont != NULL)
+       psc->cont (psc->cont_cls,
+                  psc->uri,
+                  NULL);
     }
   GNUNET_FS_namespace_delete (psc->namespace,
                              GNUNET_NO);
@@ -952,7 +948,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
                   NULL);
       return;
     }
-  psc->dsh = GNUNET_DATASTORE_connect (h->cfg, h->sched);
+  psc->dsh = GNUNET_DATASTORE_connect (h->cfg);
   if (NULL == psc->dsh)
     {
       GNUNET_free (sb_enc);
@@ -978,7 +974,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
                        &sb_enc->identifier,
                        size,
                        sb_enc,
-                       GNUNET_BLOCK_TYPE_SBLOCK, 
+                       GNUNET_BLOCK_TYPE_FS_SBLOCK, 
                        priority,
                        anonymity,
                        expirationTime,