-only trigger check config if we actually need it
[oweals/gnunet.git] / src / fs / gnunet-service-fs_cadet_server.c
index 5e47157815ea26db0c049b77e2857fa42bc3db5c..c9d838fefc6d0c1b4e7079879881d33db14a0962 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2012, 2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2012, 2013 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.
 */
 
 /**
@@ -108,12 +108,12 @@ struct CadetClient
   /**
    * Task that is scheduled to asynchronously terminate the connection.
    */
-  GNUNET_SCHEDULER_TaskIdentifier terminate_task;
+  struct GNUNET_SCHEDULER_Task * terminate_task;
 
   /**
    * Task that is scheduled to terminate idle connections.
    */
-  GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+  struct GNUNET_SCHEDULER_Task * timeout_task;
 
   /**
    * Size of the last write that was initiated.
@@ -154,16 +154,14 @@ static unsigned long long sc_count_max;
  * Task run to asynchronously terminate the cadet due to timeout.
  *
  * @param cls the 'struct CadetClient'
- * @param tc scheduler context
  */
 static void
-timeout_cadet_task (void *cls,
-                    const struct GNUNET_SCHEDULER_TaskContext *tc)
+timeout_cadet_task (void *cls)
 {
   struct CadetClient *sc = cls;
   struct GNUNET_CADET_Channel *tun;
 
-  sc->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+  sc->timeout_task = NULL;
   tun = sc->channel;
   sc->channel = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -181,7 +179,7 @@ timeout_cadet_task (void *cls,
 static void
 refresh_timeout_task (struct CadetClient *sc)
 {
-  if (GNUNET_SCHEDULER_NO_TASK != sc->timeout_task)
+  if (NULL != sc->timeout_task)
     GNUNET_SCHEDULER_cancel (sc->timeout_task);
   sc->timeout_task = GNUNET_SCHEDULER_add_delayed (IDLE_TIMEOUT,
                                                   &timeout_cadet_task,
@@ -324,7 +322,8 @@ continue_writing (struct CadetClient *sc)
 static void
 handle_datastore_reply (void *cls,
                        const struct GNUNET_HashCode *key,
-                       size_t size, const void *data,
+                       size_t size,
+                       const void *data,
                        enum GNUNET_BLOCK_Type type,
                        uint32_t priority,
                        uint32_t anonymity,
@@ -345,19 +344,19 @@ handle_datastore_reply (void *cls,
        hard error as we might have had the answer in the
        past and the user might have unindexed it. Hence
        we log at level "INFO" for now. */
-    if(NULL == key)
+    if (NULL == key)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                   "Have no answer and the query was NULL\n");
     }
     else
     {
-        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                    "Have no answer for query `%s'\n",
-                    GNUNET_h2s (key));
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                 "Have no answer for query `%s'\n",
+                 GNUNET_h2s (key));
     }
     GNUNET_STATISTICS_update (GSF_stats,
-                              gettext_noop ("# queries received via cadet not answered"), 1,
+                              gettext_noop ("# queries received via CADET not answered"), 1,
                               GNUNET_NO);
     continue_writing (sc);
     return;
@@ -414,9 +413,9 @@ handle_datastore_reply (void *cls,
  * Functions with this signature are called whenever a
  * complete query message is received.
  *
- * Do not call #GNUNET_SERVER_mst_destroy in callback
+ * Do not call #GNUNET_SERVER_mst_destroy() in callback
  *
- * @param cls closure with the 'struct CadetClient'
+ * @param cls closure with the `struct CadetClient`
  * @param channel channel handle
  * @param channel_ctx channel context
  * @param message the actual message
@@ -446,7 +445,6 @@ request_cb (void *cls,
                                     ntohl (sqm->type),
                                     0 /* priority */,
                                     GSF_datastore_queue_size,
-                                    GNUNET_TIME_UNIT_FOREVER_REL,
                                     &handle_datastore_reply, sc);
   if (NULL == sc->qe)
   {
@@ -529,9 +527,9 @@ cleaner_cb (void *cls,
   GNUNET_STATISTICS_update (GSF_stats,
                            gettext_noop ("# cadet connections active"), -1,
                            GNUNET_NO);
-  if (GNUNET_SCHEDULER_NO_TASK != sc->terminate_task)
+  if (NULL != sc->terminate_task)
     GNUNET_SCHEDULER_cancel (sc->terminate_task);
-  if (GNUNET_SCHEDULER_NO_TASK != sc->timeout_task)
+  if (NULL != sc->timeout_task)
     GNUNET_SCHEDULER_cancel (sc->timeout_task);
   if (NULL != sc->wh)
     GNUNET_CADET_notify_transmit_ready_cancel (sc->wh);