aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorLRN <lrn1986@gmail.com>2013-12-19 18:39:17 +0000
committerLRN <lrn1986@gmail.com>2013-12-19 18:39:17 +0000
commit706ee768b1d29aad1f1a8bcf42166edf700ee54a (patch)
tree0f09cdd17735eb842bdac96154826286fa1dae99 /src/gns
parent8c9ad62dcde52c2de6330337ec58991ba16aa463 (diff)
downloadgnunet-706ee768b1d29aad1f1a8bcf42166edf700ee54a.tar.gz
gnunet-706ee768b1d29aad1f1a8bcf42166edf700ee54a.zip
Keep requests in a list, cancel them before disconnecting from GNS
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-gns-helper-service-w32.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/gns/gnunet-gns-helper-service-w32.c b/src/gns/gnunet-gns-helper-service-w32.c
index b27387e1a..ca699744c 100644
--- a/src/gns/gnunet-gns-helper-service-w32.c
+++ b/src/gns/gnunet-gns-helper-service-w32.c
@@ -50,6 +50,16 @@ DEFINE_GUID(SVCID_INET_HOSTADDRBYNAME, 0x0002a803, 0x0000, 0x0000, 0xc0, 0x00, 0
50 50
51struct request 51struct request
52{ 52{
53 /**
54 * We keep these in a doubly-linked list (for cleanup).
55 */
56 struct request *next;
57
58 /**
59 * We keep these in a doubly-linked list (for cleanup).
60 */
61 struct request *prev;
62
53 struct GNUNET_SERVER_Client *client; 63 struct GNUNET_SERVER_Client *client;
54 GUID sc; 64 GUID sc;
55 int af; 65 int af;
@@ -59,6 +69,16 @@ struct request
59}; 69};
60 70
61/** 71/**
72 * Head of the doubly-linked list (for cleanup).
73 */
74static struct request *rq_head;
75
76/**
77 * Tail of the doubly-linked list (for cleanup).
78 */
79static struct request *rq_tail;
80
81/**
62 * Handle to GNS service. 82 * Handle to GNS service.
63 */ 83 */
64static struct GNUNET_GNS_Handle *gns; 84static struct GNUNET_GNS_Handle *gns;
@@ -98,6 +118,7 @@ static void
98do_shutdown (void *cls, 118do_shutdown (void *cls,
99 const struct GNUNET_SCHEDULER_TaskContext *tc) 119 const struct GNUNET_SCHEDULER_TaskContext *tc)
100{ 120{
121 struct request *rq;
101 if (NULL != id_op) 122 if (NULL != id_op)
102 { 123 {
103 GNUNET_IDENTITY_cancel (id_op); 124 GNUNET_IDENTITY_cancel (id_op);
@@ -108,6 +129,16 @@ do_shutdown (void *cls,
108 GNUNET_IDENTITY_disconnect (identity); 129 GNUNET_IDENTITY_disconnect (identity);
109 identity = NULL; 130 identity = NULL;
110 } 131 }
132 while (NULL != (rq = rq_head))
133 {
134 if (NULL != rq->lookup_request)
135 GNUNET_GNS_lookup_cancel(rq->lookup_request);
136 GNUNET_CONTAINER_DLL_remove (rq_head, rq_tail, rq);
137 GNUNET_free_non_null (rq->name);
138 if (rq->u8name)
139 free (rq->u8name);
140 GNUNET_free (rq);
141 }
111 if (NULL != gns) 142 if (NULL != gns)
112 { 143 {
113 GNUNET_GNS_disconnect (gns); 144 GNUNET_GNS_disconnect (gns);
@@ -300,6 +331,7 @@ process_lookup_result (void* cls, uint32_t rd_count,
300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 331 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
301 "Got lookup result with count %u for rq %p with client %p\n", 332 "Got lookup result with count %u for rq %p with client %p\n",
302 rd_count, rq, rq->client); 333 rd_count, rq, rq->client);
334 rq->lookup_request = NULL;
303 335
304 if (rd_count == 0) 336 if (rd_count == 0)
305 { 337 {
@@ -308,6 +340,7 @@ process_lookup_result (void* cls, uint32_t rd_count,
308 msg->header.size = htons (size); 340 msg->header.size = htons (size);
309 msg->header.type = htons (GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE); 341 msg->header.type = htons (GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE);
310 transmit (rq->client, &msg->header); 342 transmit (rq->client, &msg->header);
343 GNUNET_CONTAINER_DLL_remove (rq_head, rq_tail, rq);
311 GNUNET_free_non_null (rq->name); 344 GNUNET_free_non_null (rq->name);
312 if (rq->u8name) 345 if (rq->u8name)
313 free (rq->u8name); 346 free (rq->u8name);
@@ -538,6 +571,7 @@ process_lookup_result (void* cls, uint32_t rd_count,
538 MarshallWSAQUERYSETW (qs, &rq->sc); 571 MarshallWSAQUERYSETW (qs, &rq->sc);
539 transmit (rq->client, &msg->header); 572 transmit (rq->client, &msg->header);
540 transmit (rq->client, msgend); 573 transmit (rq->client, msgend);
574 GNUNET_CONTAINER_DLL_remove (rq_head, rq_tail, rq);
541 GNUNET_free_non_null (rq->name); 575 GNUNET_free_non_null (rq->name);
542 if (rq->u8name) 576 if (rq->u8name)
543 free (rq->u8name); 577 free (rq->u8name);
@@ -625,6 +659,7 @@ get_ip_from_hostname (struct GNUNET_SERVER_Client *client,
625 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 659 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
626 "Lookup launched, waiting for a reply\n"); 660 "Lookup launched, waiting for a reply\n");
627 GNUNET_SERVER_receive_done (client, GNUNET_OK); 661 GNUNET_SERVER_receive_done (client, GNUNET_OK);
662 GNUNET_CONTAINER_DLL_insert (rq_head, rq_tail, rq);
628 } 663 }
629 else 664 else
630 { 665 {