gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r24817 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r24817 - gnunet/src/transport
Date: Wed, 7 Nov 2012 10:54:12 +0100

Author: wachs
Date: 2012-11-07 10:54:12 +0100 (Wed, 07 Nov 2012)
New Revision: 24817

Modified:
   gnunet/src/transport/gnunet-service-transport_clients.c
Log:
fix mem leak mantis 0002635

Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c     2012-11-06 
23:46:23 UTC (rev 24816)
+++ gnunet/src/transport/gnunet-service-transport_clients.c     2012-11-07 
09:54:12 UTC (rev 24817)
@@ -116,7 +116,27 @@
   int send_payload;
 };
 
+/**
+ * Context for address to string operations
+ */
+struct AddressToStringContext
+{
+  /**
+   * This is a doubly-linked list.
+   */
+  struct AddressToStringContext *next;
 
+  /**
+   * This is a doubly-linked list.
+   */
+  struct AddressToStringContext *prev;
+
+  /**
+   * Transmission context
+   */
+  struct GNUNET_SERVER_TransmitContext* tc;
+};
+
 /**
  * Client monitoring changes of active addresses of our neighbours.
  */
@@ -157,6 +177,16 @@
 static struct TransportClient *clients_tail;
 
 /**
+ * Head of linked list of all pending address iterations
+ */
+struct AddressToStringContext *a2s_head;
+
+/**
+ * Tail of linked list of all pending address iterations
+ */
+struct AddressToStringContext *a2s_tail;
+
+/**
  * Head of linked list of monitoring clients.
  */
 static struct MonitoringClient *monitoring_clients_head;
@@ -720,16 +750,18 @@
 static void
 transmit_address_to_client (void *cls, const char *buf)
 {
-  struct GNUNET_SERVER_TransmitContext *tc = cls;
+  struct AddressToStringContext *actx = cls;
 
   if (NULL == buf)
   {
-    GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
+    GNUNET_SERVER_transmit_context_append_data (actx->tc, NULL, 0,
                                                 
GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY);
-    GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
+    GNUNET_SERVER_transmit_context_run (actx->tc, 
GNUNET_TIME_UNIT_FOREVER_REL);
+    GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, actx);
+    GNUNET_free (actx);
     return;
   }
-  GNUNET_SERVER_transmit_context_append_data (tc, buf, strlen (buf) + 1,
+  GNUNET_SERVER_transmit_context_append_data (actx->tc, buf, strlen (buf) + 1,
                                               
GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY);
 }
 
@@ -753,6 +785,7 @@
   uint32_t address_len;
   uint16_t size;
   struct GNUNET_SERVER_TransmitContext *tc;
+  struct AddressToStringContext *actx;
   struct GNUNET_TIME_Relative rtimeout;
   int32_t numeric;
 
@@ -791,10 +824,13 @@
     GNUNET_SERVER_transmit_context_run (tc, rtimeout);
     return;
   }
+  actx = GNUNET_malloc (sizeof (struct AddressToStringContext));
+  actx->tc = tc;
+  GNUNET_CONTAINER_DLL_insert (a2s_head, a2s_tail, actx);
   GNUNET_SERVER_disable_receive_done_warning (client);
   papi->address_pretty_printer (papi->cls, plugin_name, address, address_len,
                                 numeric, rtimeout, &transmit_address_to_client,
-                                tc);
+                                actx);
 }
 
 
@@ -981,6 +1017,15 @@
 void
 GST_clients_stop ()
 {
+  struct AddressToStringContext *cur;
+
+  while (NULL != (cur = a2s_head))
+  {
+    GNUNET_SERVER_transmit_context_destroy (cur->tc, GNUNET_NO);
+    GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, cur);
+    GNUNET_free (cur);
+  }
+
   if (NULL != nc)
   {
     GNUNET_SERVER_notification_context_destroy (nc);




reply via email to

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