aboutsummaryrefslogtreecommitdiff
path: root/lib/bind/resolv/res_send.c
diff options
context:
space:
mode:
authorDoug Barton <dougb@FreeBSD.org>2008-07-12 08:12:46 +0000
committerDoug Barton <dougb@FreeBSD.org>2008-07-12 08:12:46 +0000
commitcba78608de638f8cc6d1d48a2b3072e82386b70d (patch)
tree2857dd6ab984105d7ac37bbcfc816607c48ccc1d /lib/bind/resolv/res_send.c
parentf16b9a8f9e30675de8048c5832ffbb3f50f2fdc4 (diff)
Vendor import of BIND 9.3.5vendor/bind9/9.3.5
Notes
Notes: svn path=/vendor/bind9/dist-9.3/; revision=180470 svn path=/vendor/bind9/9.3.5/; revision=180471; tag=vendor/bind9/9.3.5
Diffstat (limited to 'lib/bind/resolv/res_send.c')
-rw-r--r--lib/bind/resolv/res_send.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/bind/resolv/res_send.c b/lib/bind/resolv/res_send.c
index c47dd49bc6e8..bc3cc923814a 100644
--- a/lib/bind/resolv/res_send.c
+++ b/lib/bind/resolv/res_send.c
@@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_send.c,v 1.5.2.2.4.9 2006/10/16 23:00:50 marka Exp $";
+static const char rcsid[] = "$Id: res_send.c,v 1.5.2.2.4.11 2008/01/27 02:06:07 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -288,7 +288,7 @@ int
res_nsend(res_state statp,
const u_char *buf, int buflen, u_char *ans, int anssiz)
{
- int gotsomewhere, terrno, try, v_circuit, resplen, ns, n;
+ int gotsomewhere, terrno, tries, v_circuit, resplen, ns, n;
char abuf[NI_MAXHOST];
#ifdef USE_POLL
@@ -400,7 +400,7 @@ res_nsend(res_state statp,
/*
* Send request, RETRY times, or until successful.
*/
- for (try = 0; try < statp->retry; try++) {
+ for (tries = 0; tries < statp->retry; tries++) {
for (ns = 0; ns < statp->nscount; ns++) {
struct sockaddr *nsap;
int nsaplen;
@@ -448,7 +448,7 @@ res_nsend(res_state statp,
if (v_circuit) {
/* Use VC; at most one attempt per server. */
- try = statp->retry;
+ tries = statp->retry;
n = send_vc(statp, buf, buflen, ans, anssiz, &terrno,
ns);
if (n < 0)
@@ -459,7 +459,7 @@ res_nsend(res_state statp,
} else {
/* Use datagrams. */
n = send_dg(statp, buf, buflen, ans, anssiz, &terrno,
- ns, try, &v_circuit, &gotsomewhere);
+ ns, tries, &v_circuit, &gotsomewhere);
if (n < 0)
goto fail;
if (n == 0)
@@ -596,6 +596,9 @@ send_vc(res_state statp,
u_short len;
u_char *cp;
void *tmp;
+#ifdef SO_NOSIGPIPE
+ int on = 1;
+#endif
nsap = get_nsaddr(statp, ns);
nsaplen = get_salen(nsap);
@@ -641,6 +644,17 @@ send_vc(res_state statp,
return (-1);
}
}
+#ifdef SO_NOSIGPIPE
+ /*
+ * Disable generation of SIGPIPE when writing to a closed
+ * socket. Write should return -1 and set errno to EPIPE
+ * instead.
+ *
+ * Push on even if setsockopt(SO_NOSIGPIPE) fails.
+ */
+ (void)setsockopt(statp->_vcsock, SOL_SOCKET, SO_NOSIGPIPE, &on,
+ sizeof(on));
+#endif
errno = 0;
if (connect(statp->_vcsock, nsap, nsaplen) < 0) {
*terrno = errno;
@@ -768,7 +782,7 @@ send_vc(res_state statp,
static int
send_dg(res_state statp, const u_char *buf, int buflen, u_char *ans,
- int anssiz, int *terrno, int ns, int try, int *v_circuit,
+ int anssiz, int *terrno, int ns, int tries, int *v_circuit,
int *gotsomewhere)
{
const HEADER *hp = (const HEADER *) buf;
@@ -850,7 +864,7 @@ send_dg(res_state statp, const u_char *buf, int buflen, u_char *ans,
/*
* Wait for reply.
*/
- seconds = (statp->retrans << try);
+ seconds = (statp->retrans << tries);
if (ns > 0)
seconds /= statp->nscount;
if (seconds <= 0)