+ if (sks_search == NULL)
+ return;
+ GNUNET_FS_search_stop (sks_search);
+ sks_search = NULL;
+ ns = GNUNET_FS_namespace_create (fs, "testNamespace");
+ GNUNET_assert (NULL != ns);
+ GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_YES));
+ if (ksk_search == NULL)
+ {
+ GNUNET_FS_stop (fs);
+ if (GNUNET_SCHEDULER_NO_TASK != kill_task)
+ GNUNET_SCHEDULER_cancel (kill_task);
+ }
+}
+
+
+static void
+do_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ fprintf (stderr, "Operation timed out\n");
+ kill_task = GNUNET_SCHEDULER_NO_TASK;
+ abort_sks_search_task (NULL, tc);
+ abort_ksk_search_task (NULL, tc);
+}
+
+
+
+static void *
+progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
+{
+ switch (event->status)
+ {
+ case GNUNET_FS_STATUS_SEARCH_RESULT:
+ if (sks_search == event->value.search.sc)
+ {
+ if (!GNUNET_FS_uri_test_equal
+ (sks_expect_uri, event->value.search.specifics.result.uri))
+ {
+ fprintf (stderr, "Wrong result for sks search!\n");
+ err = 1;
+ }
+ /* give system 1ms to initiate update search! */
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
+ &abort_sks_search_task, NULL);
+ }
+ else if (ksk_search == event->value.search.sc)
+ {
+ if (!GNUNET_FS_uri_test_equal
+ (ksk_expect_uri, event->value.search.specifics.result.uri))
+ {
+ fprintf (stderr, "Wrong result for ksk search!\n");
+ err = 1;
+ }
+ GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ }
+ else
+ {
+ fprintf (stderr, "Unexpected search result received!\n");
+ GNUNET_break (0);
+ }
+ break;
+ case GNUNET_FS_STATUS_SEARCH_ERROR:
+ fprintf (stderr, "Error searching file: %s\n",
+ event->value.search.specifics.error.message);
+ if (sks_search == event->value.search.sc)
+ GNUNET_SCHEDULER_add_continuation (&abort_sks_search_task, NULL,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ else if (ksk_search == event->value.search.sc)
+ GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ else
+ GNUNET_break (0);
+ break;
+ case GNUNET_FS_STATUS_SEARCH_START:
+ GNUNET_assert ((NULL == event->value.search.cctx) ||
+ (0 == strcmp ("sks_search", event->value.search.cctx)) ||
+ (0 == strcmp ("ksk_search", event->value.search.cctx)));
+ if (NULL == event->value.search.cctx)
+ {
+ GNUNET_assert (0 == strcmp ("sks_search", event->value.search.pctx));
+ update_started = GNUNET_YES;
+ }
+ GNUNET_assert (1 == event->value.search.anonymity);
+ break;
+ case GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED:
+ return NULL;
+ case GNUNET_FS_STATUS_SEARCH_STOPPED:
+ return NULL;
+ default:
+ fprintf (stderr, "Unexpected event: %d\n", event->status);
+ break;
+ }
+ return event->value.search.cctx;