Skip to content

Commit

Permalink
Dirk Manske's ares_cancel() function was added.
Browse files Browse the repository at this point in the history
  • Loading branch information
bagder committed Apr 1, 2004
1 parent 8ede9dd commit 86ae234
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 4 deletions.
11 changes: 11 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Changelog for the c-ares project

* April 1, 2004
- Dirk Manske provided a new function that is now named ares_cancel(). It is
used to cancel/cleanup a resolve/request made using ares functions on the
given ares channel. It does not destroy/kill the ares channel itself.

- Dominick Meglio cleaned up the formatting in several man pages.

* March 30, 2004
- Dominick Meglio's new ares_expand_string. A helper function when decoding
incoming DNS packages.
Expand Down Expand Up @@ -81,3 +90,5 @@ Version 1.0-pre1 (8 October 2003)
- Daniel Stenberg adjusted the windows port

- liren at vivisimo.com made the initial windows port

* Imported the sources from ares 1.1.1
5 changes: 2 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ OBJS= ares__close_sockets.o ares__get_hostent.o ares__read_line.o \
ares_gethostbyname.o ares_init.o ares_mkquery.o ares_parse_a_reply.o \
ares_parse_ptr_reply.o ares_process.o ares_query.o ares_search.o \
ares_send.o ares_strerror.o ares_timeout.o ares_version.o \
ares_expand_string.o
ares_expand_string.o ares_cancel.o

MANPAGES= ares_destroy.3 ares_expand_name.3 ares_expand_string.3 ares_fds.3 \
ares_free_hostent.3 ares_free_string.3 ares_gethostbyaddr.3 \
ares_gethostbyname.3 ares_init.3 ares_init_options.3 ares_mkquery.3 \
ares_parse_a_reply.3 ares_parse_ptr_reply.3 ares_process.3 \
ares_query.3 ares_search.3 ares_send.3 ares_strerror.3 ares_timeout.3 \
ares_version.3

ares_version.3 ares_cancel.3

$(LIB): ${OBJS}
ar cru $@ ${OBJS}
Expand Down
2 changes: 1 addition & 1 deletion ares.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int ares_init(ares_channel *channelptr);
int ares_init_options(ares_channel *channelptr, struct ares_options *options,
int optmask);
void ares_destroy(ares_channel channel);

void ares_cancel(ares_channel channel);
void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
ares_callback callback, void *arg);
void ares_query(ares_channel channel, const char *name, int dnsclass,
Expand Down
37 changes: 37 additions & 0 deletions ares_cancel.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.\" $Id$
.\"
.\" Copyright 1998 by the Massachusetts Institute of Technology.
.\"
.\" Permission to use, copy, modify, and distribute this
.\" software and its documentation for any purpose and without
.\" fee is hereby granted, provided that the above copyright
.\" notice appear in all copies and that both that copyright
.\" notice and this permission notice appear in supporting
.\" documentation, and that the name of M.I.T. not be used in
.\" advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission.
.\" M.I.T. makes no representations about the suitability of
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
.TH ARES_CANCEL 3 "31 March 2004"
.SH NAME
ares_cancel \- Cancel a resolve
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_cancel(ares_channel \fIchannel\fP)
.fi
.SH DESCRIPTION
The \fBares_cancel\fP function cancels all lookups/requests made on the the
name service channel identified by \fIchannel\fP. \fBares_cancel\fP invokes
the callbacks for each pending query on the channel, passing a status of
.BR ARES_ETIMEOUT .
These calls give the callbacks a chance to clean up any state which
might have been stored in their arguments.
.SH SEE ALSO
.BR ares_init (3)
.BR ares_destroy (3)
.SH AUTHOR
Dirk Manske
44 changes: 44 additions & 0 deletions ares_cancel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/

#include <stdlib.h>
#include "ares.h"
#include "ares_private.h"

/*
* ares_cancel() cancels a ongoing request/resolve that might be going on on
* the given channel. It does NOT kill the channel, use ares_destroy() for
* that.
*/
void ares_cancel(ares_channel channel)
{
struct query *query, *next;
int i;

for (query = channel->queries; query; query = next)
{
next = query->next;
query->callback(query->arg, ARES_ETIMEOUT, NULL, 0);
free(query->tcpbuf);
free(query->skip_server);
free(query);
}
channel->queries = NULL;
if (!(channel->flags & ARES_FLAG_STAYOPEN))
{
for (i = 0; i < channel->nservers; i++)
ares__close_sockets(&channel->servers[i]);
}
}

0 comments on commit 86ae234

Please sign in to comment.