aboutsummaryrefslogtreecommitdiff
path: root/lib/isc/unix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/isc/unix')
-rw-r--r--lib/isc/unix/Makefile.in8
-rw-r--r--lib/isc/unix/app.c20
-rw-r--r--lib/isc/unix/dir.c8
-rw-r--r--lib/isc/unix/entropy.c7
-rw-r--r--lib/isc/unix/errno2result.c8
-rw-r--r--lib/isc/unix/file.c8
-rw-r--r--lib/isc/unix/ifiter_getifaddrs.c10
-rw-r--r--lib/isc/unix/ifiter_ioctl.c13
-rw-r--r--lib/isc/unix/include/isc/dir.h8
-rw-r--r--lib/isc/unix/include/isc/strerror.h8
-rw-r--r--lib/isc/unix/include/isc/time.h8
-rw-r--r--lib/isc/unix/keyboard.c8
-rw-r--r--lib/isc/unix/net.c29
-rw-r--r--lib/isc/unix/os.c8
-rw-r--r--lib/isc/unix/resource.c77
-rw-r--r--lib/isc/unix/socket.c99
-rw-r--r--lib/isc/unix/stdtime.c8
-rw-r--r--lib/isc/unix/strerror.c8
-rw-r--r--lib/isc/unix/syslog.c10
19 files changed, 198 insertions, 155 deletions
diff --git a/lib/isc/unix/Makefile.in b/lib/isc/unix/Makefile.in
index 49845d420d5b..725ba68441da 100644
--- a/lib/isc/unix/Makefile.in
+++ b/lib/isc/unix/Makefile.in
@@ -1,7 +1,7 @@
-# Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
-# Copyright (C) 1998-2001 Internet Software Consortium.
+# Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 1998-2001, 2003 Internet Software Consortium.
#
-# Permission to use, copy, modify, and distribute this software for any
+# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
@@ -13,7 +13,7 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
-# $Id: Makefile.in,v 1.35.2.1.10.2 2004/06/22 02:48:36 marka Exp $
+# $Id: Makefile.in,v 1.35.2.1.10.5 2007/08/28 07:19:17 tbox Exp $
srcdir = @srcdir@
VPATH = @srcdir@
diff --git a/lib/isc/unix/app.c b/lib/isc/unix/app.c
index 811d67be1ff6..8e1f0fafd306 100644
--- a/lib/isc/unix/app.c
+++ b/lib/isc/unix/app.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: app.c,v 1.43.2.3.8.5 2004/03/08 02:08:05 marka Exp $ */
+/* $Id: app.c,v 1.43.2.3.8.8 2008/01/17 23:45:28 tbox Exp $ */
#include <config.h>
@@ -57,11 +57,11 @@ static isc_boolean_t running = ISC_FALSE;
/*
* We assume that 'want_shutdown' can be read and written atomically.
*/
-static isc_boolean_t want_shutdown = ISC_FALSE;
+static volatile isc_boolean_t want_shutdown = ISC_FALSE;
/*
* We assume that 'want_reload' can be read and written atomically.
*/
-static isc_boolean_t want_reload = ISC_FALSE;
+static volatile isc_boolean_t want_reload = ISC_FALSE;
static isc_boolean_t blocked = ISC_FALSE;
#ifdef ISC_PLATFORM_USETHREADS
@@ -85,13 +85,13 @@ static pthread_t main_thread;
#ifndef HAVE_SIGWAIT
static void
exit_action(int arg) {
- UNUSED(arg);
+ UNUSED(arg);
want_shutdown = ISC_TRUE;
}
static void
reload_action(int arg) {
- UNUSED(arg);
+ UNUSED(arg);
want_reload = ISC_TRUE;
}
#endif
@@ -337,7 +337,7 @@ evloop() {
* We call isc__timermgr_dispatch() only when
* necessary, in order to reduce overhead. If the
* select() call indicates a timeout, we need the
- * dispatch. Even if not, if we set the 0-timeout
+ * dispatch. Even if not, if we set the 0-timeout
* for the select() call, we need to check the timer
* events. In the 'readytasks' case, there may be no
* timeout event actually, but there is no other way
@@ -421,7 +421,7 @@ isc__nothread_signal_hack(isc_condition_t *cp) {
signalled = ISC_TRUE;
return (ISC_R_SUCCESS);
}
-
+
#endif /* ISC_PLATFORM_USETHREADS */
isc_result_t
@@ -674,7 +674,7 @@ isc_app_unblock(void) {
REQUIRE(blockedthread == pthread_self());
RUNTIME_CHECK(sigemptyset(&sset) == 0 &&
- sigaddset(&sset, SIGINT) == 0 &&
+ sigaddset(&sset, SIGINT) == 0 &&
sigaddset(&sset, SIGTERM) == 0);
RUNTIME_CHECK(pthread_sigmask(SIG_BLOCK, &sset, NULL) == 0);
#endif /* ISC_PLATFORM_USETHREADS */
diff --git a/lib/isc/unix/dir.c b/lib/isc/unix/dir.c
index 85a121739b4c..29afb0f264b0 100644
--- a/lib/isc/unix/dir.c
+++ b/lib/isc/unix/dir.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1999-2001 Internet Software Consortium.
+ * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2001, 2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dir.c,v 1.18.2.1.2.3 2004/03/08 09:04:55 marka Exp $ */
+/* $Id: dir.c,v 1.18.2.1.2.6 2007/08/28 07:19:17 tbox Exp $ */
/* Principal Authors: DCL */
diff --git a/lib/isc/unix/entropy.c b/lib/isc/unix/entropy.c
index d52849aa35b8..f30a4725dcdc 100644
--- a/lib/isc/unix/entropy.c
+++ b/lib/isc/unix/entropy.c
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: entropy.c,v 1.60.2.3.8.14 2006/03/02 23:29:17 marka Exp $ */
+/* $Id: entropy.c,v 1.60.2.3.8.15 2006/12/07 04:52:50 marka Exp $ */
/*
* This is the system depenedent part of the ISC entropy API.
@@ -486,8 +486,6 @@ isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname) {
LOCK(&ent->lock);
- source = NULL;
-
if (stat(fname, &_stat) < 0) {
ret = isc__errno2result(errno);
goto errout;
@@ -589,9 +587,6 @@ isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname) {
(void)close(fd);
errout:
- if (source != NULL)
- isc_mem_put(ent->mctx, source, sizeof(isc_entropysource_t));
-
UNLOCK(&ent->lock);
return (ret);
diff --git a/lib/isc/unix/errno2result.c b/lib/isc/unix/errno2result.c
index 66a4e916d79c..d25dcb288f50 100644
--- a/lib/isc/unix/errno2result.c
+++ b/lib/isc/unix/errno2result.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 2000-2002 Internet Software Consortium.
+ * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2000-2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: errno2result.c,v 1.8.2.4.8.1 2004/03/06 08:14:59 marka Exp $ */
+/* $Id: errno2result.c,v 1.8.2.4.8.4 2007/08/28 07:19:17 tbox Exp $ */
#include <config.h>
diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c
index 7ed6272efb73..8e4e87c6077c 100644
--- a/lib/isc/unix/file.c
+++ b/lib/isc/unix/file.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 2000-2002 Internet Software Consortium.
+ * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2000-2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -48,7 +48,7 @@
* SUCH DAMAGE.
*/
-/* $Id: file.c,v 1.38.12.8 2004/03/16 05:50:25 marka Exp $ */
+/* $Id: file.c,v 1.38.12.11 2007/08/28 07:19:17 tbox Exp $ */
#include <config.h>
diff --git a/lib/isc/unix/ifiter_getifaddrs.c b/lib/isc/unix/ifiter_getifaddrs.c
index ad6e1e0b0409..ac4edc8922c3 100644
--- a/lib/isc/unix/ifiter_getifaddrs.c
+++ b/lib/isc/unix/ifiter_getifaddrs.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: ifiter_getifaddrs.c,v 1.2.68.3 2004/03/06 08:14:59 marka Exp $ */
+/* $Id: ifiter_getifaddrs.c,v 1.2.68.6 2007/08/28 07:19:17 tbox Exp $ */
/*
* Obtain the list of network interfaces using the getifaddrs(3) library.
@@ -106,7 +106,9 @@ internal_current(isc_interfaceiter_t *iter) {
INSIST(ifa != NULL);
INSIST(ifa->ifa_name != NULL);
- INSIST(ifa->ifa_addr != NULL);
+
+ if (ifa->ifa_addr == NULL)
+ return (ISC_R_IGNORE);
family = ifa->ifa_addr->sa_family;
if (family != AF_INET && family != AF_INET6)
diff --git a/lib/isc/unix/ifiter_ioctl.c b/lib/isc/unix/ifiter_ioctl.c
index 68a13651bc86..ce8baf7e99eb 100644
--- a/lib/isc/unix/ifiter_ioctl.c
+++ b/lib/isc/unix/ifiter_ioctl.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: ifiter_ioctl.c,v 1.19.2.5.2.19 2006/02/03 23:51:37 marka Exp $ */
+/* $Id: ifiter_ioctl.c,v 1.19.2.5.2.21 2007/08/31 23:45:57 tbox Exp $ */
/*
* Obtain the list of network interfaces using the SIOCGLIFCONF ioctl.
@@ -904,7 +904,8 @@ internal_next4(isc_interfaceiter_t *iter) {
struct ifreq *ifrp;
#endif
- REQUIRE (iter->pos < (unsigned int) iter->ifc.ifc_len);
+ REQUIRE(iter->ifc.ifc_len == 0 ||
+ iter->pos < (unsigned int) iter->ifc.ifc_len);
#ifdef __linux
if (linux_if_inet6_next(iter) == ISC_R_SUCCESS)
@@ -912,6 +913,10 @@ internal_next4(isc_interfaceiter_t *iter) {
if (!iter->first)
return (ISC_R_SUCCESS);
#endif
+
+ if (iter->ifc.ifc_len == 0)
+ return (ISC_R_NOMORE);
+
#ifdef ISC_PLATFORM_HAVESALEN
ifrp = (struct ifreq *)((char *) iter->ifc.ifc_req + iter->pos);
diff --git a/lib/isc/unix/include/isc/dir.h b/lib/isc/unix/include/isc/dir.h
index 53b51df087b1..e9e965963bac 100644
--- a/lib/isc/unix/include/isc/dir.h
+++ b/lib/isc/unix/include/isc/dir.h
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1999-2001 Internet Software Consortium.
+ * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2001, 2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dir.h,v 1.15.12.3 2004/03/08 09:04:57 marka Exp $ */
+/* $Id: dir.h,v 1.15.12.6 2007/08/28 07:19:17 tbox Exp $ */
/* Principal Authors: DCL */
diff --git a/lib/isc/unix/include/isc/strerror.h b/lib/isc/unix/include/isc/strerror.h
index f51fbdc2d04c..7577b1ccb2e6 100644
--- a/lib/isc/unix/include/isc/strerror.h
+++ b/lib/isc/unix/include/isc/strerror.h
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 2001 Internet Software Consortium.
+ * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2001, 2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: strerror.h,v 1.2.12.3 2004/03/08 09:04:57 marka Exp $ */
+/* $Id: strerror.h,v 1.2.12.6 2007/08/28 07:19:17 tbox Exp $ */
#ifndef ISC_STRERROR_H
#define ISC_STRERROR_H
diff --git a/lib/isc/unix/include/isc/time.h b/lib/isc/unix/include/isc/time.h
index 6021c13d9295..c592862c6e01 100644
--- a/lib/isc/unix/include/isc/time.h
+++ b/lib/isc/unix/include/isc/time.h
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1998-2001 Internet Software Consortium.
+ * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1998-2001, 2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: time.h,v 1.25.2.1.10.4 2004/03/08 09:04:58 marka Exp $ */
+/* $Id: time.h,v 1.25.2.1.10.7 2007/08/28 07:19:17 tbox Exp $ */
#ifndef ISC_TIME_H
#define ISC_TIME_H 1
diff --git a/lib/isc/unix/keyboard.c b/lib/isc/unix/keyboard.c
index 146338aebe75..5828ef0461d7 100644
--- a/lib/isc/unix/keyboard.c
+++ b/lib/isc/unix/keyboard.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 2000, 2001 Internet Software Consortium.
+ * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: keyboard.c,v 1.9.12.3 2004/03/08 09:04:56 marka Exp $ */
+/* $Id: keyboard.c,v 1.9.12.6 2007/08/28 07:19:17 tbox Exp $ */
#include <config.h>
diff --git a/lib/isc/unix/net.c b/lib/isc/unix/net.c
index e0aeccbbbf4d..42cadec7d761 100644
--- a/lib/isc/unix/net.c
+++ b/lib/isc/unix/net.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: net.c,v 1.22.2.2.10.9 2005/03/17 03:58:33 marka Exp $ */
+/* $Id: net.c,v 1.22.2.2.10.11 2007/09/13 23:45:58 tbox Exp $ */
#include <config.h>
@@ -30,17 +30,26 @@
#include <isc/string.h>
#include <isc/util.h>
-#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY)
+#if defined(ISC_PLATFORM_HAVEIPV6)
+# if defined(ISC_PLATFORM_NEEDIN6ADDRANY)
const struct in6_addr isc_net_in6addrany = IN6ADDR_ANY_INIT;
-#endif
+# endif
-#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK)
+# if defined(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK)
const struct in6_addr isc_net_in6addrloop = IN6ADDR_LOOPBACK_INIT;
-#endif
+# endif
-static isc_once_t once = ISC_ONCE_INIT;
+# if defined(WANT_IPV6)
static isc_once_t once_ipv6only = ISC_ONCE_INIT;
+# endif
+
+# if defined(ISC_PLATFORM_HAVEIN6PKTINFO)
static isc_once_t once_ipv6pktinfo = ISC_ONCE_INIT;
+# endif
+#endif /* ISC_PLATFORM_HAVEIPV6 */
+
+static isc_once_t once = ISC_ONCE_INIT;
+
static isc_result_t ipv4_result = ISC_R_NOTFOUND;
static isc_result_t ipv6_result = ISC_R_NOTFOUND;
static isc_result_t ipv6only_result = ISC_R_NOTFOUND;
@@ -235,7 +244,7 @@ initialize_ipv6only(void) {
RUNTIME_CHECK(isc_once_do(&once_ipv6only,
try_ipv6only) == ISC_R_SUCCESS);
}
-#endif /* IPV6_V6ONLY */
+#endif /* WANT_IPV6 */
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
static void
@@ -291,7 +300,7 @@ initialize_ipv6pktinfo(void) {
try_ipv6pktinfo) == ISC_R_SUCCESS);
}
#endif /* ISC_PLATFORM_HAVEIN6PKTINFO */
-#endif /* WANT_IPV6 */
+#endif /* ISC_PLATFORM_HAVEIPV6 */
isc_result_t
isc_net_probe_ipv6only(void) {
diff --git a/lib/isc/unix/os.c b/lib/isc/unix/os.c
index 4d34d8ce6f47..fb37acdca61d 100644
--- a/lib/isc/unix/os.c
+++ b/lib/isc/unix/os.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 2000, 2001 Internet Software Consortium.
+ * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: os.c,v 1.11.12.6 2005/10/14 02:13:07 marka Exp $ */
+/* $Id: os.c,v 1.11.12.9 2007/08/28 07:19:17 tbox Exp $ */
#include <config.h>
diff --git a/lib/isc/unix/resource.c b/lib/isc/unix/resource.c
index b6faf32a5e4d..bfec43d32d45 100644
--- a/lib/isc/unix/resource.c
+++ b/lib/isc/unix/resource.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000, 2001 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: resource.c,v 1.11.206.1 2004/03/06 08:15:01 marka Exp $ */
+/* $Id: resource.c,v 1.11.206.3 2008/01/26 23:45:31 tbox Exp $ */
#include <config.h>
@@ -40,13 +40,13 @@ resource2rlim(isc_resource_t resource, int *rlim_resource) {
break;
case isc_resource_cputime:
*rlim_resource = RLIMIT_CPU;
- break;
+ break;
case isc_resource_datasize:
*rlim_resource = RLIMIT_DATA;
- break;
+ break;
case isc_resource_filesize:
*rlim_resource = RLIMIT_FSIZE;
- break;
+ break;
case isc_resource_lockedmemory:
#ifdef RLIMIT_MEMLOCK
*rlim_resource = RLIMIT_MEMLOCK;
@@ -79,7 +79,7 @@ resource2rlim(isc_resource_t resource, int *rlim_resource) {
*rlim_resource = RLIMIT_STACK;
break;
default:
- /*
+ /*
* This test is not very robust if isc_resource_t
* changes, but generates a clear assertion message.
*/
@@ -132,58 +132,27 @@ isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) {
rlim_value = value;
}
- /*
- * The BIND 8 documentation reports:
- *
- * Note: on some operating systems the server cannot set an
- * unlimited value and cannot determine the maximum number of
- * open files the kernel can support. On such systems, choosing
- * unlimited will cause the server to use the larger of the
- * rlim_max for RLIMIT_NOFILE and the value returned by
- * sysconf(_SC_OPEN_MAX). If the actual kernel limit is larger
- * than this value, use limit files to specify the limit
- * explicitly.
- *
- * The CHANGES for 8.1.2-T3A also mention:
- *
- * 352. [bug] Because of problems with setting an infinite
- * rlim_max for RLIMIT_NOFILE on some systems, previous versions
- * of the server implemented "limit files unlimited" by setting
- * the limit to the value returned by sysconf(_SC_OPEN_MAX). The
- * server will now use RLIM_INFINITY on systems which allow it.
- *
- * At some point the BIND 8 server stopped using SC_OPEN_MAX for this
- * purpose at all, but it isn't clear to me when or why, as my access
- * to the CVS archive is limited at the time of this writing. What
- * BIND 8 *does* do is to set RLIMIT_NOFILE to either RLIMIT_INFINITY
- * on a half dozen operating systems or to FD_SETSIZE on the rest,
- * the latter of which is probably fewer than the real limit. (Note
- * that libisc's socket module will have problems with any fd over
- * FD_SETSIZE. This should be fixed in the socket module, not a
- * limitation here. BIND 8's eventlib also has a problem, making
- * its RLIMIT_INFINITY setting useless, because it closes and ignores
- * any fd over FD_SETSIZE.)
- *
- * More troubling is the reference to some operating systems not being
- * able to set an unlimited value for the number of open files. I'd
- * hate to put in code that is really only there to support archaic
- * systems that the rest of libisc won't work on anyway. So what this
- * extremely verbose comment is here to say is the following:
- *
- * I'm aware there might be an issue with not limiting the value
- * for RLIMIT_NOFILE on some systems, but since I don't know yet
- * what those systems are and what the best workaround is (use
- * sysconf()? rlim_max from getrlimit()? FD_SETSIZE?) so nothing
- * is currently being done to clamp the value for open files.
- */
-
rl.rlim_cur = rl.rlim_max = rlim_value;
unixresult = setrlimit(unixresource, &rl);
if (unixresult == 0)
return (ISC_R_SUCCESS);
- else
- return (isc__errno2result(errno));
+
+#if defined(OPEN_MAX) && defined(__APPLE__)
+ /*
+ * The Darwin kernel doesn't accept RLIM_INFINITY for rlim_cur; the
+ * maximum possible value is OPEN_MAX. BIND8 used to use
+ * sysconf(_SC_OPEN_MAX) for such a case, but this value is much
+ * smaller than OPEN_MAX and is not really effective.
+ */
+ if (resource == isc_resource_openfiles && rlim_value == RLIM_INFINITY) {
+ rl.rlim_cur = OPEN_MAX;
+ unixresult = setrlimit(unixresource, &rl);
+ if (unixresult == 0)
+ return (ISC_R_SUCCESS);
+ }
+#endif
+ return (isc__errno2result(errno));
}
isc_result_t
diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c
index f95e3c8f75d4..7322abc2518e 100644
--- a/lib/isc/unix/socket.c
+++ b/lib/isc/unix/socket.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: socket.c,v 1.207.2.19.2.26 2006/05/19 02:53:36 marka Exp $ */
+/* $Id: socket.c,v 1.207.2.19.2.35 2008/01/27 02:06:07 marka Exp $ */
#include <config.h>
@@ -42,6 +42,7 @@
#include <isc/msgs.h>
#include <isc/mutex.h>
#include <isc/net.h>
+#include <isc/once.h>
#include <isc/platform.h>
#include <isc/print.h>
#include <isc/region.h>
@@ -57,6 +58,10 @@
#include "socket_p.h"
#endif /* ISC_PLATFORM_USETHREADS */
+#if defined(SO_BSDCOMPAT) && defined(__linux__)
+#include <sys/utsname.h>
+#endif
+
/*
* Some systems define the socket length argument as an int, some as size_t,
* some as socklen_t. This is here so it can be easily changed if needed.
@@ -400,7 +405,7 @@ select_readmsg(isc_socketmgr_t *mgr, int *fd, int *msg) {
"read() failed "
"during watcher poke: %s"),
strbuf);
-
+
return;
}
INSIST(cc == sizeof(buf));
@@ -505,7 +510,7 @@ cmsg_space(ISC_SOCKADDR_LEN_T len) {
return ((char *)cmsgp - (char *)msg.msg_control);
else
return (0);
-#endif
+#endif
}
#endif /* USE_CMSG */
@@ -579,7 +584,7 @@ process_cmsg(isc_socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
"interface received on ifindex %u",
dev->pktinfo.ipi6_ifindex);
if (IN6_IS_ADDR_MULTICAST(&pktinfop->ipi6_addr))
- dev->attributes |= ISC_SOCKEVENTATTR_MULTICAST;
+ dev->attributes |= ISC_SOCKEVENTATTR_MULTICAST;
goto next;
}
#endif
@@ -951,7 +956,7 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) {
isc__strerror(recv_errno, strbuf, sizeof(strbuf));
socket_log(sock, NULL, IOEVENT,
isc_msgcat, ISC_MSGSET_SOCKET,
- ISC_MSG_DOIORECV,
+ ISC_MSG_DOIORECV,
"doio_recv: recvmsg(%d) %d bytes, err %d/%s",
sock->fd, cc, recv_errno, strbuf);
}
@@ -999,7 +1004,7 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) {
if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) {
socket_log(sock, &dev->address, IOEVENT,
isc_msgcat, ISC_MSGSET_SOCKET,
- ISC_MSG_ZEROPORT,
+ ISC_MSG_ZEROPORT,
"dropping source port zero packet");
}
return (DOIO_SOFT);
@@ -1368,7 +1373,45 @@ free_socket(isc_socket_t **socketp) {
*socketp = NULL;
}
+#ifdef SO_BSDCOMPAT
/*
+ * This really should not be necessary to do. Having to workout
+ * which kernel version we are on at run time so that we don't cause
+ * the kernel to issue a warning about us using a deprecated socket option.
+ * Such warnings should *never* be on by default in production kernels.
+ *
+ * We can't do this a build time because executables are moved between
+ * machines and hence kernels.
+ *
+ * We can't just not set SO_BSDCOMAT because some kernels require it.
+ */
+
+static isc_once_t bsdcompat_once = ISC_ONCE_INIT;
+isc_boolean_t bsdcompat = ISC_TRUE;
+
+static void
+clear_bsdcompat(void) {
+#ifdef __linux__
+ struct utsname buf;
+ char *endp;
+ long int major;
+ long int minor;
+
+ uname(&buf); /* Can only fail if buf is bad in Linux. */
+
+ /* Paranoia in parsing can be increased, but we trust uname(). */
+ major = strtol(buf.release, &endp, 10);
+ if (*endp == '.') {
+ minor = strtol(endp+1, &endp, 10);
+ if ((major > 2) || ((major == 2) && (minor >= 4))) {
+ bsdcompat = ISC_FALSE;
+ }
+ }
+#endif /* __linux __ */
+}
+#endif
+
+/*%
* Create a new 'type' socket managed by 'manager'. Events
* will be posted to 'task' and when dispatched 'action' will be
* called with 'arg' as the arg value. The new socket is returned
@@ -1385,6 +1428,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
#endif
char strbuf[ISC_STRERRORSIZE];
const char *err = "socket";
+ int tries = 0;
REQUIRE(VALID_MANAGER(manager));
REQUIRE(socketp != NULL && *socketp == NULL);
@@ -1394,6 +1438,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
return (ret);
sock->pf = pf;
+ again:
switch (type) {
case isc_sockettype_udp:
sock->fd = socket(pf, SOCK_DGRAM, IPPROTO_UDP);
@@ -1402,6 +1447,8 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
sock->fd = socket(pf, SOCK_STREAM, IPPROTO_TCP);
break;
}
+ if (sock->fd == -1 && errno == EINTR && tries++ < 42)
+ goto again;
#ifdef F_DUPFD
/*
@@ -1428,7 +1475,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
free_socket(&sock);
return (ISC_R_NORESOURCES);
}
-
+
if (sock->fd < 0) {
free_socket(&sock);
@@ -1468,8 +1515,10 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
}
#ifdef SO_BSDCOMPAT
- if (setsockopt(sock->fd, SOL_SOCKET, SO_BSDCOMPAT,
- (void *)&on, sizeof(on)) < 0) {
+ RUNTIME_CHECK(isc_once_do(&bsdcompat_once,
+ clear_bsdcompat) == ISC_R_SUCCESS);
+ if (bsdcompat && setsockopt(sock->fd, SOL_SOCKET, SO_BSDCOMPAT,
+ (void *)&on, sizeof(on)) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"setsockopt(%d, SO_BSDCOMPAT) %s: %s",
@@ -1481,6 +1530,20 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
}
#endif
+#ifdef SO_NOSIGPIPE
+ if (setsockopt(sock->fd, SOL_SOCKET, SO_NOSIGPIPE,
+ (void *)&on, sizeof(on)) < 0) {
+ isc__strerror(errno, strbuf, sizeof(strbuf));
+ UNEXPECTED_ERROR(__FILE__, __LINE__,
+ "setsockopt(%d, SO_NOSIGPIPE) %s: %s",
+ sock->fd,
+ isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
+ ISC_MSG_FAILED, "failed"),
+ strbuf);
+ /* Press on... */
+ }
+#endif
+
#if defined(USE_CMSG)
if (type == isc_sockettype_udp) {
@@ -1491,7 +1554,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"setsockopt(%d, SO_TIMESTAMP) %s: %s",
- sock->fd,
+ sock->fd,
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_GENERAL,
ISC_MSG_FAILED,
@@ -1513,7 +1576,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
}
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
#ifdef IPV6_RECVPKTINFO
- /* 2292bis */
+ /* RFC 3542 */
if ((pf == AF_INET6)
&& (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVPKTINFO,
(void *)&on, sizeof(on)) < 0)) {
@@ -1528,7 +1591,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
strbuf);
}
#else
- /* 2292 */
+ /* RFC 2292 */
if ((pf == AF_INET6)
&& (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_PKTINFO,
(void *)&on, sizeof(on)) < 0)) {
@@ -1544,7 +1607,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
}
#endif /* IPV6_RECVPKTINFO */
#endif /* ISC_PLATFORM_HAVEIN6PKTINFO */
-#ifdef IPV6_USE_MIN_MTU /*2292bis, not too common yet*/
+#ifdef IPV6_USE_MIN_MTU /* RFC 3542, not too common yet*/
/* use minimum MTU */
if (pf == AF_INET6) {
(void)setsockopt(sock->fd, IPPROTO_IPV6,
@@ -1851,7 +1914,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
*/
addrlen = sizeof(dev->newsocket->address.type);
- memset(&dev->newsocket->address.type.sa, 0, addrlen);
+ memset(&dev->newsocket->address.type, 0, addrlen);
fd = accept(sock->fd, &dev->newsocket->address.type.sa,
(void *)&addrlen);
@@ -1919,7 +1982,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"internal_accept(): "
"accept() returned peer address "
- "family %u (expected %u)",
+ "family %u (expected %u)",
dev->newsocket->address.
type.sa.sa_family,
sock->pf);
@@ -1992,7 +2055,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
dev->newsocket->references--;
free_socket(&dev->newsocket);
}
-
+
/*
* Fill in the done event details and send it off.
*/
diff --git a/lib/isc/unix/stdtime.c b/lib/isc/unix/stdtime.c
index b8d818dcfd7a..3833b27d7c01 100644
--- a/lib/isc/unix/stdtime.c
+++ b/lib/isc/unix/stdtime.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1999-2001 Internet Software Consortium.
+ * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2001, 2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: stdtime.c,v 1.11.2.1.10.5 2005/06/09 23:54:31 marka Exp $ */
+/* $Id: stdtime.c,v 1.11.2.1.10.8 2007/08/28 07:19:17 tbox Exp $ */
#include <config.h>
diff --git a/lib/isc/unix/strerror.c b/lib/isc/unix/strerror.c
index 863867e15953..5d7d7c5f1ab9 100644
--- a/lib/isc/unix/strerror.c
+++ b/lib/isc/unix/strerror.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 2001 Internet Software Consortium.
+ * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2001, 2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: strerror.c,v 1.1.2.1.10.3 2004/03/08 09:04:57 marka Exp $ */
+/* $Id: strerror.c,v 1.1.2.1.10.6 2007/08/28 07:19:17 tbox Exp $ */
#include <config.h>
diff --git a/lib/isc/unix/syslog.c b/lib/isc/unix/syslog.c
index e53154452254..8e898c3a12f3 100644
--- a/lib/isc/unix/syslog.c
+++ b/lib/isc/unix/syslog.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 2001 Internet Software Consortium.
+ * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2001, 2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,15 +15,15 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: syslog.c,v 1.1.12.3 2004/03/08 09:04:57 marka Exp $ */
+/* $Id: syslog.c,v 1.1.12.7 2007/09/13 05:18:08 each Exp $ */
#include <config.h>
#include <stdlib.h>
-#include <string.h>
#include <syslog.h>
#include <isc/result.h>
+#include <isc/string.h>
#include <isc/syslog.h>
#include <isc/util.h>