allow empty/NULL context message
[oweals/gnunet.git] / src / namestore / gnunet-service-namestore.c
index 1f42262977f4495264642771b2f1df2bcf52daf9..aeec2d10bd83b4b6ca909cc5540eba4d02c038ed 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2012, 2013, 2014 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2012, 2013, 2014 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.
 */
 
 /**
@@ -152,7 +152,7 @@ struct ZoneMonitor
   /**
    * Task active during initial iteration.
    */
-  GNUNET_SCHEDULER_TaskIdentifier task;
+  struct GNUNET_SCHEDULER_Task * task;
 
   /**
    * Offset of the zone iteration used to address next result of the zone
@@ -270,10 +270,9 @@ static struct GNUNET_SERVER_NotificationContext *monitor_nc;
  * Task run during shutdown.
  *
  * @param cls unused
- * @param tc unused
  */
 static void
-cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+cleanup_task (void *cls)
 {
   struct ZoneIteration *no;
   struct NamestoreClient *nc;
@@ -355,10 +354,10 @@ client_disconnect_notification (void *cls,
       GNUNET_CONTAINER_DLL_remove (monitor_head,
                                   monitor_tail,
                                   zm);
-      if (GNUNET_SCHEDULER_NO_TASK != zm->task)
+      if (NULL != zm->task)
       {
        GNUNET_SCHEDULER_cancel (zm->task);
-       zm->task = GNUNET_SCHEDULER_NO_TASK;
+       zm->task = NULL;
       }
       GNUNET_free (zm);
       break;
@@ -457,7 +456,8 @@ get_nick_record (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone)
   res = GSN_database->lookup_records (GSN_database->cls, zone,
                                       GNUNET_GNS_MASTERZONE_STR,
                                       &lookup_nick_it, &nick);
-  if ((NULL == nick) || (GNUNET_OK != res))
+  if ( (GNUNET_OK != res) ||
+       (NULL == nick) )
   {
     GNUNET_CRYPTO_ecdsa_key_get_public (zone, &pub);
     GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
@@ -595,7 +595,7 @@ send_lookup_response (struct GNUNET_SERVER_NotificationContext *nc,
   rd_ser = &name_tmp[name_len];
   GNUNET_GNSRECORD_records_serialize (res_count, res, rd_ser_len, rd_ser);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Sending `%s' message with %u records and size %u\n",
+             "Sending `%s' message with %u records and size %zu\n",
              "RECORD_RESULT",
              res_count,
              msg_size);
@@ -1524,11 +1524,9 @@ monitor_sync (struct ZoneMonitor *zm)
  * Obtain the next datum during the zone monitor's zone intiial iteration.
  *
  * @param cls zone monitor that does its initial iteration
- * @param tc scheduler context
  */
 static void
-monitor_next (void *cls,
-             const struct GNUNET_SCHEDULER_TaskContext *tc);
+monitor_next (void *cls);
 
 
 /**
@@ -1605,16 +1603,14 @@ handle_monitor_start (void *cls,
  * Obtain the next datum during the zone monitor's zone intiial iteration.
  *
  * @param cls zone monitor that does its initial iteration
- * @param tc scheduler context
  */
 static void
-monitor_next (void *cls,
-             const struct GNUNET_SCHEDULER_TaskContext *tc)
+monitor_next (void *cls)
 {
   struct ZoneMonitor *zm = cls;
   int ret;
 
-  zm->task = GNUNET_SCHEDULER_NO_TASK;
+  zm->task = NULL;
   ret = GSN_database->iterate_records (GSN_database->cls,
                                        (0 == memcmp (&zm->zone, &zero, sizeof (zero)))
                                        ? NULL
@@ -1693,8 +1689,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
   GNUNET_SERVER_disconnect_notify (server,
                                    &client_disconnect_notification,
                                    NULL);
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&cleanup_task,
+                                NULL);
 }
 
 
@@ -1714,4 +1710,3 @@ main (int argc, char *const *argv)
 }
 
 /* end of gnunet-service-namestore.c */
-