- dont try to send data on connections that are going to be destroyed
authorBart Polot <bart@net.in.tum.de>
Wed, 27 Nov 2013 01:42:35 +0000 (01:42 +0000)
committerBart Polot <bart@net.in.tum.de>
Wed, 27 Nov 2013 01:42:35 +0000 (01:42 +0000)
src/mesh/gnunet-service-mesh_connection.c
src/mesh/gnunet-service-mesh_connection.h

index 31ba440e6259a444fd9f29280f4edb42e2dd04f3..cc5a19c745808b485972c040059efc5ba41e5829 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));
@@ -1520,6 +1527,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;
 }
@@ -2399,6 +2407,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.
@@ -2691,6 +2700,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;
 }
 
 
index 00b5e082ba1f1693e1e8d5b32a0dc45c3bd73649..44d205756a258cc7299dd560f8bc8c254a58ee75 100644 (file)
@@ -64,6 +64,11 @@ enum MeshConnectionState
    * Connection confirmed, ready to carry traffic.
    */
   MESH_CONNECTION_READY,
+
+  /**
+   * Connection to be destroyed, just waiting to empty queues.
+   */
+  MESH_CONNECTION_DESTROYED,
 };