print stat
[oweals/gnunet.git] / src / dht / gnunet-service-dht_neighbours.c
index 6697d49ea1ca99921a5f28a1a22a1b54dcce6a9d..e1491a263d96742cabd9335ba7398969ec78c22e 100644 (file)
@@ -705,6 +705,7 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
   struct PeerInfo *to_remove;
   int current_bucket;
   struct P2PPendingMessage *pos;
+  unsigned int discarded;
 
   /* Check for disconnect from self message */
   if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
@@ -752,13 +753,19 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
     GNUNET_CORE_notify_transmit_ready_cancel (to_remove->th);
     to_remove->th = NULL;
   }
+  discarded = 0;
   while (NULL != (pos = to_remove->head))
   {
     GNUNET_CONTAINER_DLL_remove (to_remove->head,
                                 to_remove->tail,
                                 pos);
+    discarded++;
     GNUNET_free (pos);
   }
+  GNUNET_STATISTICS_update (GDS_stats,
+                           gettext_noop ("# Queued messages discarded (peer disconnected)"), discarded,
+                           GNUNET_NO);
+  GNUNET_free (to_remove);
 }
 
 
@@ -800,7 +807,8 @@ core_transmit_notify (void *cls, size_t size, void *buf)
                                           pending->importance,
                                           GNUNET_TIME_absolute_get_remaining (pending->timeout),
                                           &peer->id, ntohs (pending->msg->size),
-                                          &core_transmit_notify, peer);  
+                                          &core_transmit_notify, peer);
+    GNUNET_break (NULL != peer->th);
     return 0;
   }
   off = 0;
@@ -817,14 +825,15 @@ core_transmit_notify (void *cls, size_t size, void *buf)
     GNUNET_free (pending);
   }
   if (peer->head != NULL)
-    {
-      peer->th 
-       = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
-                                            pending->importance,
-                                            GNUNET_TIME_absolute_get_remaining (pending->timeout),
-                                            &peer->id, msize,
-                                            &core_transmit_notify, peer);
-    }
+  {
+    peer->th 
+      = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
+                                          pending->importance,
+                                          GNUNET_TIME_absolute_get_remaining (pending->timeout),
+                                          &peer->id, msize,
+                                          &core_transmit_notify, peer);
+    GNUNET_break (NULL != peer->th);
+  }
   return off;
 }
 
@@ -854,6 +863,7 @@ process_peer_queue (struct PeerInfo *peer)
                                         &peer->id,
                                         ntohs (pending->msg->size),
                                         &core_transmit_notify, peer);
+  GNUNET_break (NULL != peer->th);
 }