fix #3275 with solution from https://gnunet.org/bugs/view.php?id=3275#c8029
[oweals/gnunet.git] / src / hostlist / hostlist-server.c
index 031c7a13eb14e5aeff14ce3478fcdeb9b862bb2a..ef4debc056290c4783b2ca9ac4d9a9ed5f848eea 100644 (file)
@@ -433,9 +433,9 @@ process_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
   }
   else
   {
-    builder = GNUNET_malloc (sizeof (struct HostSet));
-  }  
-  GNUNET_assert (NULL != peerinfo); 
+    builder = GNUNET_new (struct HostSet);
+  }
+  GNUNET_assert (NULL != peerinfo);
   builder->pitr =
       GNUNET_PEERINFO_iterate (peerinfo, GNUNET_NO, NULL, GNUNET_TIME_UNIT_MINUTES,
                                &host_processor, NULL);
@@ -488,7 +488,6 @@ prepare_daemon (struct MHD_Daemon *daemon_handle)
   fd_set es;
   struct GNUNET_NETWORK_FDSet *wrs;
   struct GNUNET_NETWORK_FDSet *wws;
-  struct GNUNET_NETWORK_FDSet *wes;
   int max;
   UNSIGNED_MHD_LONG_LONG timeout;
   int haveto;
@@ -498,25 +497,22 @@ prepare_daemon (struct MHD_Daemon *daemon_handle)
   FD_ZERO (&ws);
   FD_ZERO (&es);
   wrs = GNUNET_NETWORK_fdset_create ();
-  wes = GNUNET_NETWORK_fdset_create ();
   wws = GNUNET_NETWORK_fdset_create ();
   max = -1;
   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;
+    tv.rel_value_us = (uint64_t) timeout * 1000LL;
   else
     tv = GNUNET_TIME_UNIT_FOREVER_REL;
   GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1);
   GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1);
-  GNUNET_NETWORK_fdset_copy_native (wes, &es, max + 1);
   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);
-  GNUNET_NETWORK_fdset_destroy (wes);
   return ret;
 }
 
@@ -601,7 +597,7 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c,
                   GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST",
                                                          "BINDTOIP", &ip));
   }
-  else 
+  else
     ip = NULL;
   if (NULL != ip)
   {
@@ -634,6 +630,7 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c,
                   ip);
       sa = NULL;
     }
+    GNUNET_free (ip);
   }
   else
     sa = NULL;