4a28cdfc300205f680380b0e54d9e6ef25f92a25
[oweals/gnunet.git] / src / hostlist / hostlist-server.c
1 /*
2      This file is part of GNUnet.
3      (C) 2008, 2009, 2010 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 2, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file hostlist/hostlist-server.c
23  * @author Christian Grothoff, Matthias Wachs
24  * @brief application to provide an integrated hostlist HTTP server
25  */
26
27 #include "platform.h"
28 #include <microhttpd.h>
29 #include "hostlist-server.h"
30 #include "gnunet_hello_lib.h"
31 #include "gnunet_peerinfo_service.h"
32 #include "gnunet-daemon-hostlist.h"
33 #include "gnunet_resolver_service.h"
34
35 #define DEBUG_HOSTLIST_SERVER GNUNET_NO
36
37 /**
38  * How often should we recalculate our response to hostlist requests?
39  */
40 #define RESPONSE_UPDATE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
41
42 /**
43  * Handle to the HTTP server as provided by libmicrohttpd for IPv6.
44  */
45 static struct MHD_Daemon *daemon_handle_v6;
46
47 /**
48  * Handle to the HTTP server as provided by libmicrohttpd for IPv4.
49  */
50 static struct MHD_Daemon *daemon_handle_v4;
51
52 /**
53  * Our configuration.
54  */
55 static const struct GNUNET_CONFIGURATION_Handle *cfg;
56
57 /**
58  * Our scheduler.
59  */
60 static struct GNUNET_SCHEDULER_Handle *sched;
61
62 /**
63  * For keeping statistics.
64  */ 
65 static struct GNUNET_STATISTICS_Handle *stats;
66
67 /**
68  * Handle to the core service (NULL until we've connected to it).
69  */
70 struct GNUNET_CORE_Handle *core;
71
72 /**
73  * Our primary task for IPv4.
74  */
75 static GNUNET_SCHEDULER_TaskIdentifier hostlist_task_v4;
76
77 /**
78  * Our primary task for IPv6.
79  */
80 static GNUNET_SCHEDULER_TaskIdentifier hostlist_task_v6;
81
82 /**
83  * Task that updates our HTTP response.
84  */
85 static GNUNET_SCHEDULER_TaskIdentifier response_task;
86
87 /**
88  * Our canonical response.
89  */
90 static struct MHD_Response *response;
91
92 /**
93  * NULL if we are not currenlty iterating over peer information.
94  */
95 static struct GNUNET_PEERINFO_IteratorContext *pitr;
96
97 /**
98  * Context for host processor.
99  */
100 struct HostSet
101 {
102   unsigned int size;
103
104   char *data;
105 };
106
107 /**
108  * Set if we are allowed to advertise our hostlist to others.
109  */
110 static int advertising;
111
112 /**
113  * How many times was the hostlist advertised?
114  */
115 static uint64_t hostlist_adv_count;
116
117 /**
118  * Buffer for the hostlist address
119  */
120 static char * hostlist_uri;
121
122
123 /**
124  * Task that will produce a new response object.
125  */
126 static void
127 update_response (void *cls,
128                  const struct GNUNET_SCHEDULER_TaskContext *tc);
129
130
131 /**
132  * Function that assembles our response.
133  */
134 static void
135 finish_response (struct HostSet *results)
136 {
137   struct GNUNET_TIME_Relative freq;
138
139   if (response != NULL)
140     MHD_destroy_response (response);
141 #if DEBUG_HOSTLIST_SERVER
142   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
143               "Creating hostlist response with %u bytes\n",
144               (unsigned int) results->size);
145 #endif
146   response = MHD_create_response_from_data (results->size,
147                                             results->data, MHD_YES, MHD_NO);
148   if ( (daemon_handle_v4 != NULL) ||
149        (daemon_handle_v6 != NULL) )
150     {
151       freq = RESPONSE_UPDATE_FREQUENCY;
152       if (results->size == 0)
153         freq = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250);
154       /* schedule next update of the response */
155       response_task = GNUNET_SCHEDULER_add_delayed (sched,
156                                                     freq,
157                                                     &update_response,
158                                                     NULL);
159     }
160   else
161     {
162       /* already past shutdown */
163       MHD_destroy_response (response);
164       response = NULL;
165     }
166   GNUNET_STATISTICS_set (stats,
167                          gettext_noop("bytes in hostlist"),
168                          results->size,
169                          GNUNET_YES);
170   GNUNET_free (results);
171 }
172
173
174 /**
175  * Set 'cls' to GNUNET_YES (we have an address!).
176  *
177  * @param cls closure, an 'int*'
178  * @param tname name of the transport (ignored)
179  * @param expiration expiration time (call is ignored if this is in the past)
180  * @param addr the address (ignored)
181  * @param addrlen length of the address (ignored)
182  * @return  GNUNET_SYSERR to stop iterating (unless expiration has occured)
183  */
184 static int
185 check_has_addr (void *cls,
186                 const char *tname,
187                 struct GNUNET_TIME_Absolute expiration,
188                 const void *addr, size_t addrlen)
189 {
190   int *arg = cls;
191
192   if (GNUNET_TIME_absolute_get_remaining (expiration).value == 0)
193     {
194       GNUNET_STATISTICS_update (stats,
195                                 gettext_noop("expired addresses encountered"),
196                                 1,
197                                 GNUNET_YES);
198       return GNUNET_YES; /* ignore this address */
199     }
200   *arg = GNUNET_YES;
201   return GNUNET_SYSERR;
202 }
203
204
205 /**
206  * Callback that processes each of the known HELLOs for the
207  * hostlist response construction.
208  */
209 static void
210 host_processor (void *cls,
211                 const struct GNUNET_PeerIdentity * peer,
212                 const struct GNUNET_HELLO_Message *hello,
213                 uint32_t trust)
214 {
215   struct HostSet *results = cls;
216   size_t old;
217   size_t s;
218   int has_addr;
219   
220   if (peer == NULL)
221     {
222       pitr = NULL;
223       finish_response (results);
224       return;
225     }
226   if (hello == NULL)
227     return;
228   has_addr = GNUNET_NO;
229   GNUNET_HELLO_iterate_addresses (hello,
230                                   GNUNET_NO,
231                                   &check_has_addr,
232                                   &has_addr);
233   if (GNUNET_NO == has_addr)
234     {
235       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
236                   "HELLO for peer `%4s' has no address, not suitable for hostlist!\n",
237                   GNUNET_i2s (peer));
238       GNUNET_STATISTICS_update (stats,
239                                 gettext_noop("HELLOs without addresses encountered (ignored)"),
240                                 1,
241                                 GNUNET_NO);
242       return; 
243     }
244   old = results->size;
245   s = GNUNET_HELLO_size(hello);
246 #if DEBUG_HOSTLIST_SERVER
247   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
248               "Received %u bytes of `%s' from peer `%s' for hostlist.\n",
249               (unsigned int) s,
250               "HELLO",
251               GNUNET_i2s (peer));
252 #endif
253   if (old + s >= GNUNET_MAX_MALLOC_CHECKED)
254     {
255       GNUNET_STATISTICS_update (stats,
256                                 gettext_noop("bytes not included in hostlist (size limit)"),
257                                 s,
258                                 GNUNET_NO);
259       return; /* too large, skip! */
260     }
261   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
262               "Adding peer `%s' to hostlist (%u bytes)\n",
263               GNUNET_i2s (peer),
264               (unsigned int) s);
265   GNUNET_array_grow (results->data,
266                      results->size,
267                      old + s);
268   memcpy (&results->data[old], hello, s);
269 }
270
271
272 /**
273  * Task that will produce a new response object.
274  */
275 static void
276 update_response (void *cls,
277                  const struct GNUNET_SCHEDULER_TaskContext *tc)
278 {
279   struct HostSet *results;
280
281   response_task = GNUNET_SCHEDULER_NO_TASK;
282   results = GNUNET_malloc(sizeof(struct HostSet));
283   pitr = GNUNET_PEERINFO_iterate (cfg, sched, 
284                                   NULL,
285                                   0, 
286                                   GNUNET_TIME_UNIT_MINUTES,
287                                   &host_processor,
288                                   results);
289 }
290
291
292 /**
293  * Hostlist access policy (very permissive, allows everything).
294  */
295 static int
296 accept_policy_callback (void *cls,
297                         const struct sockaddr *addr, socklen_t addrlen)
298 {
299   if (NULL == response)
300     {
301 #if DEBUG_HOSTLIST_SERVER
302       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
303                   "Received request for hostlist, but I am not yet ready; rejecting!\n");
304 #endif
305       return MHD_NO;
306     }
307   return MHD_YES;               /* accept all */
308 }
309
310
311 /**
312  * Main request handler.
313  */
314 static int
315 access_handler_callback (void *cls,
316                          struct MHD_Connection *connection,
317                          const char *url,
318                          const char *method,
319                          const char *version,
320                          const char *upload_data,
321                          size_t*upload_data_size, void **con_cls)
322 {
323   static int dummy;
324   
325   if (0 != strcmp (method, MHD_HTTP_METHOD_GET))
326     {
327       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
328                   _("Refusing `%s' request to hostlist server\n"),
329                   method);
330       GNUNET_STATISTICS_update (stats,
331                                 gettext_noop("hostlist requests refused (not HTTP GET)"),
332                                 1,
333                                 GNUNET_YES);
334       return MHD_NO;
335     }
336   if (NULL == *con_cls)
337     {
338       (*con_cls) = &dummy;
339 #if DEBUG_HOSTLIST_SERVER
340       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
341                   _("Sending 100 CONTINUE reply\n"));
342 #endif
343       return MHD_YES;           /* send 100 continue */
344     }
345   if (*upload_data_size != 0)
346     {
347       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
348                   _("Refusing `%s' request with %llu bytes of upload data\n"),
349                   method,
350                   (unsigned long long) *upload_data_size);
351       GNUNET_STATISTICS_update (stats,
352                                 gettext_noop("hostlist requests refused (upload data)"),
353                                 1,
354                                 GNUNET_YES);
355       return MHD_NO;              /* do not support upload data */
356     }
357   if (response == NULL)
358     {
359       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
360                   _("Could not handle hostlist request since I do not have a response yet\n"));
361       GNUNET_STATISTICS_update (stats,
362                                 gettext_noop("hostlist requests refused (not ready)"),
363                                 1,
364                                 GNUNET_YES);
365       return MHD_NO;              /* internal error, no response yet */
366     }
367   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
368               _("Received request for our hostlist\n"));
369   GNUNET_STATISTICS_update (stats,
370                             gettext_noop("hostlist requests processed"),
371                             1,
372                             GNUNET_YES);
373   return MHD_queue_response (connection, MHD_HTTP_OK, response);
374 }
375
376
377 /**
378  * Handler called by core when core is ready to transmit message
379  * @param cls   closure
380  * @param size  size of buffer to copy message to
381  * @param buf   buffer to copy message to
382  */
383 static size_t
384 adv_transmit_ready ( void *cls, size_t size, void *buf)
385 {
386   size_t transmission_size;
387   size_t uri_size; /* Including \0 termination! */
388   struct GNUNET_MessageHeader header;
389   char *cbuf;
390
391   if (buf == NULL)
392     {
393       GNUNET_log ( GNUNET_ERROR_TYPE_DEBUG, 
394                    "Transmission failed, buffer invalid!\n" );
395       return 0;
396     }
397   uri_size = strlen ( hostlist_uri ) + 1;
398   transmission_size = sizeof (struct GNUNET_MessageHeader) + uri_size;
399   header.type = htons (GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT);
400   header.size = htons (transmission_size);
401   GNUNET_assert (size >= transmission_size);
402   memcpy (buf, &header, sizeof (struct GNUNET_MessageHeader));
403   cbuf = buf;  
404   memcpy (&cbuf[sizeof (struct GNUNET_MessageHeader)],
405           hostlist_uri, uri_size);
406   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
407               "Sent advertisement message: Copied %u bytes into buffer!\n", 
408               (unsigned int) transmission_size);
409   hostlist_adv_count++;
410   GNUNET_STATISTICS_set (stats,
411                          gettext_noop("# hostlist advertisements send"),
412                          hostlist_adv_count,
413                          GNUNET_NO);
414   return transmission_size;
415 }
416
417
418 /**
419  * Method called whenever a given peer connects.
420  *
421  * @param cls closure
422  * @param peer peer identity this notification is about
423  * @param latency reported latency of the connection with 'other'
424  * @param distance reported distance (DV) to 'other'
425  */
426 static void
427 connect_handler (void *cls,
428                  const struct
429                  GNUNET_PeerIdentity * peer,
430                  struct GNUNET_TIME_Relative latency,
431                  uint32_t distance)
432 {
433   size_t size;
434
435   if ( !advertising )
436     return;
437   if (hostlist_uri == NULL)
438     return;
439   size = strlen (hostlist_uri) + 1;
440   if (size + sizeof (struct GNUNET_MessageHeader) > GNUNET_SERVER_MAX_MESSAGE_SIZE)
441     {
442       GNUNET_break (0);
443       return;
444     }
445   size += sizeof (struct GNUNET_MessageHeader);
446   if (NULL == core)
447     {
448       GNUNET_break (0);
449       return;
450     }
451   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
452               "Asked core to transmit advertisement message with a size of %u bytes\n", 
453               size);
454   if (NULL == GNUNET_CORE_notify_transmit_ready (core,
455                                                  0,
456                                                  GNUNET_ADV_TIMEOUT,
457                                                  peer,
458                                                  size,
459                                                  &adv_transmit_ready, NULL))
460     {
461       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
462                   _("Advertisement message could not be queued by core\n"));
463     }
464 }
465
466
467 /**
468  * Method called whenever a given peer disconnects.
469  *
470  * @param cls closure
471  * @param peer peer identity this notification is about
472  */
473 static void
474 disconnect_handler (void *cls,
475                     const struct
476                     GNUNET_PeerIdentity * peer)
477 {
478   /* nothing to do */
479 }
480
481
482 /**
483  * Function that queries MHD's select sets and
484  * starts the task waiting for them.
485  */
486 static GNUNET_SCHEDULER_TaskIdentifier
487 prepare_daemon (struct MHD_Daemon *daemon_handle);
488
489
490 /**
491  * Call MHD to process pending requests and then go back
492  * and schedule the next run.
493  */
494 static void
495 run_daemon (void *cls,
496             const struct GNUNET_SCHEDULER_TaskContext *tc)
497 {
498   struct MHD_Daemon *daemon_handle = cls;
499
500   if (daemon_handle == daemon_handle_v4)
501     hostlist_task_v4 = GNUNET_SCHEDULER_NO_TASK;
502   else
503     hostlist_task_v6 = GNUNET_SCHEDULER_NO_TASK;
504
505   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
506     return;    
507   GNUNET_assert (MHD_YES == MHD_run (daemon_handle));
508   if (daemon_handle == daemon_handle_v4)
509     hostlist_task_v4 = prepare_daemon (daemon_handle);
510   else
511     hostlist_task_v6 = prepare_daemon (daemon_handle);
512 }
513
514
515 /**
516  * Function that queries MHD's select sets and
517  * starts the task waiting for them.
518  */
519 static GNUNET_SCHEDULER_TaskIdentifier
520 prepare_daemon (struct MHD_Daemon *daemon_handle)
521 {
522   GNUNET_SCHEDULER_TaskIdentifier ret;
523   fd_set rs;
524   fd_set ws;
525   fd_set es;
526   struct GNUNET_NETWORK_FDSet *wrs;
527   struct GNUNET_NETWORK_FDSet *wws;
528   struct GNUNET_NETWORK_FDSet *wes;
529   int max;
530   unsigned long long timeout;
531   int haveto;
532   struct GNUNET_TIME_Relative tv;
533   
534   FD_ZERO(&rs);
535   FD_ZERO(&ws);
536   FD_ZERO(&es);
537   wrs = GNUNET_NETWORK_fdset_create ();
538   wes = GNUNET_NETWORK_fdset_create ();
539   wws = GNUNET_NETWORK_fdset_create ();
540   max = -1;
541   GNUNET_assert (MHD_YES ==
542                  MHD_get_fdset (daemon_handle,
543                                 &rs,
544                                 &ws,
545                                 &es,
546                                 &max));
547   haveto = MHD_get_timeout (daemon_handle, &timeout);
548   if (haveto == MHD_YES)
549     tv.value = (uint64_t) timeout;
550   else
551     tv = GNUNET_TIME_UNIT_FOREVER_REL;
552   GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max);
553   GNUNET_NETWORK_fdset_copy_native (wws, &ws, max);
554   GNUNET_NETWORK_fdset_copy_native (wes, &es, max);
555   ret = GNUNET_SCHEDULER_add_select (sched,
556                                      GNUNET_SCHEDULER_PRIORITY_HIGH,
557                                      GNUNET_SCHEDULER_NO_TASK,
558                                      tv,
559                                      wrs,
560                                      wws,
561                                      &run_daemon,
562                                      daemon_handle);
563   GNUNET_NETWORK_fdset_destroy (wrs);
564   GNUNET_NETWORK_fdset_destroy (wws);
565   GNUNET_NETWORK_fdset_destroy (wes);
566   return ret;
567 }
568
569
570
571 /**
572  * Start server offering our hostlist.
573  *
574  * @return GNUNET_OK on success
575  */
576 int
577 GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c,
578                               struct GNUNET_SCHEDULER_Handle *s,
579                               struct GNUNET_STATISTICS_Handle *st,
580                               struct GNUNET_CORE_Handle *co,
581                               GNUNET_CORE_ConnectEventHandler *server_ch,
582                               GNUNET_CORE_DisconnectEventHandler *server_dh,
583                               int advertise)
584 {
585   unsigned long long port;
586   char *hostname;
587   size_t size;
588
589   advertising = advertise;
590   if  ( !advertising )
591     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
592               "Advertising not enabled on this hostlist server\n");
593   else
594     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
595               "Advertising enabled on this hostlist server\n");
596   sched = s;
597   cfg = c;
598   stats = st;
599   if (-1 == GNUNET_CONFIGURATION_get_value_number (cfg,
600                                                    "HOSTLIST",
601                                                    "HTTPPORT", 
602                                                    &port))
603     return GNUNET_SYSERR;
604   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
605               _("Hostlist service starts on port %llu\n"),
606               port);
607   hostname = GNUNET_RESOLVER_local_hostname_get ();
608   if (NULL != hostname)
609     {
610       size = strlen (hostname);
611       if (size + 15 > MAX_URL_LEN)
612         {
613           GNUNET_break (0);
614         }
615       else
616         {
617           GNUNET_asprintf (&hostlist_uri,
618                            "http://%s:%u/",
619                            hostname,
620                            (unsigned int) port);
621           GNUNET_log (GNUNET_ERROR_TYPE_INFO,
622                       _("Address to obtain hostlist: `%s'\n"), 
623                       hostlist_uri);
624         }
625     }
626   GNUNET_free ( hostname );
627   daemon_handle_v6 = MHD_start_daemon (MHD_USE_IPv6 
628 #if DEBUG_HOSTLIST_SERVER
629                                        | MHD_USE_DEBUG
630 #endif
631                                        ,
632                                        (unsigned short) port,
633                                        &accept_policy_callback,
634                                        NULL,
635                                        &access_handler_callback,
636                                        NULL,
637                                        MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 16,
638                                        MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 1,
639                                        MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
640                                        MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024),
641                                        MHD_OPTION_END);
642   daemon_handle_v4 = MHD_start_daemon (MHD_NO_FLAG
643 #if DEBUG_HOSTLIST_SERVER
644                                        | MHD_USE_DEBUG
645 #endif
646                                        ,
647                                        (unsigned short) port,
648                                        &accept_policy_callback,
649                                        NULL,
650                                        &access_handler_callback,
651                                        NULL,
652                                        MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 16,
653                                        MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 1,
654                                        MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
655                                        MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024),
656                                        MHD_OPTION_END);
657
658   if ( (daemon_handle_v6 == NULL) &&
659        (daemon_handle_v4 == NULL) )
660     {
661       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
662                   _("Could not start hostlist HTTP server on port %u\n"),
663                   (unsigned short) port);
664       return GNUNET_SYSERR;    
665     }
666
667   core = co;
668
669   *server_ch = &connect_handler;
670   *server_dh = &disconnect_handler;
671
672   if (daemon_handle_v4 != NULL)
673     hostlist_task_v4 = prepare_daemon (daemon_handle_v4);
674   if (daemon_handle_v6 != NULL)
675     hostlist_task_v6 = prepare_daemon (daemon_handle_v6);
676   response_task = GNUNET_SCHEDULER_add_now (sched,
677                                             &update_response,
678                                             NULL);
679   return GNUNET_OK;
680 }
681
682 /**
683  * Stop server offering our hostlist.
684  */
685 void
686 GNUNET_HOSTLIST_server_stop ()
687 {
688 #if DEBUG_HOSTLIST_SERVER
689   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
690               "Hostlist server shutdown\n");
691 #endif
692   if (GNUNET_SCHEDULER_NO_TASK != hostlist_task_v6)
693     {
694       GNUNET_SCHEDULER_cancel (sched, hostlist_task_v6);
695       hostlist_task_v6 = GNUNET_SCHEDULER_NO_TASK;
696     }
697   if (GNUNET_SCHEDULER_NO_TASK != hostlist_task_v4)
698     {
699       GNUNET_SCHEDULER_cancel (sched, hostlist_task_v4);
700       hostlist_task_v4 = GNUNET_SCHEDULER_NO_TASK;
701     }
702   if (pitr != NULL)
703     {
704       GNUNET_PEERINFO_iterate_cancel (pitr);
705       pitr = NULL;
706     }
707   if (GNUNET_SCHEDULER_NO_TASK != response_task)
708     {
709       GNUNET_SCHEDULER_cancel (sched, response_task);
710       response_task = GNUNET_SCHEDULER_NO_TASK;
711     }
712   if (NULL != daemon_handle_v4)
713     {
714       MHD_stop_daemon (daemon_handle_v4);
715       daemon_handle_v4 = NULL;
716     }
717   if (NULL != daemon_handle_v6)
718     {
719       MHD_stop_daemon (daemon_handle_v6);
720       daemon_handle_v6 = NULL;
721     }
722   if (response != NULL)
723     {
724       MHD_destroy_response (response);
725       response = NULL;
726     }
727 }
728
729 /* end of hostlist-server.c */