gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r31547 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r31547 - gnunet/src/mesh
Date: Wed, 18 Dec 2013 21:33:26 +0100

Author: bartpolot
Date: 2013-12-18 21:33:26 +0100 (Wed, 18 Dec 2013)
New Revision: 31547

Modified:
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/gnunet-service-mesh_peer.c
Log:
- send notification immediately if a connection fails to be created
- allow to queue messages with no connection


Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-12-18 18:48:38 UTC 
(rev 31546)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-12-18 20:33:26 UTC 
(rev 31547)
@@ -791,6 +791,39 @@
 
 
 /**
+ * Send a notification that a connection is broken, when a connection
+ * isn't even created.
+ *
+ * @param connection_id Connection ID.
+ * @param id1 Peer that has disconnected.
+ * @param id2 Peer that has disconnected.
+ * @param peer Peer to notify (neighbor who sent the connection).
+ */
+static void
+send_broken2 (struct GNUNET_HashCode *connection_id,
+             const struct GNUNET_PeerIdentity *id1,
+             const struct GNUNET_PeerIdentity *id2,
+             GNUNET_PEER_Id peer_id)
+{
+  struct GNUNET_MESH_ConnectionBroken *msg;
+  struct MeshPeer *neighbor;
+
+  msg = GNUNET_new (struct GNUNET_MESH_ConnectionBroken);
+  msg->header.size = htons (sizeof (struct GNUNET_MESH_ConnectionBroken));
+  msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN);
+  msg->cid = *connection_id;
+  msg->peer1 = *id1;
+  msg->peer2 = *id2;
+  neighbor = GMP_get_short (peer_id);
+  GMP_queue_add (neighbor, msg,
+                 GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED,
+                 sizeof (struct GNUNET_MESH_ConnectionBroken),
+                 NULL, GNUNET_SYSERR, /* connection, fwd */
+                 NULL, NULL); /* continuation */
+}
+
+
+/**
  * Send keepalive packets for a connection.
  *
  * @param c Connection to keep alive..
@@ -1383,15 +1416,29 @@
                                      size, &own_pos);
     if (NULL == path)
       return GNUNET_OK;
+    if (0 == own_pos)
+    {
+      GNUNET_break_op (0);
+      return GNUNET_OK;
+    }
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  Own position: %u\n", own_pos);
-    GMP_add_path_to_all (path, GNUNET_NO);
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  Creating connection\n");
     c = GMC_new (cid, NULL, path_duplicate (path), own_pos);
     if (NULL == c)
     {
+      if (path->length - 1 == own_pos)
+      {
+        /* If we are destination, why did the creation fail? */
+        GNUNET_break (0);
+        return GNUNET_OK;
+      }
+      send_broken2 (cid, &my_full_id,
+                    GNUNET_PEER_resolve2 (path->peers[own_pos + 1]),
+                    path->peers[own_pos - 1]);
       path_destroy (path);
       return GNUNET_OK;
     }
+    GMP_add_path_to_all (path, GNUNET_NO);
     connection_reset_timeout (c, GNUNET_YES);
   }
   else

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-12-18 18:48:38 UTC (rev 
31546)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-12-18 20:33:26 UTC (rev 
31547)
@@ -858,9 +858,7 @@
     case GNUNET_MESSAGE_TYPE_MESH_KX:
     case GNUNET_MESSAGE_TYPE_MESH_ACK:
     case GNUNET_MESSAGE_TYPE_MESH_POLL:
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-                  "*   raw: %s\n",
-                  GM_m2s (queue->type));
+      LOG (GNUNET_ERROR_TYPE_DEBUG, "*   raw: %s\n", GM_m2s (queue->type));
       data_size = send_core_data_raw (queue->cls, size, buf);
       break;
     case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE:
@@ -911,14 +909,13 @@
     if (NULL == peer->core_transmit)
     {
       peer->core_transmit =
-          GNUNET_CORE_notify_transmit_ready(core_handle,
-                                            0,
-                                            0,
-                                            GNUNET_TIME_UNIT_FOREVER_REL,
-                                            dst_id,
-                                            queue->size,
-                                            &queue_send,
-                                            peer);
+          GNUNET_CORE_notify_transmit_ready (core_handle,
+                                             0, 0,
+                                             GNUNET_TIME_UNIT_FOREVER_REL,
+                                             dst_id,
+                                             queue->size,
+                                             &queue_send,
+                                             peer);
       queue->start_waiting = GNUNET_TIME_absolute_get ();
     }
     else
@@ -956,7 +953,6 @@
   struct MeshPeer *peer;
 
   peer = queue->peer;
-  GNUNET_assert (NULL != queue->c);
 
   if (GNUNET_YES == clear_cls)
   {
@@ -1013,7 +1009,7 @@
  *            build the message to be sent if not already prebuilt.
  * @param type Type of the message, 0 for a raw message.
  * @param size Size of the message.
- * @param c Connection this message belongs to (cannot be NULL).
+ * @param c Connection this message belongs to (can be NULL).
  * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!)
  * @param cont Continuation to be called once CORE has taken the message.
  * @param cont_cls Closure for @c cont.
@@ -1034,7 +1030,6 @@
        "queue add %s %s towards %s (size %u) on c %p (%s)\n",
        GM_f2s (fwd),  GM_m2s (type), GMP_2s(peer),
        size, c, GMC_2s (c));
-  GNUNET_assert (NULL != c);
 
   if (NULL == peer->connections)
   {
@@ -1055,7 +1050,7 @@
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "priority %d\n", priority);
 
-  call_core = GMC_is_sendable (c, fwd);
+  call_core = NULL == c ? GNUNET_YES : GMC_is_sendable (c, fwd);
   queue = GNUNET_malloc (sizeof (struct MeshPeerQueue));
   queue->cls = cls;
   queue->type = type;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]