mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-22 19:00:07 +00:00
* resolv/res_send.c (send_dg): Create sockets with non-blocking
flag already set.
This commit is contained in:
parent
30c063710e
commit
9744268c10
@ -1,5 +1,8 @@
|
|||||||
2008-12-01 Ulrich Drepper <drepper@redhat.com>
|
2008-12-01 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* resolv/res_send.c (send_dg): Create sockets with non-blocking
|
||||||
|
flag already set.
|
||||||
|
|
||||||
* stdlib/setenv.c (unsetenv): Don't search environment if it does
|
* stdlib/setenv.c (unsetenv): Don't search environment if it does
|
||||||
not exist.
|
not exist.
|
||||||
* stdlib/Makefile (tests): Add tst-unsetenv1.
|
* stdlib/Makefile (tests): Add tst-unsetenv1.
|
||||||
|
@ -95,6 +95,7 @@ static const char rcsid[] = "$BINDId: res_send.c,v 8.38 2000/03/30 20:16:51 vixi
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <kernel-features.h>
|
||||||
|
|
||||||
#if PACKETSZ > 65536
|
#if PACKETSZ > 65536
|
||||||
#define MAXPACKET PACKETSZ
|
#define MAXPACKET PACKETSZ
|
||||||
@ -103,6 +104,13 @@ static const char rcsid[] = "$BINDId: res_send.c,v 8.38 2000/03/30 20:16:51 vixi
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __ASSUME_O_CLOEXEC
|
||||||
|
static int __have_o_nonblock;
|
||||||
|
#else
|
||||||
|
# define __have_o_nonblock 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* From ev_streams.c. */
|
/* From ev_streams.c. */
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@ -920,8 +928,20 @@ send_dg(res_state statp,
|
|||||||
if (EXT(statp).nssocks[ns] == -1) {
|
if (EXT(statp).nssocks[ns] == -1) {
|
||||||
/* only try IPv6 if IPv6 NS and if not failed before */
|
/* only try IPv6 if IPv6 NS and if not failed before */
|
||||||
if ((EXT(statp).nscount6 > 0) && !statp->ipv6_unavail) {
|
if ((EXT(statp).nscount6 > 0) && !statp->ipv6_unavail) {
|
||||||
EXT(statp).nssocks[ns] =
|
if (__have_o_nonblock >= 0) {
|
||||||
socket(PF_INET6, SOCK_DGRAM, 0);
|
EXT(statp).nssocks[ns] =
|
||||||
|
socket(PF_INET6, SOCK_DGRAM|SOCK_NONBLOCK,
|
||||||
|
0);
|
||||||
|
#ifndef __ASSUME_O_CLOEXEC
|
||||||
|
if (__have_o_nonblock == 0)
|
||||||
|
__have_o_nonblock
|
||||||
|
= (EXT(statp).nssocks[ns] == -1
|
||||||
|
&& errno == EINVAL ? -1 : 1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (__have_o_nonblock < 0)
|
||||||
|
EXT(statp).nssocks[ns] =
|
||||||
|
socket(PF_INET6, SOCK_DGRAM, 0);
|
||||||
if (EXT(statp).nssocks[ns] < 0)
|
if (EXT(statp).nssocks[ns] < 0)
|
||||||
statp->ipv6_unavail = errno == EAFNOSUPPORT;
|
statp->ipv6_unavail = errno == EAFNOSUPPORT;
|
||||||
/* If IPv6 socket and nsap is IPv4, make it
|
/* If IPv6 socket and nsap is IPv4, make it
|
||||||
@ -929,8 +949,22 @@ send_dg(res_state statp,
|
|||||||
else if (nsap->sin6_family == AF_INET)
|
else if (nsap->sin6_family == AF_INET)
|
||||||
convaddr4to6(nsap);
|
convaddr4to6(nsap);
|
||||||
}
|
}
|
||||||
if (EXT(statp).nssocks[ns] < 0)
|
if (EXT(statp).nssocks[ns] < 0) {
|
||||||
EXT(statp).nssocks[ns] = socket(PF_INET, SOCK_DGRAM, 0);
|
if (__have_o_nonblock >= 0) {
|
||||||
|
EXT(statp).nssocks[ns]
|
||||||
|
= socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK,
|
||||||
|
0);
|
||||||
|
#ifndef __ASSUME_O_CLOEXEC
|
||||||
|
if (__have_o_nonblock == 0)
|
||||||
|
__have_o_nonblock
|
||||||
|
= (EXT(statp).nssocks[ns] == -1
|
||||||
|
&& errno == EINVAL ? -1 : 1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (__have_o_nonblock < 0)
|
||||||
|
EXT(statp).nssocks[ns]
|
||||||
|
= socket(PF_INET, SOCK_DGRAM, 0);
|
||||||
|
}
|
||||||
if (EXT(statp).nssocks[ns] < 0) {
|
if (EXT(statp).nssocks[ns] < 0) {
|
||||||
*terrno = errno;
|
*terrno = errno;
|
||||||
Perror(statp, stderr, "socket(dg)", errno);
|
Perror(statp, stderr, "socket(dg)", errno);
|
||||||
@ -955,13 +989,15 @@ send_dg(res_state statp,
|
|||||||
__res_iclose(statp, false);
|
__res_iclose(statp, false);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
/* Make socket non-blocking. */
|
if (__have_o_nonblock < 0) {
|
||||||
int fl = __fcntl (EXT(statp).nssocks[ns], F_GETFL);
|
/* Make socket non-blocking. */
|
||||||
if (fl != -1)
|
int fl = __fcntl (EXT(statp).nssocks[ns], F_GETFL);
|
||||||
__fcntl (EXT(statp).nssocks[ns], F_SETFL,
|
if (fl != -1)
|
||||||
fl | O_NONBLOCK);
|
__fcntl (EXT(statp).nssocks[ns], F_SETFL,
|
||||||
Dprint(statp->options & RES_DEBUG,
|
fl | O_NONBLOCK);
|
||||||
(stdout, ";; new DG socket\n"))
|
Dprint(statp->options & RES_DEBUG,
|
||||||
|
(stdout, ";; new DG socket\n"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user