summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-04-01 08:25:58 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-04-01 08:25:58 +0000
commit86ae23430cb79b38dec419ebf9cf3f85073e091c (patch)
tree47daf64ba656da8b9c0258c69a4c9b627a0aec96
parent8ede9dd9c9f899707feec5345ef7dee79dc3674a (diff)
downloadc-ares-86ae23430cb79b38dec419ebf9cf3f85073e091c.tar.gz
c-ares-86ae23430cb79b38dec419ebf9cf3f85073e091c.tar.bz2
c-ares-86ae23430cb79b38dec419ebf9cf3f85073e091c.zip
Dirk Manske's ares_cancel() function was added.
-rw-r--r--CHANGES11
-rw-r--r--Makefile.in5
-rw-r--r--ares.h2
-rw-r--r--ares_cancel.337
-rw-r--r--ares_cancel.c44
5 files changed, 95 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index 056c6d6..39df003 100644
--- a/CHANGES
+++ b/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/Makefile.in b/Makefile.in
index eac25cf..53ff73f 100644
--- a/Makefile.in
+++ b/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.h b/ares.h
index 0dea2ff..85bfe23 100644
--- a/ares.h
+++ b/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_cancel.3 b/ares_cancel.3
new file mode 100644
index 0000000..fed7e40
--- /dev/null
+++ b/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 <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
diff --git a/ares_cancel.c b/ares_cancel.c
new file mode 100644
index 0000000..b127ed1
--- /dev/null
+++ b/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 <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]);
+ }
+}