GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
{
/* terminate helper */
if (NULL != ds->helper)
- GNUNET_HELPER_stop (ds->helper);
+ GNUNET_HELPER_stop (ds->helper, GNUNET_NO);
/* free resources */
if (NULL != ds->toplevel)
struct GNUNET_FS_DirScanner *ds = cls;
ds->stop_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_HELPER_stop (ds->helper);
- ds->helper = NULL;
+ if (NULL != ds->helper)
+ {
+ GNUNET_HELPER_stop (ds->helper, GNUNET_NO);
+ ds->helper = NULL;
+ }
ds->progress_callback (ds->progress_callback_cls,
NULL, GNUNET_SYSERR,
GNUNET_FS_DIRSCANNER_FINISHED);
* @param client always NULL
* @param msg message from the helper process
*/
-static void
+static int
process_helper_msgs (void *cls,
void *client,
const struct GNUNET_MessageHeader *msg)
const char *filename;
size_t left;
+#if 0
+ fprintf (stderr, "DMS parses %u-byte message of type %u\n",
+ (unsigned int) ntohs (msg->size),
+ (unsigned int) ntohs (msg->type));
+#endif
left = ntohs (msg->size) - sizeof (struct GNUNET_MessageHeader);
filename = (const char*) &msg[1];
switch (ntohs (msg->type))
else
(void) expand_tree (ds->pos,
filename, GNUNET_NO);
- return;
+ return GNUNET_OK;
case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY:
if (filename[left-1] != '\0')
{
break;
}
ds->pos = ds->pos->parent;
- return;
+ return GNUNET_OK;
}
ds->progress_callback (ds->progress_callback_cls,
filename, GNUNET_YES,
filename, GNUNET_YES);
if (NULL == ds->toplevel)
ds->toplevel = ds->pos;
- return;
+ return GNUNET_OK;
case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR:
break;
case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_SKIP_FILE:
- if (filename[left-1] != '\0')
+ if ('\0' != filename[left-1])
break;
ds->progress_callback (ds->progress_callback_cls,
filename, GNUNET_SYSERR,
GNUNET_FS_DIRSCANNER_FILE_IGNORED);
- return;
+ return GNUNET_OK;
case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE:
if (0 != left)
{
NULL, GNUNET_SYSERR,
GNUNET_FS_DIRSCANNER_ALL_COUNTED);
ds->pos = ds->toplevel;
- if (ds->pos->is_directory == GNUNET_YES)
+ if (GNUNET_YES == ds->pos->is_directory)
ds->pos = advance (ds->pos);
- return;
+ return GNUNET_OK;
case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA:
{
size_t nlen;
}
ds->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (ds->pos->meta);
ds->pos = advance (ds->pos);
- return;
+ return GNUNET_OK;
}
case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED:
if (NULL != ds->pos)
}
ds->stop_task = GNUNET_SCHEDULER_add_now (&finish_scan,
ds);
- return;
+ return GNUNET_OK;
default:
GNUNET_break (0);
break;
ds->progress_callback (ds->progress_callback_cls,
NULL, GNUNET_SYSERR,
GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);
+ return GNUNET_OK;
+}
+
+
+/**
+ * Function called if our helper process died.
+ *
+ * @param cls the 'struct GNUNET_FS_DirScanner' callback.
+ */
+static void
+helper_died_cb (void *cls)
+{
+ struct GNUNET_FS_DirScanner *ds = cls;
+
+ ds->helper = NULL;
+ if (GNUNET_SCHEDULER_NO_TASK != ds->stop_task)
+ return; /* normal death, was finished */
+ ds->progress_callback (ds->progress_callback_cls,
+ NULL, GNUNET_SYSERR,
+ GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);
}
ds->args[1] = ds->filename_expanded;
ds->args[2] = ds->ex_arg;
ds->args[3] = NULL;
- ds->helper = GNUNET_HELPER_start ("gnunet-helper-fs-publish",
+ ds->helper = GNUNET_HELPER_start (GNUNET_NO,
+ "gnunet-helper-fs-publish",
ds->args,
&process_helper_msgs,
- ds);
+ &helper_died_cb, ds);
if (NULL == ds->helper)
- {
+ {
GNUNET_free (filename_expanded);
GNUNET_free (ds);
return NULL;