gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r31585 - gnunet/src/gns


From: gnunet
Subject: [GNUnet-SVN] r31585 - gnunet/src/gns
Date: Thu, 19 Dec 2013 19:39:17 +0100

Author: LRN
Date: 2013-12-19 19:39:17 +0100 (Thu, 19 Dec 2013)
New Revision: 31585

Modified:
   gnunet/src/gns/gnunet-gns-helper-service-w32.c
Log:
Keep requests in a list, cancel them before disconnecting from GNS

Modified: gnunet/src/gns/gnunet-gns-helper-service-w32.c
===================================================================
--- gnunet/src/gns/gnunet-gns-helper-service-w32.c      2013-12-19 18:39:14 UTC 
(rev 31584)
+++ gnunet/src/gns/gnunet-gns-helper-service-w32.c      2013-12-19 18:39:17 UTC 
(rev 31585)
@@ -50,6 +50,16 @@
 
 struct request
 {
+  /**
+   * We keep these in a doubly-linked list (for cleanup).
+   */
+  struct request *next;
+
+  /**
+   * We keep these in a doubly-linked list (for cleanup).
+   */
+  struct request *prev;
+
   struct GNUNET_SERVER_Client *client;
   GUID sc;
   int af;
@@ -59,6 +69,16 @@
 };
 
 /**
+ * Head of the doubly-linked list (for cleanup).
+ */
+static struct request *rq_head;
+
+/**
+ * Tail of the doubly-linked list (for cleanup).
+ */
+static struct request *rq_tail;
+
+/**
  * Handle to GNS service.
  */
 static struct GNUNET_GNS_Handle *gns;
@@ -98,6 +118,7 @@
 do_shutdown (void *cls,
             const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  struct request *rq;
   if (NULL != id_op)
   {
     GNUNET_IDENTITY_cancel (id_op);
@@ -108,6 +129,16 @@
     GNUNET_IDENTITY_disconnect (identity);
     identity = NULL;
   }
+  while (NULL != (rq = rq_head))
+  {
+    if (NULL != rq->lookup_request)
+      GNUNET_GNS_lookup_cancel(rq->lookup_request);
+    GNUNET_CONTAINER_DLL_remove (rq_head, rq_tail, rq);
+    GNUNET_free_non_null (rq->name);
+    if (rq->u8name)
+      free (rq->u8name);
+    GNUNET_free (rq);
+  }
   if (NULL != gns)
   {
     GNUNET_GNS_disconnect (gns);
@@ -300,6 +331,7 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
       "Got lookup result with count %u for rq %p with client %p\n",
       rd_count, rq, rq->client);
+  rq->lookup_request = NULL;
 
   if (rd_count == 0)
   {
@@ -308,6 +340,7 @@
     msg->header.size = htons (size);
     msg->header.type = htons (GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE);
     transmit (rq->client, &msg->header);
+    GNUNET_CONTAINER_DLL_remove (rq_head, rq_tail, rq);
     GNUNET_free_non_null (rq->name);
     if (rq->u8name)
       free (rq->u8name);
@@ -538,6 +571,7 @@
   MarshallWSAQUERYSETW (qs, &rq->sc);
   transmit (rq->client, &msg->header);
   transmit (rq->client, msgend);
+  GNUNET_CONTAINER_DLL_remove (rq_head, rq_tail, rq);
   GNUNET_free_non_null (rq->name);
   if (rq->u8name)
     free (rq->u8name);
@@ -625,6 +659,7 @@
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Lookup launched, waiting for a reply\n");
     GNUNET_SERVER_receive_done (client, GNUNET_OK);
+    GNUNET_CONTAINER_DLL_insert (rq_head, rq_tail, rq);
   }
   else
   {




reply via email to

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