plugin datastore mysql
[oweals/gnunet.git] / src / hostlist / gnunet-daemon-hostlist_server.c
index 56395df0258598ce5c28c214f6a771b5fad5e8a6..5c7b8887ec414b6616ea7420c119b8ce40e5afe6 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2008, 2009, 2010, 2014 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2008, 2009, 2010, 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
@@ -74,12 +74,12 @@ static struct GNUNET_PEERINFO_NotifyContext *notify;
 /**
  * Our primary task for IPv4.
  */
-static struct GNUNET_SCHEDULER_Task * hostlist_task_v4;
+static struct GNUNET_SCHEDULER_Task *hostlist_task_v4;
 
 /**
  * Our primary task for IPv6.
  */
-static struct GNUNET_SCHEDULER_Task * hostlist_task_v6;
+static struct GNUNET_SCHEDULER_Task *hostlist_task_v6;
 
 /**
  * Our canonical response.
@@ -238,6 +238,7 @@ host_processor (void *cls,
     builder->pitr = NULL;
     GNUNET_free_non_null (builder->data);
     GNUNET_free (builder);
+    builder = NULL;
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 _("Error in communication with PEERINFO service: %s\n"),
                 err_msg);
@@ -394,9 +395,7 @@ access_handler_callback (void *cls,
   if (NULL == *con_cls)
   {
     (*con_cls) = &dummy;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Sending 100 CONTINUE reply\n");
-    return MHD_YES;             /* send 100 continue */
+    return MHD_YES;
   }
   if (0 != *upload_data_size)
   {
@@ -480,8 +479,8 @@ adv_transmit_ready (void *cls,
               (unsigned int) transmission_size);
   hostlist_adv_count++;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              " # Sent advertisement message: %u\n",
-              hostlist_adv_count);
+              " # Sent advertisement message: %llu\n",
+              (unsigned long long) hostlist_adv_count);
   GNUNET_STATISTICS_update (stats,
                             gettext_noop ("# hostlist advertisements send"), 1,
                             GNUNET_NO);
@@ -521,7 +520,7 @@ connect_handler (void *cls,
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Asked CORE to transmit advertisement message with a size of %u bytes to peer `%s'\n",
-              size,
+              (unsigned int) size,
               GNUNET_i2s (peer));
   if (NULL ==
       (th = GNUNET_CORE_notify_transmit_ready (core, GNUNET_YES,
@@ -628,11 +627,9 @@ prepare_daemon (struct MHD_Daemon *daemon_handle);
  * and schedule the next run.
  *
  * @param cls the `struct MHD_Daemon` of the HTTP server to run
- * @param tc scheduler context
  */
 static void
-run_daemon (void *cls,
-            const struct GNUNET_SCHEDULER_TaskContext *tc)
+run_daemon (void *cls)
 {
   struct MHD_Daemon *daemon_handle = cls;
 
@@ -640,9 +637,6 @@ run_daemon (void *cls,
     hostlist_task_v4 = NULL;
   else
     hostlist_task_v6 = NULL;
-
-  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
-    return;
   GNUNET_assert (MHD_YES == MHD_run (daemon_handle));
   if (daemon_handle == daemon_handle_v4)
     hostlist_task_v4 = prepare_daemon (daemon_handle);
@@ -677,7 +671,9 @@ prepare_daemon (struct MHD_Daemon *daemon_handle)
   wrs = GNUNET_NETWORK_fdset_create ();
   wws = GNUNET_NETWORK_fdset_create ();
   max = -1;
-  GNUNET_assert (MHD_YES == MHD_get_fdset (daemon_handle, &rs, &ws, &es, &max));
+  GNUNET_assert (MHD_YES ==
+                MHD_get_fdset (daemon_handle,
+                               &rs, &ws, &es, &max));
   haveto = MHD_get_timeout (daemon_handle, &timeout);
   if (haveto == MHD_YES)
     tv.rel_value_us = (uint64_t) timeout * 1000LL;
@@ -685,10 +681,9 @@ prepare_daemon (struct MHD_Daemon *daemon_handle)
     tv = GNUNET_TIME_UNIT_FOREVER_REL;
   GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1);
   GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1);
-  ret =
-      GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH,
-                                  tv, wrs, wws,
-                                   &run_daemon, daemon_handle);
+  ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH,
+                                    tv, wrs, wws,
+                                    &run_daemon, daemon_handle);
   GNUNET_NETWORK_fdset_destroy (wrs);
   GNUNET_NETWORK_fdset_destroy (wws);
   return ret;
@@ -861,9 +856,9 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c,
                                        &accept_policy_callback, NULL,
                                        &access_handler_callback, NULL,
                                        MHD_OPTION_CONNECTION_LIMIT,
-                                       (unsigned int) 16,
+                                       (unsigned int) 128,
                                        MHD_OPTION_PER_IP_CONNECTION_LIMIT,
-                                       (unsigned int) 1,
+                                       (unsigned int) 32,
                                        MHD_OPTION_CONNECTION_TIMEOUT,
                                        (unsigned int) 16,
                                        MHD_OPTION_CONNECTION_MEMORY_LIMIT,
@@ -876,9 +871,9 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c,
                                        &accept_policy_callback, NULL,
                                        &access_handler_callback, NULL,
                                        MHD_OPTION_CONNECTION_LIMIT,
-                                       (unsigned int) 16,
+                                       (unsigned int) 128,
                                        MHD_OPTION_PER_IP_CONNECTION_LIMIT,
-                                       (unsigned int) 1,
+                                       (unsigned int) 32,
                                        MHD_OPTION_CONNECTION_TIMEOUT,
                                        (unsigned int) 16,
                                        MHD_OPTION_CONNECTION_MEMORY_LIMIT,
@@ -957,6 +952,7 @@ GNUNET_HOSTLIST_server_stop ()
     }
     GNUNET_free_non_null (builder->data);
     GNUNET_free (builder);
+    builder = NULL;
   }
   if (NULL != peerinfo)
   {