[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r7456 - in /fsf/trunk/libc: ChangeLog resolv/res_send.c stdlib/Makefile stdlib/setenv.c stdlib/tst-unsetenv1.c
- To: commits@xxxxxxxxxx
- Subject: [commits] r7456 - in /fsf/trunk/libc: ChangeLog resolv/res_send.c stdlib/Makefile stdlib/setenv.c stdlib/tst-unsetenv1.c
- From: eglibc@xxxxxxxxxx
- Date: Tue, 02 Dec 2008 08:02:48 -0000
Author: eglibc
Date: Tue Dec 2 00:02:31 2008
New Revision: 7456
Log:
Import glibc-mainline for 2008-12-02
Added:
fsf/trunk/libc/stdlib/tst-unsetenv1.c
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/resolv/res_send.c
fsf/trunk/libc/stdlib/Makefile
fsf/trunk/libc/stdlib/setenv.c
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Tue Dec 2 00:02:31 2008
@@ -1,3 +1,13 @@
+2008-12-01 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * 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
+ not exist.
+ * stdlib/Makefile (tests): Add tst-unsetenv1.
+ * stdlib/tst-unsetenv1.c: New file.
+
2008-11-29 Ulrich Drepper <drepper@xxxxxxxxxx>
* login/utmp_file.c (file_writable): New variable.
Modified: fsf/trunk/libc/resolv/res_send.c
==============================================================================
--- fsf/trunk/libc/resolv/res_send.c (original)
+++ fsf/trunk/libc/resolv/res_send.c Tue Dec 2 00:02:31 2008
@@ -95,11 +95,19 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <kernel-features.h>
#if PACKETSZ > 65536
#define MAXPACKET PACKETSZ
#else
#define MAXPACKET 65536
+#endif
+
+
+#ifndef __ASSUME_O_CLOEXEC
+static int __have_o_nonblock;
+#else
+# define __have_o_nonblock 0
#endif
@@ -920,8 +928,20 @@
if (EXT(statp).nssocks[ns] == -1) {
/* only try IPv6 if IPv6 NS and if not failed before */
if ((EXT(statp).nscount6 > 0) && !statp->ipv6_unavail) {
- EXT(statp).nssocks[ns] =
- socket(PF_INET6, SOCK_DGRAM, 0);
+ if (__have_o_nonblock >= 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)
statp->ipv6_unavail = errno == EAFNOSUPPORT;
/* If IPv6 socket and nsap is IPv4, make it
@@ -929,8 +949,22 @@
else if (nsap->sin6_family == AF_INET)
convaddr4to6(nsap);
}
- if (EXT(statp).nssocks[ns] < 0)
- EXT(statp).nssocks[ns] = socket(PF_INET, SOCK_DGRAM, 0);
+ if (EXT(statp).nssocks[ns] < 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) {
*terrno = errno;
Perror(statp, stderr, "socket(dg)", errno);
@@ -955,13 +989,15 @@
__res_iclose(statp, false);
return (0);
}
- /* Make socket non-blocking. */
- int fl = __fcntl (EXT(statp).nssocks[ns], F_GETFL);
- if (fl != -1)
- __fcntl (EXT(statp).nssocks[ns], F_SETFL,
- fl | O_NONBLOCK);
- Dprint(statp->options & RES_DEBUG,
- (stdout, ";; new DG socket\n"))
+ if (__have_o_nonblock < 0) {
+ /* Make socket non-blocking. */
+ int fl = __fcntl (EXT(statp).nssocks[ns], F_GETFL);
+ if (fl != -1)
+ __fcntl (EXT(statp).nssocks[ns], F_SETFL,
+ fl | O_NONBLOCK);
+ Dprint(statp->options & RES_DEBUG,
+ (stdout, ";; new DG socket\n"))
+ }
}
/*
Modified: fsf/trunk/libc/stdlib/Makefile
==============================================================================
--- fsf/trunk/libc/stdlib/Makefile (original)
+++ fsf/trunk/libc/stdlib/Makefile Tue Dec 2 00:02:31 2008
@@ -69,7 +69,7 @@
test-a64l tst-qsort tst-system testmb2 bug-strtod2 \
tst-atof1 tst-atof2 tst-strtod2 tst-strtod3 tst-rand48-2 \
tst-makecontext tst-strtod4 tst-strtod5 tst-qsort2 \
- tst-makecontext2 tst-strtod6
+ tst-makecontext2 tst-strtod6 tst-unsetenv1
include ../Makeconfig
Modified: fsf/trunk/libc/stdlib/setenv.c
==============================================================================
--- fsf/trunk/libc/stdlib/setenv.c (original)
+++ fsf/trunk/libc/stdlib/setenv.c Tue Dec 2 00:02:31 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,1995-2001,2004 Free Software Foundation, Inc.
+/* Copyright (C) 1992,1995-2001,2004, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -292,19 +292,20 @@
LOCK;
ep = __environ;
- while (*ep != NULL)
- if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
- {
- /* Found it. Remove this pointer by moving later ones back. */
- char **dp = ep;
-
- do
- dp[0] = dp[1];
- while (*dp++);
- /* Continue the loop in case NAME appears again. */
- }
- else
- ++ep;
+ if (ep != NULL)
+ while (*ep != NULL)
+ if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
+ {
+ /* Found it. Remove this pointer by moving later ones back. */
+ char **dp = ep;
+
+ do
+ dp[0] = dp[1];
+ while (*dp++);
+ /* Continue the loop in case NAME appears again. */
+ }
+ else
+ ++ep;
UNLOCK;
Added: fsf/trunk/libc/stdlib/tst-unsetenv1.c
==============================================================================
--- fsf/trunk/libc/stdlib/tst-unsetenv1.c (added)
+++ fsf/trunk/libc/stdlib/tst-unsetenv1.c Tue Dec 2 00:02:31 2008
@@ -1,0 +1,12 @@
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+ clearenv ();
+ unsetenv ("FOO");
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"