gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: fixing misc cleanup issues


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: fixing misc cleanup issues
Date: Sun, 22 Jan 2017 20:13:41 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 88c8852e8 fixing misc cleanup issues
88c8852e8 is described below

commit 88c8852e82b8c818571946ba4fec0e14c7239266
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Jan 22 20:13:39 2017 +0100

    fixing misc cleanup issues
---
 src/cadet/gnunet-service-cadet-new.c         | 35 +++++++++++++++++++++---
 src/cadet/gnunet-service-cadet-new.h         | 14 ++++++++++
 src/cadet/gnunet-service-cadet-new_channel.c | 29 +++++++++-----------
 src/cadet/gnunet-service-cadet-new_tunnels.c | 41 +++++++++++++++++++++++-----
 4 files changed, 92 insertions(+), 27 deletions(-)

diff --git a/src/cadet/gnunet-service-cadet-new.c 
b/src/cadet/gnunet-service-cadet-new.c
index 2e431c034..3bcf35db3 100644
--- a/src/cadet/gnunet-service-cadet-new.c
+++ b/src/cadet/gnunet-service-cadet-new.c
@@ -1122,6 +1122,33 @@ client_connect_cb (void *cls,
 
 
 /**
+ * A channel was destroyed by the other peer. Tell our client.
+ *
+ * @param c client that lost a channel
+ * @param ccn channel identification number for the client
+ * @param ch the channel object
+ */
+void
+GSC_handle_remote_channel_destroy (struct CadetClient *c,
+                                   struct GNUNET_CADET_ClientChannelNumber ccn,
+                                   struct CadetChannel *ch)
+{
+  struct GNUNET_MQ_Envelope *env;
+  struct GNUNET_CADET_LocalChannelDestroyMessage *tdm;
+
+  env = GNUNET_MQ_msg (tdm,
+                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY);
+  tdm->ccn = ccn;
+  GSC_send_to_client (c,
+                      env);
+  GNUNET_assert (GNUNET_YES ==
+                 GNUNET_CONTAINER_multihashmap32_remove (c->channels,
+                                                         ntohl 
(ccn.channel_of_client),
+                                                         ch));
+}
+
+
+/**
  * Iterator for deleting each channel whose client endpoint disconnected.
  *
  * @param cls Closure (client that has disconnected).
@@ -1137,14 +1164,14 @@ channel_destroy_iterator (void *cls,
   struct CadetClient *c = cls;
   struct CadetChannel *ch = value;
 
-  GNUNET_assert (GNUNET_YES ==
-                 GNUNET_CONTAINER_multihashmap32_remove (c->channels,
-                                                         key,
-                                                         ch));
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Destroying channel %s, due to client %s disconnecting.\n",
        GCCH_2s (ch),
        GSC_2s (c));
+  GNUNET_assert (GNUNET_YES ==
+                 GNUNET_CONTAINER_multihashmap32_remove (c->channels,
+                                                         key,
+                                                         ch));
   if (key < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
     GCCH_channel_local_destroy (ch);
   else
diff --git a/src/cadet/gnunet-service-cadet-new.h 
b/src/cadet/gnunet-service-cadet-new.h
index 25f02bf89..cb289e9c3 100644
--- a/src/cadet/gnunet-service-cadet-new.h
+++ b/src/cadet/gnunet-service-cadet-new.h
@@ -30,6 +30,7 @@
 
 #include "gnunet_util_lib.h"
 #define NEW_CADET 1
+#include "cadet_protocol.h"
 
 /**
  * A client to the CADET service.  Each client gets a unique handle.
@@ -237,6 +238,19 @@ GSC_send_to_client (struct CadetClient *c,
 
 
 /**
+ * A channel was destroyed by the other peer. Tell our client.
+ *
+ * @param c client that lost a channel
+ * @param ccn channel identification number for the client
+ * @param ch the channel object
+ */
+void
+GSC_handle_remote_channel_destroy (struct CadetClient *c,
+                                   struct GNUNET_CADET_ClientChannelNumber ccn,
+                                   struct CadetChannel *ch);
+
+
+/**
  * Bind incoming channel to this client, and notify client
  * about incoming connection.
  *
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c 
b/src/cadet/gnunet-service-cadet-new_channel.c
index f3603d898..425422cb6 100644
--- a/src/cadet/gnunet-service-cadet-new_channel.c
+++ b/src/cadet/gnunet-service-cadet-new_channel.c
@@ -170,14 +170,6 @@ struct CadetChannel
   struct CadetTunnel *t;
 
   /**
-   * Last entry in the tunnel's queue relating to control messages
-   * (#GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN or
-   * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK).  Used to cancel
-   * transmission in case we receive updated information.
-   */
-  struct CadetTunnelQueueEntry *last_control_qe;
-
-  /**
    * Client owner of the tunnel, if any.
    * (Used if this channel represends the initiating end of the tunnel.)
    */
@@ -190,6 +182,14 @@ struct CadetChannel
   struct CadetClient *dest;
 
   /**
+   * Last entry in the tunnel's queue relating to control messages
+   * (#GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN or
+   * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK).  Used to cancel
+   * transmission in case we receive updated information.
+   */
+  struct CadetTunnelQueueEntry *last_control_qe;
+
+  /**
    * Head of DLL of messages sent and not yet ACK'd.
    */
   struct CadetReliableMessage *head_sent;
@@ -417,6 +417,7 @@ channel_open_sent_cb (void *cls)
 {
   struct CadetChannel *ch = cls;
 
+  GNUNET_assert (NULL != ch->last_control_qe);
   ch->last_control_qe = NULL;
   ch->retry_time = GNUNET_TIME_STD_BACKOFF (ch->retry_time);
   ch->retry_task = GNUNET_SCHEDULER_add_delayed (ch->retry_time,
@@ -620,6 +621,7 @@ send_ack_cb (void *cls)
 {
   struct CadetChannel *ch = cls;
 
+  GNUNET_assert (NULL != ch->last_control_qe);
   ch->last_control_qe = NULL;
 }
 
@@ -1025,18 +1027,13 @@ GCCH_handle_channel_plaintext_data_ack (struct 
CadetChannel *ch,
 void
 GCCH_handle_remote_destroy (struct CadetChannel *ch)
 {
-  struct GNUNET_MQ_Envelope *env;
-  struct GNUNET_CADET_LocalChannelDestroyMessage *tdm;
-
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Received remote channel DESTROY for %s\n",
        GCCH_2s (ch));
   ch->destroy = GNUNET_YES;
-  env = GNUNET_MQ_msg (tdm,
-                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY);
-  tdm->ccn = ch->ccn;
-  GSC_send_to_client ((NULL != ch->owner) ? ch->owner : ch->dest,
-                      env);
+  GSC_handle_remote_channel_destroy ((NULL != ch->owner) ? ch->owner : 
ch->dest,
+                                     ch->ccn,
+                                     ch);
   channel_destroy (ch);
 }
 
diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.c 
b/src/cadet/gnunet-service-cadet-new_tunnels.c
index e5fb91f44..9754040cf 100644
--- a/src/cadet/gnunet-service-cadet-new_tunnels.c
+++ b/src/cadet/gnunet-service-cadet-new_tunnels.c
@@ -309,6 +309,11 @@ struct CadetTunnel
   struct GNUNET_SCHEDULER_Task *maintain_connections_task;
 
   /**
+   * Task to send messages from queue (if possible).
+   */
+  struct GNUNET_SCHEDULER_Task *send_task;
+
+  /**
    * Task to trigger KX.
    */
   struct GNUNET_SCHEDULER_Task *kx_task;
@@ -569,10 +574,10 @@ new_ephemeral (struct CadetTunnel *t)
  * at our message queue and if there is a message, picks a connection
  * to send it on.
  *
- * @param t tunnel to process messages on
+ * @param cls the `struct CadetTunnel` to process messages on
  */
 static void
-trigger_transmissions (struct CadetTunnel *t);
+trigger_transmissions (void *cls);
 
 
 /* ************************************** start core crypto 
***************************** */
@@ -1437,7 +1442,10 @@ GCT_handle_kx (struct CadetTConnection *ct,
        we can start transmitting! */
     GCT_change_estate (t,
                        CADET_TUNNEL_KEY_OK);
-    trigger_transmissions (t);
+    if (NULL != t->send_task)
+      GNUNET_SCHEDULER_cancel (t->send_task);
+    t->send_task = GNUNET_SCHEDULER_add_now (&trigger_transmissions,
+                                             t);
     break;
   case CADET_TUNNEL_KEY_PING:
     /* Got a key yet again; need encrypted payload to advance */
@@ -1554,6 +1562,16 @@ destroy_tunnel (void *cls)
     GNUNET_SCHEDULER_cancel (t->maintain_connections_task);
     t->maintain_connections_task = NULL;
   }
+  if (NULL != t->send_task)
+  {
+    GNUNET_SCHEDULER_cancel (t->send_task);
+    t->send_task = NULL;
+  }
+  if (NULL != t->kx_task)
+  {
+    GNUNET_SCHEDULER_cancel (t->kx_task);
+    t->kx_task = NULL;
+  }
   GNUNET_MST_destroy (t->mst);
   GNUNET_MQ_destroy (t->mq);
   while (NULL != t->ax.skipped_head)
@@ -1744,13 +1762,15 @@ connection_ready_cb (void *cls,
  * at our message queue and if there is a message, picks a connection
  * to send it on.
  *
- * @param t tunnel to process messages on
+ * @param cls the `struct CadetTunnel` to process messages on
  */
 static void
-trigger_transmissions (struct CadetTunnel *t)
+trigger_transmissions (void *cls)
 {
+  struct CadetTunnel *t = cls;
   struct CadetTConnection *ct;
 
+  t->send_task = NULL;
   if (NULL == t->tq_head)
     return; /* no messages pending right now */
   ct = get_ready_connection (t);
@@ -2327,7 +2347,10 @@ GCT_handle_encrypted (struct CadetTConnection *ct,
   {
     GCT_change_estate (t,
                        CADET_TUNNEL_KEY_OK);
-    trigger_transmissions (t);
+    if (NULL != t->send_task)
+      GNUNET_SCHEDULER_cancel (t->send_task);
+    t->send_task = GNUNET_SCHEDULER_add_now (&trigger_transmissions,
+                                             t);
   }
   /* The MST will ultimately call #handle_decrypted() on each message. */
   GNUNET_break_op (GNUNET_OK ==
@@ -2393,7 +2416,11 @@ GCT_send (struct CadetTunnel *t,
   GNUNET_CONTAINER_DLL_insert_tail (t->tq_head,
                                     t->tq_tail,
                                     tq);
-  trigger_transmissions (t);
+  if (NULL != t->send_task)
+    GNUNET_SCHEDULER_cancel (t->send_task);
+  t->send_task
+    = GNUNET_SCHEDULER_add_now (&trigger_transmissions,
+                                t);
   return tq;
 }
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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