- log
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_connection.c
index 46cf0422662bd234c11507a988bb765f29547561..8d2ef4044b0725954bb210415c1bc9167f64d782 100644 (file)
@@ -334,6 +334,8 @@ GMC_state2s (enum MeshConnectionState s)
       return "MESH_CONNECTION_ACK";
     case MESH_CONNECTION_READY:
       return "MESH_CONNECTION_READY";
+    case MESH_CONNECTION_DESTROYED:
+      return "MESH_CONNECTION_DESTROYED";
     default:
       return "MESH_CONNECTION_STATE_ERROR";
   }
@@ -379,6 +381,11 @@ connection_change_state (struct MeshConnection* c,
   LOG (GNUNET_ERROR_TYPE_DEBUG,
               "Connection %s state was %s\n",
               GMC_2s (c), GMC_state2s (c->state));
+  if (MESH_CONNECTION_DESTROYED == c->state)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "state not changing anymore\n");
+    return;
+  }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
               "Connection %s state is now %s\n",
               GMC_2s (c), GMC_state2s (state));
@@ -1274,7 +1281,7 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
   if (c->own_pos == size - 1)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  It's for us!\n");
-    GMP_add_path_to_origin (orig_peer, path, GNUNET_YES);
+    GMP_add_path_to_origin (orig_peer, path_duplicate (path), GNUNET_YES);
 
     add_to_peer (c, orig_peer);
     if (MESH_TUNNEL3_NEW == GMT_get_state (c->t))
@@ -1510,6 +1517,7 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
      */
     GNUNET_STATISTICS_update (stats, "# control on unknown tunnel",
                               1, GNUNET_NO);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "  connection unknown: already destroyed?\n");
     return GNUNET_OK;
   }
   fwd = is_fwd (c, peer);
@@ -1520,6 +1528,7 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
   }
   GMC_send_prebuilt_message (message, c, fwd, NULL, NULL);
   c->destroy = GNUNET_YES;
+  c->state = MESH_CONNECTION_DESTROYED;
 
   return GNUNET_OK;
 }
@@ -1566,7 +1575,9 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer,
   if (NULL == c)
   {
     GNUNET_STATISTICS_update (stats, "# unknown connection", 1, GNUNET_NO);
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "WARNING connection unknown\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "WARNING connection %s unknown\n",
+         GNUNET_h2s (&msg->cid));
     return GNUNET_OK;
   }
 
@@ -2014,6 +2025,12 @@ GMC_send_ack (struct MeshConnection *c, int fwd, int force)
     return;
   }
 
+  if (GNUNET_NO != c->destroy)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "  being destroyed, why bother...\n");
+    return;
+  }
+
   /* Get available buffer space */
   if (GMC_is_terminal (c, fwd))
   {
@@ -2391,6 +2408,7 @@ GMC_notify_broken (struct MeshConnection *c,
    * (the one we just scheduled), so no point in checking whether to
    * destroy immediately. */
   c->destroy = GNUNET_YES;
+  c->state = MESH_CONNECTION_DESTROYED;
 
   /**
    * Cancel all queues, if no message is left, connection will be destroyed.
@@ -2683,6 +2701,7 @@ GMC_send_destroy (struct MeshConnection *c)
   if (GNUNET_NO == GMC_is_terminal (c, GNUNET_NO))
     GMC_send_prebuilt_message (&msg.header, c, GNUNET_NO, NULL, NULL);
   c->destroy = GNUNET_YES;
+  c->state = MESH_CONNECTION_DESTROYED;
 }