summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorInternet Software Consortium, Inc <@isc.org>2007-09-07 14:08:29 -0600
committerLaMont Jones <lamont@debian.org>2007-09-07 14:08:29 -0600
commit7438cf18a71bf2bb0003f6fd9a26a46afa4adee2 (patch)
treeb2db8be7224b5f189ab2765281e6dcb6ee58ec73 /lib
parentf96316d95bf0c04848031437a285934912c68b83 (diff)
downloadbind9-7438cf18a71bf2bb0003f6fd9a26a46afa4adee2.tar.gz
9.0.0rc4
Diffstat (limited to 'lib')
-rw-r--r--lib/dns/cache.c13
-rw-r--r--lib/dns/config/confparser.y10
-rw-r--r--lib/dns/dispatch.c11
-rw-r--r--lib/dns/dnssec.c7
-rw-r--r--lib/dns/validator.c5
-rw-r--r--lib/dns/xfrin.c8
-rw-r--r--lib/dns/zone.c31
-rw-r--r--lib/isc/include/isc/Makefile.in5
-rw-r--r--lib/isc/include/isc/log.h13
-rw-r--r--lib/isc/log.c48
-rw-r--r--lib/isc/unix/socket.c40
11 files changed, 131 insertions, 60 deletions
diff --git a/lib/dns/cache.c b/lib/dns/cache.c
index 5d01070a..60423212 100644
--- a/lib/dns/cache.c
+++ b/lib/dns/cache.c
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
-/* $Id: cache.c,v 1.23 2000/06/07 02:38:30 marka Exp $ */
+/* $Id: cache.c,v 1.23.2.2 2000/08/18 22:47:39 bwelling Exp $ */
#include <config.h>
@@ -298,6 +298,14 @@ dns_cache_dump(dns_cache_t *cache) {
void
dns_cache_setcleaninginterval(dns_cache_t *cache, unsigned int t) {
LOCK(&cache->lock);
+
+ /*
+ * It may be the case that the cache has already shut down.
+ * If so, it has no timer.
+ */
+ if (cache->cleaner.cleaning_timer == NULL)
+ goto unlock;
+
cache->cleaner.cleaning_interval = t;
if (t == 0) {
isc_timer_reset(cache->cleaner.cleaning_timer,
@@ -310,7 +318,8 @@ dns_cache_setcleaninginterval(dns_cache_t *cache, unsigned int t) {
isc_timertype_ticker,
NULL, &interval, ISC_FALSE);
}
- UNLOCK(&cache->lock);
+ unlock:
+ UNLOCK(&cache->lock);
}
/*
diff --git a/lib/dns/config/confparser.y b/lib/dns/config/confparser.y
index 25eaa572..8ffba577 100644
--- a/lib/dns/config/confparser.y
+++ b/lib/dns/config/confparser.y
@@ -16,7 +16,7 @@
* SOFTWARE.
*/
-/* $Id: confparser.y,v 1.99.2.3 2000/07/26 22:32:23 gson Exp $ */
+/* $Id: confparser.y,v 1.99.2.4 2000/08/22 00:46:22 gson Exp $ */
#include <config.h>
@@ -3154,10 +3154,10 @@ address_name: any_string
tmpres = dns_c_acltable_getacl(currcfg->acls,
$1, &acl);
if (tmpres == ISC_R_NOTFOUND) {
- parser_warning(ISC_FALSE,
- "undefined acl '%s' "
- "referenced", $1);
- elem = NULL;
+ parser_error(ISC_FALSE,
+ "undefined acl '%s' "
+ "referenced", $1);
+ YYABORT;
} else {
tmpres = dns_c_ipmatch_aclnew(currcfg->mem,
&elem, $1);
diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c
index b163ae6e..4d27d69a 100644
--- a/lib/dns/dispatch.c
+++ b/lib/dns/dispatch.c
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
-/* $Id: dispatch.c,v 1.57 2000/06/22 21:54:23 tale Exp $ */
+/* $Id: dispatch.c,v 1.57.2.1 2000/08/22 01:45:14 bwelling Exp $ */
#include <config.h>
@@ -175,6 +175,9 @@ mgr_log(dns_dispatchmgr_t *mgr, int level, const char *fmt, ...) {
char msgbuf[2048];
va_list ap;
+ if (! isc_log_wouldlog(dns_lctx, level))
+ return;
+
va_start(ap, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
va_end(ap);
@@ -189,6 +192,9 @@ dispatch_log(dns_dispatch_t *disp, int level, const char *fmt, ...) {
char msgbuf[2048];
va_list ap;
+ if (! isc_log_wouldlog(dns_lctx, level))
+ return;
+
va_start(ap, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
va_end(ap);
@@ -206,6 +212,9 @@ request_log(dns_dispatch_t *disp, dns_dispentry_t *resp,
char peerbuf[256];
va_list ap;
+ if (! isc_log_wouldlog(dns_lctx, level))
+ return;
+
va_start(ap, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
va_end(ap);
diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c
index 32f0583b..0206cb9f 100644
--- a/lib/dns/dnssec.c
+++ b/lib/dns/dnssec.c
@@ -16,7 +16,7 @@
*/
/*
- * $Id: dnssec.c,v 1.43.2.1 2000/07/27 22:15:21 gson Exp $
+ * $Id: dnssec.c,v 1.43.2.2 2000/08/21 23:17:29 gson Exp $
* Principal Author: Brian Wellington
*/
@@ -581,12 +581,11 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
/*
* Digest the fields of the SIG - we can cheat and use
* dns_rdata_fromstruct. Since siglen is 0, the digested data
- * is identical to dns format with the last 2 bytes removed.
+ * is identical to dns format.
*/
RETERR(dns_rdata_fromstruct(NULL, dns_rdataclass_any,
dns_rdatatype_sig, &sig, &databuf));
isc_buffer_usedregion(&databuf, &r);
- r.length -= 2;
RETERR(dst_context_adddata(ctx, &r));
RETERR(dst_key_sigsize(key, &sigsize));
@@ -743,7 +742,7 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg,
dns_name_fromregion(&tname, &r);
dns_name_toregion(&tname, &r2);
isc_region_consume(&r, r2.length + 10);
- r.length -= (sig.siglen + 2);
+ r.length -= sig.siglen;
RETERR(dst_context_adddata(ctx, &r));
sig_r.base = sig.signature;
diff --git a/lib/dns/validator.c b/lib/dns/validator.c
index b7274b4c..96605ae1 100644
--- a/lib/dns/validator.c
+++ b/lib/dns/validator.c
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: validator.c,v 1.63.2.3 2000/07/27 22:50:02 gson Exp $ */
+/* $Id: validator.c,v 1.63.2.4 2000/08/22 01:45:16 bwelling Exp $ */
#include <config.h>
@@ -1545,6 +1545,9 @@ validator_log(dns_validator_t *val, int level, const char *fmt, ...)
{
va_list ap;
+ if (! isc_log_wouldlog(dns_lctx, level))
+ return;
+
va_start(ap, fmt);
validator_logv(val, DNS_LOGCATEGORY_DNSSEC,
DNS_LOGMODULE_VALIDATOR, level, fmt, ap);
diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c
index 10c2516d..48086fe4 100644
--- a/lib/dns/xfrin.c
+++ b/lib/dns/xfrin.c
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
-/* $Id: xfrin.c,v 1.79.2.4 2000/07/27 22:56:38 gson Exp $ */
+/* $Id: xfrin.c,v 1.79.2.5 2000/08/22 01:45:18 bwelling Exp $ */
#include <config.h>
@@ -1226,6 +1226,9 @@ xfrin_log1(int level, dns_name_t *zonename, isc_sockaddr_t *masteraddr,
{
va_list ap;
+ if (isc_log_wouldlog(dns_lctx, level) == ISC_FALSE)
+ return;
+
va_start(ap, fmt);
xfrin_logv(level, zonename, masteraddr, fmt, ap);
va_end(ap);
@@ -1240,6 +1243,9 @@ xfrin_log(dns_xfrin_ctx_t *xfr, unsigned int level, const char *fmt, ...)
{
va_list ap;
+ if (isc_log_wouldlog(dns_lctx, level) == ISC_FALSE)
+ return;
+
va_start(ap, fmt);
xfrin_logv(level, &xfr->name, &xfr->masteraddr, fmt, ap);
va_end(ap);
diff --git a/lib/dns/zone.c b/lib/dns/zone.c
index c7908298..2abc2ffd 100644
--- a/lib/dns/zone.c
+++ b/lib/dns/zone.c
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
-/* $Id: zone.c,v 1.152.2.5 2000/08/06 22:07:25 gson Exp $ */
+/* $Id: zone.c,v 1.152.2.7 2000/08/22 01:45:20 bwelling Exp $ */
#include <config.h>
@@ -1703,6 +1703,10 @@ notify_find_address(dns_notify_t *notify) {
DNS_ADBFIND_INET6 | DNS_ADBFIND_RETURNLAME;
dns_zone_iattach(notify->zone, &zone);
+
+ if (zone->view->adb == NULL)
+ goto destroy;
+
result = dns_adb_createfind(zone->view->adb,
zone->task,
process_adb_event, notify,
@@ -1711,13 +1715,8 @@ notify_find_address(dns_notify_t *notify) {
&notify->find);
/* Something failed? */
- if (result != ISC_R_SUCCESS) {
- LOCK(&zone->lock);
- notify_destroy(notify);
- UNLOCK(&zone->lock);
- dns_zone_idetach(&zone);
- return;
- }
+ if (result != ISC_R_SUCCESS)
+ goto destroy;
/* More addresses pending? */
if ((notify->find->options & DNS_ADBFIND_WANTEVENT) != 0) {
@@ -1729,6 +1728,13 @@ notify_find_address(dns_notify_t *notify) {
LOCK(&zone->lock);
notify_send(notify);
UNLOCK(&zone->lock);
+ goto detach;
+
+ destroy:
+ LOCK(&zone->lock);
+ notify_destroy(notify);
+ UNLOCK(&zone->lock);
+ detach:
dns_zone_idetach(&zone);
}
@@ -1772,7 +1778,8 @@ notify_send_toaddr(isc_task_t *task, isc_event_t *event) {
LOCK(&notify->zone->lock);
dns_zone_iattach(notify->zone, &zone);
if ((event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0 ||
- DNS_ZONE_FLAG(notify->zone, DNS_ZONEFLG_EXITING)) {
+ DNS_ZONE_FLAG(notify->zone, DNS_ZONEFLG_EXITING) ||
+ zone->view->requestmgr == NULL) {
result = ISC_R_CANCELED;
goto cleanup;
}
@@ -2614,7 +2621,8 @@ soa_query(isc_task_t *task, isc_event_t *event) {
DNS_ENTER;
if (((event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0) ||
- DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) {
+ DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING) ||
+ zone->view->requestmgr == NULL) {
if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING))
cancel_refresh(zone);
isc_event_free(&event);
@@ -3370,6 +3378,9 @@ zone_log(dns_zone_t *zone, const char *me, int level, const char *fmt, ...) {
int len;
isc_result_t result = ISC_R_FAILURE;
+ if (isc_log_wouldlog(dns_lctx, level) == ISC_FALSE)
+ return;
+
isc_buffer_init(&buffer, namebuf, sizeof(namebuf));
if (dns_name_dynamic(&zone->origin))
diff --git a/lib/isc/include/isc/Makefile.in b/lib/isc/include/isc/Makefile.in
index 600c813d..e31da0f4 100644
--- a/lib/isc/include/isc/Makefile.in
+++ b/lib/isc/include/isc/Makefile.in
@@ -13,7 +13,7 @@
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
-# $Id: Makefile.in,v 1.38.2.1 2000/06/30 01:25:29 bwelling Exp $
+# $Id: Makefile.in,v 1.38.2.2 2000/08/17 00:25:25 gson Exp $
srcdir = @srcdir@
VPATH = @srcdir@
@@ -27,7 +27,8 @@ top_srcdir = @top_srcdir@
# install target below.
#
HEADERS = assertions.h base64.h bitstring.h boolean.h buffer.h \
- bufferlist.h commandline.h error.h event.h eventclass.h \
+ bufferlist.h commandline.h entropy.h error.h event.h \
+ eventclass.h \
file.h formatcheck.h fsaccess.h heap.h interfaceiter.h \
@ISC_IPV6_H@ lang.h lex.h \
lfsr.h lib.h list.h log.h magic.h md5.h mem.h msgcat.h \
diff --git a/lib/isc/include/isc/log.h b/lib/isc/include/isc/log.h
index 091c7633..f65e8cc0 100644
--- a/lib/isc/include/isc/log.h
+++ b/lib/isc/include/isc/log.h
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
-/* $Id: log.h,v 1.25 2000/06/19 21:45:03 explorer Exp $ */
+/* $Id: log.h,v 1.25.2.1 2000/08/22 01:45:26 bwelling Exp $ */
#ifndef ISC_LOG_H
#define ISC_LOG_H 1
@@ -627,6 +627,17 @@ isc_log_getdebuglevel(isc_log_t *lctx);
* The current logging debugging level is returned.
*/
+isc_boolean_t
+isc_log_wouldlog(isc_log_t *lctx, int level);
+/*
+ * Determine whether logging something to 'lctx' at 'level' would
+ * actually cause something to be logged somewhere.
+ *
+ * If ISC_FALSE is returned, it is guaranteed that nothing would
+ * be logged, allowing the caller to omit unnecessary
+ * isc_log_write() calls and possible message preformatting.
+ */
+
void
isc_log_setduplicateinterval(isc_logconfig_t *lcfg, unsigned int interval);
/*
diff --git a/lib/isc/log.c b/lib/isc/log.c
index 93df1fe8..55ee7cf3 100644
--- a/lib/isc/log.c
+++ b/lib/isc/log.c
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
-/* $Id: log.c,v 1.38 2000/06/23 17:52:20 tale Exp $ */
+/* $Id: log.c,v 1.38.2.1 2000/08/22 01:45:24 bwelling Exp $ */
/* Principal Authors: DCL */
@@ -1197,6 +1197,33 @@ isc_log_open(isc_logchannel_t *channel) {
return (ISC_R_SUCCESS);
}
+isc_boolean_t
+isc_log_wouldlog(isc_log_t *lctx, int level) {
+ /*
+ * Try to avoid locking the mutex for messages which can't
+ * possibly be logged to any channels -- primarily debugging
+ * messages that the debug level is not high enough to print.
+ *
+ * If the level is (mathematically) less than or equal to the
+ * highest_level, or if there is a dynamic channel and the level is
+ * less than or equal to the debug level, the main loop must be
+ * entered to see if the message should really be output.
+ *
+ * NOTE: this is UNLOCKED access to the logconfig. However,
+ * the worst thing that can happen is that a bad decision is made
+ * about returning without logging, and that's not a big concern,
+ * because that's a risk anyway if the logconfig is being
+ * dynamically changed.
+ */
+
+ if (lctx == NULL)
+ return (ISC_FALSE);
+
+ return (ISC_TF(level <= lctx->logconfig->highest_level ||
+ (lctx->logconfig->dynamic &&
+ level <= lctx->debug_level)));
+}
+
static void
isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
isc_logmodule_t *module, int level, isc_boolean_t write_once,
@@ -1232,24 +1259,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
REQUIRE(category->id < lctx->category_count);
REQUIRE(module->id < lctx->module_count);
- /*
- * Try to avoid locking the mutex for messages which can't
- * possibly be logged to any channels -- primarily debugging
- * messages that the debug level is not high enough to print.
- *
- * If the level is (mathematically) less than or equal to the
- * highest_level, or if there is a dynamic channel and the level is
- * less than or equal to the debug level, the main loop must be
- * entered to see if the message should really be output.
- *
- * NOTE: this is UNLOCKED access to the logconfig. However,
- * the worst thing that can happen is that a bad decision is made
- * about returning without logging, and that's not a big concern,
- * because that's a risk anyway if the logconfig is being
- * dynamically changed.
- */
- if (! (level <= lctx->logconfig->highest_level ||
- (lctx->logconfig->dynamic && level <= lctx->debug_level)))
+ if (! isc_log_wouldlog(lctx, level))
return;
time_string[0] = '\0';
diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c
index 9f33588c..04aa279a 100644
--- a/lib/isc/unix/socket.c
+++ b/lib/isc/unix/socket.c
@@ -15,7 +15,7 @@
* SOFTWARE.
*/
-/* $Id: socket.c,v 1.142.2.3 2000/08/15 01:30:34 gson Exp $ */
+/* $Id: socket.c,v 1.142.2.4 2000/08/22 01:45:28 bwelling Exp $ */
#include <config.h>
@@ -76,11 +76,17 @@
* DLVL(50) -- Event tracing, including receiving/sending completion events.
* DLVL(20) -- Socket creation/destruction.
*/
-#define TRACE DLVL(90)
-#define CORRECTNESS DLVL(70)
-#define IOEVENT DLVL(60)
-#define EVENT DLVL(50)
-#define CREATION DLVL(20)
+#define TRACE_LEVEL 90
+#define CORRECTNESS_LEVEL 70
+#define IOEVENT_LEVEL 60
+#define EVENT_LEVEL 50
+#define CREATION_LEVEL 20
+
+#define TRACE DLVL(TRACE_LEVEL)
+#define CORRECTNESS DLVL(CORRECTNESS_LEVEL)
+#define IOEVENT DLVL(IOEVENT_LEVEL)
+#define EVENT DLVL(EVENT_LEVEL)
+#define CREATION DLVL(CREATION_LEVEL)
typedef isc_event_t intev_t;
@@ -228,6 +234,9 @@ manager_log(isc_socketmgr_t *sockmgr,
char msgbuf[2048];
va_list ap;
+ if (! isc_log_wouldlog(isc_lctx, level))
+ return;
+
va_start(ap, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
va_end(ap);
@@ -245,6 +254,9 @@ socket_log(isc_socket_t *sock, isc_sockaddr_t *address,
char peerbuf[256];
va_list ap;
+ if (! isc_log_wouldlog(isc_lctx, level))
+ return;
+
va_start(ap, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
va_end(ap);
@@ -741,9 +753,10 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) {
if (SOFT_ERROR(errno))
return (DOIO_SOFT);
- socket_log(sock, NULL, IOEVENT,
- "doio_recv: recvmsg(%d) %d bytes, err %d/%s",
- sock->fd, cc, errno, strerror(errno));
+ if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL))
+ socket_log(sock, NULL, IOEVENT,
+ "doio_recv: recvmsg(%d) %d bytes, err %d/%s",
+ sock->fd, cc, errno, strerror(errno));
#define SOFT_OR_HARD(_system, _isc) \
if (errno == _system) { \
@@ -1519,8 +1532,10 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
* If some other error, ignore it as well and hope
* for the best, but log it.
*/
- socket_log(sock, NULL, TRACE,
- "accept() returned %d/%s", errno, strerror(errno));
+ if (isc_log_wouldlog(isc_lctx, TRACE_LEVEL))
+ socket_log(sock, NULL, TRACE,
+ "accept() returned %d/%s", errno,
+ strerror(errno));
fd = -1;
@@ -1800,9 +1815,6 @@ watcher(void *uap) {
UNLOCK(&manager->lock);
cc = select(maxfd, &readfds, &writefds, NULL, NULL);
- manager_log(manager, IOEVENT,
- "select(%d, ...) == %d, errno %d/%s",
- maxfd, cc, errno, strerror(errno));
if (cc < 0) {
if (!SOFT_ERROR(errno))
FATAL_ERROR(__FILE__, __LINE__,