fixes
authorChristian Grothoff <christian@grothoff.org>
Sun, 17 Jan 2010 21:07:12 +0000 (21:07 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 17 Jan 2010 21:07:12 +0000 (21:07 +0000)
src/hostlist/test_gnunet_daemon_hostlist.c
src/hostlist/test_gnunet_daemon_hostlist_peer1.conf
src/hostlist/test_gnunet_daemon_hostlist_peer2.conf
src/peerinfo/peerinfo_api.c
src/transport/transport.h
src/transport/transport_api.c

index 0d5ab561de4f68e979d1a16a6c52d828c8fad711..904990a83be29f3ed7f1d5a1bc30e47e49efc565 100644 (file)
@@ -62,10 +62,16 @@ static struct PeerContext p2;
 static void
 clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  GNUNET_TRANSPORT_disconnect (p1.th);
-  p1.th = NULL;
-  GNUNET_TRANSPORT_disconnect (p2.th);
-  p2.th = NULL;
+  if (p1.th != NULL)
+    {
+      GNUNET_TRANSPORT_disconnect (p1.th);
+      p1.th = NULL;
+    }
+  if (p2.th != NULL)
+    {
+      GNUNET_TRANSPORT_disconnect (p2.th);
+      p2.th = NULL;
+    }
   GNUNET_SCHEDULER_shutdown (sched);
 }
 
@@ -99,13 +105,16 @@ notify_connect (void *cls,
     return;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Peers connected, shutting down.\n");
-  GNUNET_assert (ok == 4);
   ok = 0;
-  GNUNET_SCHEDULER_cancel (sched,
-                          timeout_task);
-  timeout_task = GNUNET_SCHEDULER_NO_TASK;
-  GNUNET_SCHEDULER_add_now (sched,
-                           &clean_up, NULL);
+  if (timeout_task != GNUNET_SCHEDULER_NO_TASK)
+    {
+      GNUNET_SCHEDULER_cancel (sched,
+                              timeout_task);
+      timeout_task = GNUNET_SCHEDULER_NO_TASK;
+    }
+  GNUNET_SCHEDULER_add_delayed (sched,
+                               GNUNET_TIME_UNIT_MINUTES,
+                               &clean_up, NULL);
 }
 
 
@@ -121,8 +130,6 @@ process_hello (void *cls,
     return;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Received HELLO, starting hostlist service.\n");
-  GNUNET_assert ( (ok >= 2) && (ok <= 3) );
-  ok++;
   GNUNET_ARM_start_services (p->cfg, sched, "hostlist", NULL);
 }
 
index 844e1ded574aaf5bd2c1e9ef1fcfc665d3427426..6f19661d690c9cdce4a5581e196945ce8370e81c 100644 (file)
@@ -8,7 +8,7 @@ PORT = 12964
 [transport]
 PORT = 12965
 PLUGINS = tcp
-#DEBUG = YES
+DEBUG = YES
 
 [arm]
 PORT = 12966
@@ -36,6 +36,7 @@ WEAKRANDOM = YES
 HTTPPORT = 12980
 SERVERS = http://localhost:12981/
 OPTIONS = -b -p
+DEBUG = YES
 #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist
 
 [topology]
index dd5a599b8e3d03e0c5e3a3f83ec487eb9d026d34..ec34c8a8bab84c870cfad446fbb2ff8804c81553 100644 (file)
@@ -8,7 +8,7 @@ PORT = 22964
 [transport]
 PORT = 22965
 PLUGINS = tcp
-#DEBUG = YES
+DEBUG = YES
 
 [arm]
 PORT = 22966
@@ -36,6 +36,7 @@ WEAKRANDOM = YES
 HTTPPORT = 12981
 SERVERS = http://localhost:12980/
 OPTIONS = -b -p
+DEBUG = YES
 #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist
 
 [topology]
index 3ed2172db358c33058b685772509500da574d9d5..f3479ab7be34eff01e127b852895607eec77a978 100644 (file)
@@ -49,10 +49,12 @@ copy_and_free (void *cls, size_t size, void *buf)
 
   if (buf == NULL)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+#if DEBUG_PEERINFO
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   _
                   ("Failed to transmit message of type %u to `%s' service.\n"),
                   ntohs (msg->type), "peerinfo");
+#endif
       GNUNET_free (msg);
       GNUNET_CLIENT_disconnect (cc->client);
       GNUNET_free (cc);
@@ -112,7 +114,7 @@ GNUNET_PEERINFO_add_peer (const struct GNUNET_CONFIGURATION_Handle *cfg,
   GNUNET_CLIENT_notify_transmit_ready (client,
                                        ntohs (pam->header.size),
                                        ADD_PEER_TIMEOUT, 
-                                      GNUNET_YES,
+                                      GNUNET_NO,
                                       &copy_and_free, cc);
 }
 
index 57c312171ec102b321f7ad98e4966cca228b3f94..fad4300094bf3f4c75712f76bd302d74e4e4f27f 100644 (file)
@@ -27,7 +27,7 @@
 #include "gnunet_time_lib.h"
 #include "gnunet_transport_service.h"
 
-#define DEBUG_TRANSPORT GNUNET_NO
+#define DEBUG_TRANSPORT GNUNET_YES
 
 /**
  * For how long do we allow unused bandwidth
index ecd860675b724444085ba5e889105027658127e8..7adec78c9f5592de5f9f0b1967788efbb96d69d9 100644 (file)
@@ -378,7 +378,7 @@ transport_notify_ready (void *cls, size_t size, void *buf)
   if (buf == NULL)
     {
 #if DEBUG_TRANSPORT
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Could not transmit to transport service, cancelling pending requests\n");
 #endif
       th = h->connect_ready_head;
@@ -398,7 +398,8 @@ transport_notify_ready (void *cls, size_t size, void *buf)
        }
       GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL));
       GNUNET_free (th);
-      if (h->connect_ready_head != NULL) schedule_transmission (h); /* FIXME: is this ok? */
+      if (h->connect_ready_head != NULL) 
+       schedule_transmission (h); /* FIXME: is this ok? */
       return 0;
     } 
 #if DEBUG_TRANSPORT
@@ -409,7 +410,8 @@ transport_notify_ready (void *cls, size_t size, void *buf)
   ret = 0;
   h->network_handle = NULL;
   h->transmission_scheduled = GNUNET_NO;
-  do
+  while ((h->connect_ready_head != NULL) &&
+         (h->connect_ready_head->notify_size <= size))
     {
       th = h->connect_ready_head;
       if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
@@ -433,8 +435,6 @@ transport_notify_ready (void *cls, size_t size, void *buf)
         n->last_sent += ret;
       size -= ret;
     }
-  while ((h->connect_ready_head != NULL) &&
-         (h->connect_ready_head->notify_size <= size));
   if (h->connect_ready_head != NULL)
     schedule_transmission (h);
 #if DEBUG_TRANSPORT
@@ -1498,6 +1498,16 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
   while (NULL != (n = handle->neighbours))
     {
       handle->neighbours = n->next;
+      if (NULL != (th = n->transmit_handle))
+       {
+         if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
+           {
+             GNUNET_SCHEDULER_cancel (handle->sched, th->notify_delay_task);
+             th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
+           }
+         th->notify (th->notify_cls, 0, NULL);
+         GNUNET_free (th);
+       }
       GNUNET_free (n);
     }
   while (NULL != (hwl = handle->hwl_head))