-only notify AFTER sending is really close to finished, not before
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_peer.c
index 9526e0b0ac9e12e0c2a074c1570d4542ca599fbb..3768da895ca7f9f915351fe3a792bcf0904a7a16 100644 (file)
@@ -25,7 +25,7 @@
 #include "gnunet_core_service.h"
 #include "gnunet_statistics_service.h"
 
-#include "mesh_protocol_enc.h"
+#include "mesh_protocol.h"
 
 #include "gnunet-service-mesh_peer.h"
 #include "gnunet-service-mesh_dht.h"
@@ -277,28 +277,29 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
 static void
 core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
-  struct MeshPeer *pi;
+  struct MeshPeer *p;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Peer disconnected\n");
-  pi = GNUNET_CONTAINER_multipeermap_get (peers, peer);
-  if (NULL == pi)
+  p = GNUNET_CONTAINER_multipeermap_get (peers, peer);
+  if (NULL == p)
   {
     GNUNET_break (0);
     return;
   }
+  if (myid == p->id)
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "     (self)\n");
+  else
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "     %s\n", GMP_2s (p));
 
-  GNUNET_CONTAINER_multihashmap_iterate (pi->connections, &notify_broken, pi);
-  GNUNET_CONTAINER_multihashmap_destroy (pi->connections);
-  pi->connections = NULL;
-  if (NULL != pi->core_transmit)
+
+  GNUNET_CONTAINER_multihashmap_iterate (p->connections, &notify_broken, p);
+  GNUNET_CONTAINER_multihashmap_destroy (p->connections);
+  p->connections = NULL;
+  if (NULL != p->core_transmit)
     {
-      GNUNET_CORE_notify_transmit_ready_cancel (pi->core_transmit);
-      pi->core_transmit = NULL;
+      GNUNET_CORE_notify_transmit_ready_cancel (p->core_transmit);
+      p->core_transmit = NULL;
     }
-  if (myid == pi->id)
-  {
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "     (self)\n");
-  }
   GNUNET_STATISTICS_update (stats, "# peers", -1, GNUNET_NO);
 
   return;
@@ -924,6 +925,7 @@ GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls)
       case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK:
       case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE:
       case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN:
+      case GNUNET_MESSAGE_TYPE_MESH_KX:
         LOG (GNUNET_ERROR_TYPE_DEBUG, "#   prebuilt message\n");;
         GNUNET_free_non_null (queue->cls);
         break;
@@ -1598,7 +1600,7 @@ GMP_remove_connection (struct MeshPeer *peer,
   if (NULL == peer || NULL == peer->connections)
   {
     GNUNET_break (0);
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
+    LOG (GNUNET_ERROR_TYPE_WARNING,
          "Peer %s is not a neighbor!\n",
          GMP_2s (peer));
     return GNUNET_SYSERR;