summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-01-28 22:03:48 +0000
committerDaniel Stenberg <daniel@haxx.se>2010-01-28 22:03:48 +0000
commit8b6f71ce9522d0199a00c8021e8ab2d08c799dbf (patch)
treec3ce757fec08b2ca42929b7eec3724fd601ec293
parent004c2e34004fcb12b1c33071efee8a7c4bfc8591 (diff)
downloadc-ares-8b6f71ce9522d0199a00c8021e8ab2d08c799dbf.tar.gz
c-ares-8b6f71ce9522d0199a00c8021e8ab2d08c799dbf.tar.bz2
c-ares-8b6f71ce9522d0199a00c8021e8ab2d08c799dbf.zip
- Tommie Gannert pointed out a silly bug in ares_process_fd() since it didn't
check for broken connections like ares_process() did. Based on that, I merged the two functions into a single generic one with two front-ends.
-rw-r--r--CHANGES5
-rw-r--r--RELEASE-NOTES3
-rw-r--r--ares_process.c47
3 files changed, 34 insertions, 21 deletions
diff --git a/CHANGES b/CHANGES
index 8ad0b9d..c3961c4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,10 @@
Changelog for the c-ares project
+* January 28, 2010 (Daniel Stenberg)
+- Tommie Gannert pointed out a silly bug in ares_process_fd() since it didn't
+ check for broken connections like ares_process() did. Based on that, I
+ merged the two functions into a single generic one with two front-ends.
+
* December 29, 2009 (Yang Tse)
- Laszlo Tamas Szabo adjusted Makefile.msvc compiler options so that where
run-time error checks enabling compiler option /GZ was used it is replaced
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index a444c2c..120ac29 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -8,9 +8,10 @@ Fixed:
o closing of sockets on Windows systems
o MSVC deprecated compiler options warnings
+ o ares_process_fd() didn't check broken connections
Thanks go to these friendly people for their efforts and contributions:
- Ingmar Runge, Laszlo Tamas Szabo
+ Ingmar Runge, Laszlo Tamas Szabo, Yang Tse, Tommie Gannert
Have fun!
diff --git a/ares_process.c b/ares_process.c
index 4b5f182..01036f5 100644
--- a/ares_process.c
+++ b/ares_process.c
@@ -1,7 +1,7 @@
/* $Id$ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
- * Copyright (C) 2004-2009 by Daniel Stenberg
+ * Copyright (C) 2004-2010 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -139,16 +139,18 @@ long ares__timeoffset(struct timeval *now,
}
-/* Something interesting happened on the wire, or there was a timeout.
- * See what's up and respond accordingly.
+/*
+ * generic process function
*/
-void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds)
+static void processfds(ares_channel channel,
+ fd_set *read_fds, ares_socket_t read_fd,
+ fd_set *write_fds, ares_socket_t write_fd)
{
struct timeval now = ares__tvnow();
- write_tcp_data(channel, write_fds, ARES_SOCKET_BAD, &now);
- read_tcp_data(channel, read_fds, ARES_SOCKET_BAD, &now);
- read_udp_packets(channel, read_fds, ARES_SOCKET_BAD, &now);
+ write_tcp_data(channel, write_fds, write_fd, &now);
+ read_tcp_data(channel, read_fds, read_fd, &now);
+ read_udp_packets(channel, read_fds, read_fd, &now);
process_timeouts(channel, &now);
process_broken_connections(channel, &now);
}
@@ -156,17 +158,20 @@ void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds)
/* Something interesting happened on the wire, or there was a timeout.
* See what's up and respond accordingly.
*/
+void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds)
+{
+ processfds(channel, read_fds, ARES_SOCKET_BAD, write_fds, ARES_SOCKET_BAD);
+}
+
+/* Something interesting happened on the wire, or there was a timeout.
+ * See what's up and respond accordingly.
+ */
void ares_process_fd(ares_channel channel,
ares_socket_t read_fd, /* use ARES_SOCKET_BAD or valid
file descriptors */
ares_socket_t write_fd)
{
- struct timeval now = ares__tvnow();
-
- write_tcp_data(channel, NULL, write_fd, &now);
- read_tcp_data(channel, NULL, read_fd, &now);
- read_udp_packets(channel, NULL, read_fd, &now);
- process_timeouts(channel, &now);
+ processfds(channel, NULL, read_fd, NULL, write_fd);
}
@@ -174,7 +179,8 @@ void ares_process_fd(ares_channel channel,
* otherwise. This is mostly for HP-UX, which could return EAGAIN or
* EWOULDBLOCK. See this man page
*
- * http://devrsrc1.external.hp.com/STKS/cgi-bin/man2html?manpage=/usr/share/man/man2.Z/send.2
+ * http://devrsrc1.external.hp.com/STKS/cgi-bin/man2html?
+ * manpage=/usr/share/man/man2.Z/send.2
*/
static int try_again(int errnum)
{
@@ -802,8 +808,9 @@ void ares__send_query(ares_channel channel, struct query *query,
}
/*
- * setsocknonblock sets the given socket to either blocking or non-blocking mode
- * based on the 'nonblock' boolean argument. This function is highly portable.
+ * setsocknonblock sets the given socket to either blocking or non-blocking
+ * mode based on the 'nonblock' boolean argument. This function is highly
+ * portable.
*/
static int setsocknonblock(ares_socket_t sockfd, /* operate on this */
int nonblock /* TRUE or FALSE */)
@@ -902,10 +909,10 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
#ifdef TCP_NODELAY
/*
- * Disable the Nagle algorithm (only relevant for TCP sockets, and thus not in
- * configure_socket). In general, in DNS lookups we're pretty much interested
- * in firing off a single request and then waiting for a reply, so batching
- * isn't very interesting in general.
+ * Disable the Nagle algorithm (only relevant for TCP sockets, and thus not
+ * in configure_socket). In general, in DNS lookups we're pretty much
+ * interested in firing off a single request and then waiting for a reply,
+ * so batching isn't very interesting in general.
*/
opt = 1;
if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY,