/*
This file is part of GNUnet.
- (C) 2012 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2012 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
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;
struct GNUNET_GNS_LookupRequest *lookup_request;
};
+/**
+ * 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.
*/
do_shutdown (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ struct request *rq;
if (NULL != id_op)
{
GNUNET_IDENTITY_cancel (id_op);
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);
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)
{
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);
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);
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
{
}
msize = ntohs (message->size);
- if (msize < sizeof (struct GNUNET_W32RESOLVER_GetMessage))
+ if (msize <= sizeof (struct GNUNET_W32RESOLVER_GetMessage))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
sc.Data4[3], sc.Data4[4], sc.Data4[5], sc.Data4[6], sc.Data4[7]);
hostname = (const wchar_t *) &msg[1];
- if (hostname[size - 1] != L'\0')
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "name of %u bytes (last word is 0x%0X): %*S\n",
+ size, hostname[size / 2 - 2], size / 2, hostname);
+ if (hostname[size / 2 - 1] != L'\0')
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "name of length %u, not 0-terminated: %*S\n",
- size, size, hostname);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "name of length %u, not 0-terminated (%d-th word is 0x%0X): %*S\n",
+ size, size / 2 - 1, hostname[size / 2 - 1], size, hostname);
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;