- doc
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_peer.c
index 2884b1a53618058500786d46bebc00a7eabf6acc..5fe19e646c7ac378b28de2d9097c1b9d3fd3ba47 100644 (file)
@@ -766,7 +766,6 @@ queue_is_sendable (struct MeshPeerQueue *q)
     case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK:
     case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY:
     case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN:
-    case GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE:
       return GNUNET_YES;
 
     case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
@@ -776,10 +775,7 @@ queue_is_sendable (struct MeshPeerQueue *q)
       GNUNET_break (0);
   }
 
-  if (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN != q->type)
-    return GMC_is_sendable (q->c, q->fwd);
-
-  return GNUNET_NO;
+  return GMC_is_sendable (q->c, q->fwd);
 }
 
 
@@ -788,7 +784,7 @@ queue_is_sendable (struct MeshPeerQueue *q)
  *
  * @param peer The destination peer.
  *
- * @return Best current known path towards the peer, if any.
+ * @return First transmittable message, if any. Otherwise, NULL.
  */
 static struct MeshPeerQueue *
 peer_get_first_message (const struct MeshPeer *peer)
@@ -797,6 +793,7 @@ peer_get_first_message (const struct MeshPeer *peer)
 
   for (q = peer->queue_head; NULL != q; q = q->next)
   {
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Checking %p towards %s\n", q, GMC_2s (q->c));
     if (queue_is_sendable (q))
       return q;
   }
@@ -870,7 +867,7 @@ queue_send (void *cls, size_t size, void *buf)
   queue = peer_get_first_message (peer);
   if (NULL == queue)
   {
-    GNUNET_break (0); /* Core tmt_rdy should've been canceled */
+    GNUNET_assert (0); /* Core tmt_rdy should've been canceled */
     return 0;
   }
   c = queue->c;
@@ -1808,7 +1805,7 @@ GMP_remove_path (struct MeshPeer *peer, struct MeshPeerPath *path)
                      sizeof (GNUNET_PEER_Id) * path->length))
     {
       GNUNET_CONTAINER_DLL_remove (peer->path_head, peer->path_tail, iter);
-      if (path != iter)
+      if (iter != path)
         path_destroy (iter);
     }
   }
@@ -1924,6 +1921,10 @@ void
 GMP_set_tunnel (struct MeshPeer *peer, struct MeshTunnel3 *t)
 {
   peer->tunnel = t;
+  if (NULL == t && NULL != peer->search_h)
+  {
+    GMP_stop_search (peer);
+  }
 }
 
 
@@ -2067,11 +2068,10 @@ GMP_notify_broken_link (struct MeshPeer *peer,
         char *s;
 
         s = path_2s (iter);
-        LOG (GNUNET_ERROR_TYPE_DEBUG, " - destroying %s\n", s);
+        LOG (GNUNET_ERROR_TYPE_DEBUG, " - invalidating %s\n", s);
         GNUNET_free (s);
 
-        GNUNET_CONTAINER_DLL_remove (peer->path_head, peer->path_tail, iter);
-        path_destroy (iter);
+        path_invalidate (iter);
       }
     }
   }