static const struct GNUNET_CONFIGURATION_Handle *cfg;
+static struct GNUNET_SCHEDULER_Handle *sched;
+
static struct GNUNET_FS_Handle *ctx;
static struct GNUNET_FS_SearchContext *sc;
return GNUNET_OK;
}
+static void
+clean_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_FS_stop (ctx);
+ ctx = NULL;
+}
+
/**
* Called by FS client to give information about the progress of an
fprintf (stderr,
_("Error searching: %s.\n"),
info->value.search.specifics.error.message);
- GNUNET_FS_search_stop (sc);
+ GNUNET_SCHEDULER_shutdown (sched);
break;
case GNUNET_FS_STATUS_SEARCH_STOPPED:
- GNUNET_FS_stop (ctx);
+ sc = NULL;
+ GNUNET_SCHEDULER_add_continuation (sched,
+ &clean_task,
+ NULL,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
default:
fprintf (stderr,
}
+static void
+shutdown_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ if (sc != NULL)
+ {
+ GNUNET_FS_search_stop (sc);
+ sc = NULL;
+ }
+}
+
+
/**
* Main function that will be run by the scheduler.
*
*/
static void
run (void *cls,
- struct GNUNET_SCHEDULER_Handle *sched,
+ struct GNUNET_SCHEDULER_Handle *s,
char *const *args,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
struct GNUNET_FS_Uri *uri;
unsigned int argc;
+ sched = s;
argc = 0;
while (NULL != args[argc])
argc++;
{
fprintf (stderr,
_("Could not start searching.\n"));
+ GNUNET_FS_stop (ctx);
ret = 1;
return;
}
+ GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &shutdown_task,
+ NULL);
}