gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r35830 - gnunet/src/vpn


From: gnunet
Subject: [GNUnet-SVN] r35830 - gnunet/src/vpn
Date: Thu, 28 May 2015 15:38:58 +0200

Author: grothoff
Date: 2015-05-28 15:38:58 +0200 (Thu, 28 May 2015)
New Revision: 35830

Modified:
   gnunet/src/vpn/gnunet-helper-vpn.c
   gnunet/src/vpn/gnunet-service-vpn.c
Log:
-simplify logic, fix double free

Modified: gnunet/src/vpn/gnunet-helper-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-helper-vpn.c  2015-05-28 09:58:58 UTC (rev 35829)
+++ gnunet/src/vpn/gnunet-helper-vpn.c  2015-05-28 13:38:58 UTC (rev 35830)
@@ -50,7 +50,7 @@
  * Should we print (interesting|debug) messages that can happen during
  * normal operation?
  */
-#define DEBUG GNUNET_NO
+#define DEBUG GNUNET_YES
 
 /**
  * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
@@ -364,7 +364,7 @@
      tests fail. With '||' the tests pass, but this process
      keeps running --- but only for the 'GNS' test ---
      even though the stdout is closed :-(. Very confusing. */
-  while ((1 == read_open) || (1 == write_open))
+  while ((1 == read_open) && (1 == write_open))
   {
     FD_ZERO (&fds_w);
     FD_ZERO (&fds_r);
@@ -547,6 +547,7 @@
       }
     }
   }
+  fprintf (stderr, "Existing select() loop\n");
 }
 
 
@@ -568,6 +569,8 @@
   int fd_tun;
   int global_ret;
 
+  fprintf (stderr,
+           "VPN helper running!\n");
   if (6 != argc)
   {
     fprintf (stderr, "Fatal: must supply 5 arguments!\n");

Modified: gnunet/src/vpn/gnunet-service-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-service-vpn.c 2015-05-28 09:58:58 UTC (rev 35829)
+++ gnunet/src/vpn/gnunet-service-vpn.c 2015-05-28 13:38:58 UTC (rev 35830)
@@ -84,11 +84,6 @@
   struct DestinationEntry *destination;
 
   /**
-   * Pre-allocated channel for this destination, or NULL for none.
-   */
-  struct ChannelState *ts;
-
-  /**
    * Destination port this channel state is used for.
    */
   uint16_t destination_port;
@@ -247,12 +242,6 @@
   struct ChannelMessageQueueEntry *tmq_tail;
 
   /**
-   * Destination entry that has a pointer to this channel state;
-   * NULL if this channel state is in the channel map.
-   */
-  struct DestinationChannel *destination_container;
-
-  /**
    * Destination to which this channel leads.  Note that
    * this struct is NOT in the destination_map (but a
    * local copy) and that the 'heap_node' should always
@@ -552,6 +541,17 @@
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Cleaning up channel state\n");
+  if (NULL != ts->th)
+  {
+    GNUNET_CADET_notify_transmit_ready_cancel (ts->th);
+    ts->th = NULL;
+  }
+  if (NULL != (channel = ts->channel))
+  {
+    ts->channel = NULL;
+    GNUNET_CADET_channel_destroy (channel);
+    return;
+  }
   GNUNET_STATISTICS_update (stats,
                            gettext_noop ("# Active channels"),
                            -1, GNUNET_NO);
@@ -564,17 +564,7 @@
     GNUNET_free (tnq);
   }
   GNUNET_assert (0 == ts->tmq_length);
-  if (NULL != ts->th)
-  {
-    GNUNET_CADET_notify_transmit_ready_cancel (ts->th);
-    ts->th = NULL;
-  }
   GNUNET_assert (NULL == ts->destination.heap_node);
-  if (NULL != (channel = ts->channel))
-  {
-    ts->channel = NULL;
-    GNUNET_CADET_channel_destroy (channel);
-  }
   if (NULL != ts->search)
   {
     GNUNET_REGEX_search_cancel (ts->search);
@@ -596,12 +586,6 @@
                                                         &key,
                                                         ts));
   }
-  if (NULL != ts->destination_container)
-  {
-    GNUNET_assert (ts == ts->destination_container->ts);
-    ts->destination_container->ts = NULL;
-    ts->destination_container = NULL;
-  }
   GNUNET_free (ts);
 }
 
@@ -796,7 +780,6 @@
   GNUNET_STATISTICS_update (stats,
                            gettext_noop ("# Cadet channels created"),
                            1, GNUNET_NO);
-  GNUNET_assert (NULL == dt->ts);
   switch (client_af)
   {
   case AF_INET:
@@ -813,8 +796,6 @@
   ts->af = client_af;
   ts->destination = *dt->destination;
   ts->destination.heap_node = NULL; /* copy is NOT in destination heap */
-  dt->ts = ts;
-  ts->destination_container = dt; /* we are referenced from dt */
   if (dt->destination->is_service)
   {
     ts->channel = GNUNET_CADET_channel_create (cadet_handle,
@@ -1102,14 +1083,9 @@
                 GNUNET_h2s (&key));
     /* need to either use the existing channel from the destination (if still
        available) or create a fresh one */
-    if (NULL == dt->ts)
-      ts = create_channel_to_destination (dt, af);
-    else
-      ts = dt->ts;
+    ts = create_channel_to_destination (dt, af);
     if (NULL == ts)
       return;
-    dt->ts = NULL;
-    ts->destination_container = NULL; /* no longer 'contained' */
     /* now bind existing "unbound" channel to our IP/port tuple */
     ts->protocol = protocol;
     ts->af = af;
@@ -2519,11 +2495,6 @@
     GNUNET_CONTAINER_DLL_remove (de->dt_head,
                                 de->dt_tail,
                                 dt);
-    if (NULL != dt->ts)
-    {
-      free_channel_state (dt->ts);
-      GNUNET_assert (NULL == dt->ts);
-    }
     GNUNET_free (dt);
   }
   if (NULL != de->heap_node)




reply via email to

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