- don't re-encrypt data queued in a broken connection
authorBart Polot <bart@net.in.tum.de>
Mon, 21 Jul 2014 00:15:14 +0000 (00:15 +0000)
committerBart Polot <bart@net.in.tum.de>
Mon, 21 Jul 2014 00:15:14 +0000 (00:15 +0000)
src/cadet/gnunet-service-cadet_connection.c
src/cadet/gnunet-service-cadet_tunnel.c
src/cadet/gnunet-service-cadet_tunnel.h

index 005e1cb8d9a9cb06f2b8b19c3268f8d7d991650a..102f7edac5a146e1623f42b8bdac3ccfa838766e 100644 (file)
@@ -1839,9 +1839,7 @@ GCC_handle_broken (void* cls,
      * is popped! Do not use 'c' after the call. */
     while (NULL != (out_msg = GCP_connection_pop (neighbor, c)))
     {
-      GNUNET_assert (NULL ==
-                     GCT_send_prebuilt_message (out_msg, t, NULL, GNUNET_YES,
-                                                NULL, NULL));
+      GCT_resend_message (out_msg, t);
       pending_msgs--;
     }
 
@@ -3000,9 +2998,8 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
     GNUNET_STATISTICS_update (stats, "# messages dropped (buffer full)",
                               1, GNUNET_NO);
     GNUNET_break (0);
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-                "queue full: %u/%u\n",
-                fc->queue_n, fc->queue_max);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "queue full: %u/%u\n",
+         fc->queue_n, fc->queue_max);
     if (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED == type)
     {
       fc->queue_n--;
@@ -3011,7 +3008,8 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
     return NULL; /* Drop this message */
   }
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "  C_P+ %p %u\n", c, c->pending_messages);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "  C_P+ %s %u\n",
+       GCC_2s (c), c->pending_messages);
   c->pending_messages++;
 
   q = GNUNET_new (struct CadetConnectionQueue);
@@ -3020,7 +3018,7 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
                         size, c, fwd, &conn_message_sent, q);
   if (NULL == q->q)
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "WARNING dropping msg on %s\n", GCC_2s (c));
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "dropping msg on %s, NULL q\n", GCC_2s (c));
     GNUNET_free (data);
     GNUNET_free (q);
     return NULL;
index 1fb5e539c2ef635f021314b7b7078c221c2f0aa0..fffdb9102bf433769364289c5aefc2ee409883d2 100644 (file)
@@ -3039,6 +3039,32 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
   return send_prebuilt_message (message, t, c, force, cont, cont_cls, NULL);
 }
 
+/**
+ * Sends an already built and encrypted message on a tunnel, choosing the best
+ * connection. Useful for re-queueing messages queued on a destroyed connection.
+ *
+ * @param message Message to send. Function modifies it.
+ * @param t Tunnel on which this message is transmitted.
+ */
+void
+GCT_resend_message (const struct GNUNET_MessageHeader *message,
+                    struct CadetTunnel *t)
+{
+  struct CadetConnection *c;
+  int fwd;
+
+  c = tunnel_get_connection (t);
+  if (NULL == c)
+  {
+    /* TODO queue in tunnel, marked as encrypted */
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "No connection available, dropping.\n");
+    return;
+  }
+  fwd = GCC_is_origin (c, GNUNET_YES);
+  GNUNET_break (NULL == GCC_send_prebuilt_message (message, 0, 0, c, fwd,
+                                                   GNUNET_YES, NULL, NULL));
+}
+
 
 /**
  * Is the tunnel directed towards the local peer?
index 3013254e9d9172495e6464de2a7feb5bea925e87..f9415325890c85efd5488deff2349e115a0ff32f 100644 (file)
@@ -439,6 +439,17 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
                            struct CadetTunnel *t, struct CadetConnection *c,
                            int force, GCT_sent cont, void *cont_cls);
 
+/**
+ * Sends an already built and encrypted message on a tunnel, choosing the best
+ * connection. Useful for re-queueing messages queued on a destroyed connection.
+ *
+ * @param message Message to send. Function modifies it.
+ * @param t Tunnel on which this message is transmitted.
+ */
+void
+GCT_resend_message (const struct GNUNET_MessageHeader *message,
+                    struct CadetTunnel *t);
+
 /**
  * Is the tunnel directed towards the local peer?
  *