-round expiration times to full seconds
[oweals/gnunet.git] / src / fs / test_fs_search_probes.c
index e69251d40c96fc532b3dc9431fcea335d65b1c1d..380c857aa7868d0b6bbaa4b9e83c689594ea3d89 100644 (file)
@@ -25,7 +25,7 @@
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
-#include "gnunet_testing_lib-new.h"
+#include "gnunet_testing_lib.h"
 #include "gnunet_fs_service.h"
 
 
@@ -53,12 +53,44 @@ static struct GNUNET_FS_SearchContext *search;
 
 static struct GNUNET_FS_PublishContext *publish;
 
+static GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+
+static int err;
+
+
+static void
+abort_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  timeout_task = GNUNET_SCHEDULER_NO_TASK;
+  fprintf (stderr,
+          "Timeout\n");
+  if (NULL != search)
+  {
+    GNUNET_FS_search_stop (search);
+    search = NULL;
+  }
+  if (NULL != publish)
+  {
+    GNUNET_FS_publish_stop (publish);
+    publish = NULL;
+  }
+  err = 1;
+}
+
 
 static void
 abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  GNUNET_FS_publish_stop (publish);
-  publish = NULL;
+  if (NULL != publish)
+  {
+    GNUNET_FS_publish_stop (publish);
+    publish = NULL;
+  }
+  if (GNUNET_SCHEDULER_NO_TASK != timeout_task)
+  {
+    GNUNET_SCHEDULER_cancel (timeout_task);
+    timeout_task = GNUNET_SCHEDULER_NO_TASK;
+  }
 }
 
 
@@ -194,6 +226,8 @@ run (void *cls,
       GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL,
                                GNUNET_FS_PUBLISH_OPTION_NONE);
   GNUNET_assert (publish != NULL);
+  timeout_task = GNUNET_SCHEDULER_add_delayed (LIFETIME,
+                                              &abort_error, NULL);
 }
 
 
@@ -204,7 +238,7 @@ main (int argc, char *argv[])
                                    "test_fs_search_data.conf",
                                    &run, NULL))
     return 1;
-  return 0;
+  return err;
 }
 
 /* end of test_fs_search_probes.c */