* for this upload.
*/
int rid;
+
+ /**
+ * Set to GNUNET_YES if all processing has completed.
+ */
+ int all_done;
};
char **emsg)
{
char *data = cls;
+
if (max == 0)
{
GNUNET_free (data);
ret->data.file.reader = reader;
ret->data.file.reader_cls = reader_cls;
ret->data.file.do_index = do_index;
+ ret->data.file.file_size = length;
ret->anonymity = anonymity;
ret->priority = priority;
GNUNET_FS_file_information_sync (ret);
GNUNET_FS_file_information_destroy (pos, cleaner, cleaner_cls);
}
/* clean up client-info */
- cleaner (cleaner_cls,
- fi,
- fi->data.dir.dir_size,
- fi->meta,
- &fi->keywords,
- &fi->anonymity,
- &fi->priority,
- &fi->expirationTime,
- &fi->client_info);
+ if (NULL != cleaner)
+ cleaner (cleaner_cls,
+ fi,
+ fi->data.dir.dir_size,
+ fi->meta,
+ &fi->keywords,
+ &fi->anonymity,
+ &fi->priority,
+ &fi->expirationTime,
+ &fi->client_info);
GNUNET_free_non_null (fi->data.dir.dir_data);
GNUNET_free (fi->data.dir.dirname);
}
/* call clean-up function of the reader */
fi->data.file.reader (fi->data.file.reader_cls, 0, 0, NULL, NULL);
/* clean up client-info */
- cleaner (cleaner_cls,
- fi,
- fi->data.file.file_size,
- fi->meta,
- &fi->keywords,
- &fi->anonymity,
- &fi->priority,
- &fi->expirationTime,
- &fi->client_info);
+ if (NULL != cleaner)
+ cleaner (cleaner_cls,
+ fi,
+ fi->data.file.file_size,
+ fi->meta,
+ &fi->keywords,
+ &fi->anonymity,
+ &fi->priority,
+ &fi->expirationTime,
+ &fi->client_info);
}
GNUNET_free_non_null (fi->emsg);
/* clean up serialization */
- if (0 != UNLINK (fi->serialization))
+ if ( (NULL != fi->serialization) &&
+ (0 != UNLINK (fi->serialization)) )
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
"unlink",
fi->serialization);
GNUNET_FS_uri_destroy (fi->keywords);
GNUNET_CONTAINER_meta_data_destroy (fi->meta);
- GNUNET_free (fi->serialization);
+ GNUNET_free_non_null (fi->serialization);
GNUNET_free (fi);
}
publish_cleanup (struct GNUNET_FS_PublishContext *sc)
{
GNUNET_FS_file_information_destroy (sc->fi, NULL, NULL);
- GNUNET_FS_namespace_delete (sc->namespace, GNUNET_NO);
+ if (sc->namespace != NULL)
+ GNUNET_FS_namespace_delete (sc->namespace, GNUNET_NO);
GNUNET_free_non_null (sc->nid);
GNUNET_free_non_null (sc->nuid);
GNUNET_DATASTORE_disconnect (sc->dsh, GNUNET_NO);
pcc->p->client_info
= pcc->sc->h->upcb (pcc->sc->h->upcb_cls,
&pi);
- return;
}
GNUNET_FS_file_information_sync (pcc->p);
if (NULL != pcc->cont)
}
// FIXME: release the datastore reserve here!
signal_publish_completion (sc->fi, sc);
+ sc->all_done = GNUNET_YES;
}
{
pt_size = GNUNET_MIN(max,
p->data.file.file_size - offset);
+ if (pt_size == 0)
+ return 0; /* calling reader with pt_size==0
+ might free buf, so don't! */
if (pt_size !=
p->data.file.reader (p->data.file.reader_cls,
offset,
dpc_cls = GNUNET_malloc(sizeof(struct PutContCtx));
dpc_cls->cont = &do_upload;
dpc_cls->cont_cls = sc;
+ dpc_cls->sc = sc;
dpc_cls->p = p;
if ( (p->is_directory) &&
(p->data.file.do_index) &&
= sc->h->upcb (sc->h->upcb_cls,
&pi);
}
+ sc->all_done = GNUNET_YES;
return;
}
/* handle completion */
* Stop an upload. Will abort incomplete uploads (but
* not remove blocks that have already been publishd) or
* simply clean up the state for completed uploads.
+ * Must NOT be called from within the event callback!
*
* @param sc context for the upload to stop
*/
{
if (GNUNET_SCHEDULER_NO_TASK != sc->upload_task)
GNUNET_SCHEDULER_cancel (sc->h->sched, sc->upload_task);
+ else
+ GNUNET_assert (sc->all_done == GNUNET_YES);
// FIXME: remove from persistence DB (?) --- think more about
// shutdown / persistent-resume APIs!!!
GNUNET_FS_file_information_inspect (sc->fi,
{
struct GNUNET_FS_TreeEncoder *te;
+ GNUNET_assert (size > 0);
te = GNUNET_malloc (sizeof (struct GNUNET_FS_TreeEncoder));
te->h = h;
te->size = size;
static char *fn;
+static void
+abort_download_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_FS_download_stop (download, GNUNET_YES);
+ download = NULL;
+}
+
+
+static void
+abort_publish_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_FS_publish_stop (publish);
+ publish = NULL;
+}
+
+
static void *
progress_cb (void *cls,
const struct GNUNET_FS_ProgressInfo *event)
switch (event->status)
{
- case GNUNET_FS_STATUS_DOWNLOAD_SUSPEND:
- GNUNET_break (0);
- break;
- case GNUNET_FS_STATUS_DOWNLOAD_RESUME:
- GNUNET_break (0);
- break;
case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
-#if DEBUG_VERBOSE > 1
+#if DEBUG_VERBOSE
printf ("Publish is progressing (%llu/%llu)...\n",
(unsigned long long) event->value.publish.completed,
(unsigned long long) event->value.publish.size);
download = NULL;
break;
case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
-#if DEBUG_VERBOSE > 1
+#if DEBUG_VERBOSE
printf ("Download is progressing (%llu/%llu)...\n",
(unsigned long long) event->value.download.completed,
(unsigned long long) event->value.download.size);
#endif
break;
- case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
- GNUNET_break (0);
- break;
- case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
- GNUNET_break (0);
- break;
- case GNUNET_FS_STATUS_UNINDEX_ERROR:
- GNUNET_break (0);
case GNUNET_FS_STATUS_PUBLISH_ERROR:
+ fprintf (stderr,
+ "Error publishing file: %s\n",
+ event->value.publish.specifics.error.message);
GNUNET_break (0);
- case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
- GNUNET_break (0);
- break;
- case GNUNET_FS_STATUS_UNINDEX_SUSPEND:
- GNUNET_break (0);
+ GNUNET_SCHEDULER_add_continuation (sched,
+ GNUNET_NO,
+ &abort_publish_task,
+ NULL,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
- case GNUNET_FS_STATUS_PUBLISH_SUSPEND:
- GNUNET_break (0);
+ case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
+ fprintf (stderr,
+ "Error downloading file: %s\n",
+ event->value.download.specifics.error.message);
+ GNUNET_SCHEDULER_add_continuation (sched,
+ GNUNET_NO,
+ &abort_download_task,
+ NULL,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
case GNUNET_FS_STATUS_PUBLISH_START:
/* FIXME: add checks here... */
+ break;
case GNUNET_FS_STATUS_PUBLISH_STOPPED:
/* FIXME: add checks here... */
+ break;
case GNUNET_FS_STATUS_DOWNLOAD_START:
/* FIXME: add checks here... */
break;
GNUNET_FS_stop (fs);
fs = NULL;
break;
- case GNUNET_FS_STATUS_UNINDEX_START:
- GNUNET_break (0);
- break;
- case GNUNET_FS_STATUS_UNINDEX_STOPPED:
- GNUNET_break (0);
- break;
default:
printf ("Unexpected event: %d\n",
event->status);
[arm]
PORT = 42466
HOSTNAME = localhost
+DEFAULTSERVICES = resolver datastore transport core fs
[statistics]
PORT = 42467
* Stop an upload. Will abort incomplete uploads (but
* not remove blocks that have already been publishd) or
* simply clean up the state for completed uploads.
+ * Must NOT be called from within the event callback!
*
* @param sc context for the upload to stop
*/