diff options
author | Ulrich Drepper <drepper@redhat.com> | 2005-11-01 00:08:54 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2005-11-01 00:08:54 +0000 |
commit | cb07f6f67db0ef4ccbf3bedfb7c9c4f140773d2c (patch) | |
tree | 2524b26825fbddf3868e2e8a976f030d4e1dd626 /resolv/res_send.c | |
parent | 6ff8f07aba531a7f8641562889898b1a657d7d54 (diff) | |
download | glibc-cb07f6f67db0ef4ccbf3bedfb7c9c4f140773d2c.tar.gz glibc-cb07f6f67db0ef4ccbf3bedfb7c9c4f140773d2c.tar.xz glibc-cb07f6f67db0ef4ccbf3bedfb7c9c4f140773d2c.zip |
* resolv/res_init.c (__res_iclose): New function. Broken out of
res_nclose. Take addition parameter which determines whether addresses should be freed. (res_nclose): Call __res_iclose. (res_thread_freeres): Likewise. * resolv/res_data.c (res_close): Call __res_iclose. * resolv/res_libc.c (res_init): No need to separately free the addresses. (__res_maybe_init): Likewise. * resolv/res_send.c: Use __res_iclose instead of res_nclose. * resolv/Versions [GLIBC_PRIVATE]: Add __res_iclose. * include/resolv.h: Declare __res_iclose. Add libc_hidden_proto for __res_iclose. * hesiod/hesiod.c (__hesiod_res_set): No need to free name server addresses here again.
Diffstat (limited to 'resolv/res_send.c')
-rw-r--r-- | resolv/res_send.c | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/resolv/res_send.c b/resolv/res_send.c index e62cde2360..ff7be11509 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -381,7 +381,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, } } if (needclose) - res_nclose(statp); + __res_iclose(statp, false); } /* @@ -488,7 +488,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, done = 1; break; case res_nextns: - res_nclose(statp); + __res_iclose(statp, false); goto next_ns; case res_done: return (resplen); @@ -553,7 +553,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, */ if ((v_circuit && (statp->options & RES_USEVC) == 0) || (statp->options & RES_STAYOPEN) == 0) { - res_nclose(statp); + __res_iclose(statp, false); } if (statp->rhook) { int done = 0, loops = 0; @@ -570,7 +570,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, done = 1; break; case res_nextns: - res_nclose(statp); + __res_iclose(statp, false); goto next_ns; case res_modified: /* give the hook another try */ @@ -589,7 +589,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, next_ns: ; } /*foreach ns*/ } /*foreach retry*/ - res_nclose(statp); + __res_iclose(statp, false); if (!v_circuit) { if (!gotsomewhere) __set_errno (ECONNREFUSED); /* no nameservers found */ @@ -637,14 +637,14 @@ send_vc(res_state statp, if (getpeername(statp->_vcsock, (struct sockaddr *)&peer, &size) < 0 || !sock_eq(&peer, nsap)) { - res_nclose(statp); + __res_iclose(statp, false); statp->_flags &= ~RES_F_VC; } } if (statp->_vcsock < 0 || (statp->_flags & RES_F_VC) == 0) { if (statp->_vcsock >= 0) - res_nclose(statp); + __res_iclose(statp, false); statp->_vcsock = socket(nsap->sin6_family, SOCK_STREAM, 0); if (statp->_vcsock < 0) { @@ -660,7 +660,7 @@ send_vc(res_state statp, *terrno = errno; Aerror(statp, stderr, "connect/vc", errno, (struct sockaddr *) nsap); - res_nclose(statp); + __res_iclose(statp, false); return (0); } statp->_flags |= RES_F_VC; @@ -676,7 +676,7 @@ send_vc(res_state statp, != (INT16SZ + buflen)) { *terrno = errno; Perror(statp, stderr, "write failed", errno); - res_nclose(statp); + __res_iclose(statp, false); return (0); } /* @@ -694,7 +694,7 @@ send_vc(res_state statp, if (n <= 0) { *terrno = errno; Perror(statp, stderr, "read failed", errno); - res_nclose(statp); + __res_iclose(statp, false); /* * A long running process might get its TCP * connection reset if the remote server was @@ -706,10 +706,8 @@ send_vc(res_state statp, */ if (*terrno == ECONNRESET && !connreset) { connreset = 1; - res_nclose(statp); goto same_ns; } - res_nclose(statp); return (0); } resplen = ns_get16(ans); @@ -718,7 +716,7 @@ send_vc(res_state statp, ans = malloc (MAXPACKET); if (ans == NULL) { *terrno = ENOMEM; - res_nclose(statp); + __res_iclose(statp, false); return (0); } anssiz = MAXPACKET; @@ -743,7 +741,7 @@ send_vc(res_state statp, Dprint(statp->options & RES_DEBUG, (stdout, ";; undersized: %d\n", len)); *terrno = EMSGSIZE; - res_nclose(statp); + __res_iclose(statp, false); return (0); } cp = ans; @@ -754,7 +752,7 @@ send_vc(res_state statp, if (n <= 0) { *terrno = errno; Perror(statp, stderr, "read(vc)", errno); - res_nclose(statp); + __res_iclose(statp, false); return (0); } if (truncating) { @@ -847,7 +845,7 @@ send_dg(res_state statp, sizeof *nsap) < 0) { Aerror(statp, stderr, "connect(dg)", errno, (struct sockaddr *) nsap); - res_nclose(statp); + __res_iclose(statp, false); return (0); } /* Make socket non-blocking. */ @@ -879,7 +877,7 @@ send_dg(res_state statp, evNowTime(&now); if (evCmpTime(finish, now) <= 0) { Perror(statp, stderr, "select", errno); - res_nclose(statp); + __res_iclose(statp, false); return (0); } evSubTime(&timeout, &finish, &now); @@ -910,7 +908,7 @@ send_dg(res_state statp, } } Perror(statp, stderr, "poll", errno); - res_nclose(statp); + __res_iclose(statp, false); return (0); } __set_errno (0); @@ -919,7 +917,7 @@ send_dg(res_state statp, if (errno == EINTR || errno == EAGAIN) goto recompute_resend; Perror(statp, stderr, "send", errno); - res_nclose(statp); + __res_iclose(statp, false); return (0); } pfd[0].events = POLLIN; @@ -950,7 +948,7 @@ send_dg(res_state statp, goto wait; } Perror(statp, stderr, "recvfrom", errno); - res_nclose(statp); + __res_iclose(statp, false); return (0); } *gotsomewhere = 1; @@ -962,7 +960,7 @@ send_dg(res_state statp, (stdout, ";; undersized: %d\n", resplen)); *terrno = EMSGSIZE; - res_nclose(statp); + __res_iclose(statp, false); return (0); } if (hp->id != anhp->id) { @@ -1011,7 +1009,7 @@ send_dg(res_state statp, (stdout, "server rejected query:\n"), ans, (resplen > anssiz) ? anssiz : resplen); next_ns: - res_nclose(statp); + __res_iclose(statp, false); /* don't retry if called from dig */ if (!statp->pfcode) return (0); @@ -1031,7 +1029,7 @@ send_dg(res_state statp, Dprint(statp->options & RES_DEBUG, (stdout, ";; truncated answer\n")); *v_circuit = 1; - res_nclose(statp); + __res_iclose(statp, false); return (1); } /* @@ -1041,7 +1039,7 @@ send_dg(res_state statp, return (resplen); } else if (pfd[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { /* Something went wrong. We can stop trying. */ - res_nclose(statp); + __res_iclose(statp, false); return (0); } else { |