From 6c9d96e811b7ad4d8830714011c31e5c33506829 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 1 Apr 2004 08:25:58 +0000 Subject: Dirk Manske's ares_cancel() function was added. --- ares/CHANGES | 11 +++++++++++ ares/Makefile.in | 5 ++--- ares/ares.h | 2 +- ares/ares_cancel.3 | 37 +++++++++++++++++++++++++++++++++++++ ares/ares_cancel.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 ares/ares_cancel.3 create mode 100644 ares/ares_cancel.c diff --git a/ares/CHANGES b/ares/CHANGES index 056c6d677..39df0035e 100644 --- a/ares/CHANGES +++ b/ares/CHANGES @@ -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. @@ -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 diff --git a/ares/Makefile.in b/ares/Makefile.in index eac25cf94..53ff73f83 100644 --- a/ares/Makefile.in +++ b/ares/Makefile.in @@ -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} diff --git a/ares/ares.h b/ares/ares.h index 0dea2ff99..85bfe2315 100644 --- a/ares/ares.h +++ b/ares/ares.h @@ -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, diff --git a/ares/ares_cancel.3 b/ares/ares_cancel.3 new file mode 100644 index 000000000..fed7e4087 --- /dev/null +++ b/ares/ares_cancel.3 @@ -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 +.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 diff --git a/ares/ares_cancel.c b/ares/ares_cancel.c new file mode 100644 index 000000000..b127ed112 --- /dev/null +++ b/ares/ares_cancel.c @@ -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 +#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]); + } +} -- cgit v1.2.3