3 /* Copyright (C) 2004 by Daniel Stenberg et al
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation for any purpose and without fee is hereby granted, provided
7 * that the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of M.I.T. not be used in advertising or
10 * publicity pertaining to distribution of the software without specific,
11 * written prior permission. M.I.T. makes no representations about the
12 * suitability of this software for any purpose. It is provided "as is"
13 * without express or implied warranty.
20 #include "ares_private.h"
23 * ares_cancel() cancels all ongoing requests/resolves that might be going on
24 * on the given channel. It does NOT kill the channel, use ares_destroy() for
27 void ares_cancel(ares_channel channel)
30 struct list_node* list_head;
31 struct list_node* list_node;
34 list_head = &(channel->all_queries);
35 for (list_node = list_head->next; list_node != list_head; )
37 query = list_node->data;
38 list_node = list_node->next; /* since we're deleting the query */
39 query->callback(query->arg, ARES_ETIMEOUT, 0, NULL, 0);
40 ares__free_query(query);
43 /* Freeing the query should remove it from all the lists in which it sits,
44 * so all query lists should be empty now.
46 assert(ares__is_list_empty(&(channel->all_queries)));
47 for (i = 0; i < ARES_QID_TABLE_SIZE; i++)
49 assert(ares__is_list_empty(&(channel->queries_by_qid[i])));
51 for (i = 0; i < ARES_TIMEOUT_TABLE_SIZE; i++)
53 assert(ares__is_list_empty(&(channel->queries_by_timeout[i])));
56 if (!(channel->flags & ARES_FLAG_STAYOPEN))
60 for (i = 0; i < channel->nservers; i++)
61 ares__close_sockets(channel, &channel->servers[i]);