-only trigger check config if we actually need it
[oweals/gnunet.git] / src / fs / gnunet-search.c
index 9065922e14657f0309de4eb7eb1e5ef8ca9d3a95..0ddcd892ee76a15b2635bd86043280a1ac117e61 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
      You should have received a copy of the GNU General Public License
      along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
 */
 /**
  * @file fs/gnunet-search.c
@@ -55,6 +55,9 @@ static int verbose;
 
 static int local_only;
 
+static struct GNUNET_SCHEDULER_Task *tt;
+
+
 /**
  * Type of a function that libextractor calls for each
  * meta data item found.
@@ -96,7 +99,7 @@ item_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type,
 
 
 static void
-clean_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+clean_task (void *cls)
 {
   size_t dsize;
   void *ddata;
@@ -199,8 +202,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
     GNUNET_SCHEDULER_shutdown ();
     break;
   case GNUNET_FS_STATUS_SEARCH_STOPPED:
-    GNUNET_SCHEDULER_add_continuation (&clean_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&clean_task, NULL);
     break;
   default:
     FPRINTF (stderr, _("Unexpected status: %d\n"), info->status);
@@ -211,7 +213,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
 
 
 static void
-shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
 {
   if (sc != NULL)
   {
@@ -221,6 +223,14 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 }
 
 
+static void
+timeout_task (void *cls)
+{
+  tt = NULL;
+  GNUNET_SCHEDULER_shutdown ();
+}
+
+
 /**
  * Main function that will be run by the scheduler.
  *
@@ -273,10 +283,11 @@ run (void *cls, char *const *args, const char *cfgfile,
     return;
   }
   if (0 != timeout.rel_value_us)
-    GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_task, NULL);
-  else
-    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
-                                  NULL);
+    tt = GNUNET_SCHEDULER_add_delayed (timeout,
+                                      &timeout_task,
+                                      NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+                                NULL);
 }