Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/lib/libc/resolv/res_send.c,v rcsdiff: /ftp/cvs/cvsroot/src/lib/libc/resolv/res_send.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.9.4.3 retrieving revision 1.10 diff -u -p -r1.9.4.3 -r1.10 --- src/lib/libc/resolv/res_send.c 2011/01/23 21:47:51 1.9.4.3 +++ src/lib/libc/resolv/res_send.c 2007/01/27 22:26:44 1.10 @@ -1,4 +1,4 @@ -/* $NetBSD: res_send.c,v 1.9.4.3 2011/01/23 21:47:51 bouyer Exp $ */ +/* $NetBSD: res_send.c,v 1.10 2007/01/27 22:26:44 christos Exp $ */ /* * Copyright (c) 1985, 1989, 1993 @@ -74,9 +74,9 @@ #if defined(LIBC_SCCS) && !defined(lint) #ifdef notdef static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "Id: res_send.c,v 1.9.18.10 2008/01/27 02:06:26 marka Exp"; +static const char rcsid[] = "Id: res_send.c,v 1.9.18.8 2006/10/16 23:00:58 marka Exp"; #else -__RCSID("$NetBSD: res_send.c,v 1.9.4.3 2011/01/23 21:47:51 bouyer Exp $"); +__RCSID("$NetBSD: res_send.c,v 1.10 2007/01/27 22:26:44 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -313,11 +313,11 @@ int res_nsend(res_state statp, const u_char *buf, int buflen, u_char *ans, int anssiz) { - int gotsomewhere, terrno, tries, v_circuit, resplen, ns, n; + int gotsomewhere, terrno, try, v_circuit, resplen, ns, n; char abuf[NI_MAXHOST]; #ifdef USE_POLL - highestFD = sysconf(_SC_OPEN_MAX) - 1; + highestFD = sysconf(_SC_OPEN_MAX) - 1; #endif /* No name servers or res_init() failure */ @@ -425,7 +425,7 @@ res_nsend(res_state statp, /* * Send request, RETRY times, or until successful. */ - for (tries = 0; tries < statp->retry; tries++) { + for (try = 0; try < statp->retry; try++) { for (ns = 0; ns < statp->nscount; ns++) { struct sockaddr *nsap; int nsaplen; @@ -473,7 +473,7 @@ res_nsend(res_state statp, if (v_circuit) { /* Use VC; at most one attempt per server. */ - tries = statp->retry; + try = statp->retry; n = send_vc(statp, buf, buflen, ans, anssiz, &terrno, ns); if (n < 0) @@ -484,7 +484,7 @@ res_nsend(res_state statp, } else { /* Use datagrams. */ n = send_dg(statp, buf, buflen, ans, anssiz, &terrno, - ns, tries, &v_circuit, &gotsomewhere); + ns, try, &v_circuit, &gotsomewhere); if (n < 0) goto fail; if (n == 0) @@ -621,9 +621,6 @@ send_vc(res_state statp, u_short len; u_char *cp; void *tmp; -#ifdef SO_NOSIGPIPE - int on = 1; -#endif nsap = get_nsaddr(statp, (size_t)ns); nsaplen = get_salen(nsap); @@ -669,17 +666,6 @@ 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, (socklen_t)nsaplen) < 0) { *terrno = errno; @@ -734,30 +720,30 @@ send_vc(res_state statp, goto same_ns; } res_nclose(statp); - return (0); -} -resplen = ns_get16(ans); -if (resplen > anssiz) { - Dprint(statp->options & RES_DEBUG, - (stdout, ";; response truncated\n") - ); - truncating = 1; - len = anssiz; -} else - len = resplen; -if (len < HFIXEDSZ) { - /* - * Undersized message. - */ - Dprint(statp->options & RES_DEBUG, - (stdout, ";; undersized: %d\n", len)); - *terrno = EMSGSIZE; - res_nclose(statp); - return (0); -} -cp = ans; -while (len != 0 && (n = read(statp->_vcsock, (char *)cp, (size_t)len)) > 0){ - cp += n; + return (0); + } + resplen = ns_get16(ans); + if (resplen > anssiz) { + Dprint(statp->options & RES_DEBUG, + (stdout, ";; response truncated\n") + ); + truncating = 1; + len = anssiz; + } else + len = resplen; + if (len < HFIXEDSZ) { + /* + * Undersized message. + */ + Dprint(statp->options & RES_DEBUG, + (stdout, ";; undersized: %d\n", len)); + *terrno = EMSGSIZE; + res_nclose(statp); + return (0); + } + cp = ans; + while (len != 0 && (n = read(statp->_vcsock, (char *)cp, (size_t)len)) > 0){ + cp += n; len -= n; } if (n <= 0) { @@ -807,7 +793,7 @@ while (len != 0 && (n = read(statp->_vcs static int send_dg(res_state statp, const u_char *buf, int buflen, u_char *ans, - int anssiz, int *terrno, int ns, int tries, int *v_circuit, + int anssiz, int *terrno, int ns, int try, int *v_circuit, int *gotsomewhere) { const HEADER *hp = (const HEADER *)(const void *)buf; @@ -889,7 +875,7 @@ send_dg(res_state statp, const u_char *b /* * Wait for reply. */ - seconds = (statp->retrans << tries); + seconds = (statp->retrans << try); if (ns > 0) seconds /= statp->nscount; if (seconds <= 0) @@ -912,7 +898,7 @@ send_dg(res_state statp, const u_char *b #else timeout = evSubTime(finish, now); if (timeout.tv_sec < 0) - timeout = evConsTime(0L, 0L); + timeout = evConsTime(0, 0); polltimeout = 1000*timeout.tv_sec + timeout.tv_nsec/1000000; pollfd.fd = s;