]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup:
authorBrian Wellington <source@isc.org>
Tue, 22 Aug 2000 01:45:28 +0000 (01:45 +0000)
committerBrian Wellington <source@isc.org>
Tue, 22 Aug 2000 01:45:28 +0000 (01:45 +0000)
 330.   [func]          New function isc_log_wouldlog().

(note: #330 is out of place in CHANGES, because it's new in rc4, but if
it was in the place that 330 is supposed to go, no one would see it.  So,
leave it at the top)

CHANGES
bin/named/client.c
bin/named/query.c
bin/named/xfrout.c
lib/dns/dispatch.c
lib/dns/validator.c
lib/dns/xfrin.c
lib/dns/zone.c
lib/isc/include/isc/log.h
lib/isc/log.c
lib/isc/unix/socket.c

diff --git a/CHANGES b/CHANGES
index cba351c87cc9ad766e6b1ac883ed8dfab17b12ea..01dc1987e592958274ffe5eb441f97e173572a72 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,6 @@
 
+ 330.   [func]          New function isc_log_wouldlog(). 
+
  402.  [bug]           Treat undefined acls as errors, rather than
                        warning and then later throwing an assertion.
                        [RT #252]
index 003db2023e3f9fb11a46e2218a5f5a94402bdb07..82d53f1e7775c564a62404d56fda0ba1a520f56b 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: client.c,v 1.98.2.3 2000/07/26 23:51:31 bwelling Exp $ */
+/* $Id: client.c,v 1.98.2.4 2000/08/22 01:45:08 bwelling Exp $ */
 
 #include <config.h>
 
@@ -270,7 +270,7 @@ set_timeout(ns_client_t *client, unsigned int seconds) {
        if (result != ISC_R_SUCCESS) {
                ns_client_log(client, NS_LOGCATEGORY_CLIENT,
                              NS_LOGMODULE_CLIENT, ISC_LOG_ERROR,
-                             "setting timouet: %s",
+                             "setting timeout: %s",
                              isc_result_totext(result));
                /* Continue anyway. */
        }
@@ -1694,6 +1694,9 @@ ns_client_log(ns_client_t *client, isc_logcategory_t *category,
 {
        va_list ap;
 
+       if (isc_log_wouldlog(ns_g_lctx, level) == ISC_FALSE)
+               return;
+
        va_start(ap, fmt);
        ns_client_logv(client, category, module, level, fmt, ap);
        va_end(ap);
index 4bd1cedb46e66c21cade8d01bf0e4095d7c1e12c..8606bef8e18afcbcd3b44904fe406cb88774c1d7 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: query.c,v 1.109.2.10 2000/08/08 19:30:13 bwelling Exp $ */
+/* $Id: query.c,v 1.109.2.11 2000/08/22 01:45:09 bwelling Exp $ */
 
 #include <config.h>
 
@@ -2881,6 +2881,10 @@ log_query(ns_client_t *client) {
        char text[256];
        isc_region_t r;
        dns_rdataset_t *rdataset;
+       int level = ISC_LOG_DEBUG(1);
+
+       if (! isc_log_wouldlog(ns_g_lctx, level))
+               return;
 
        /* XXXRTH  Allow this to be turned off! */
 
@@ -2900,7 +2904,7 @@ log_query(ns_client_t *client) {
        }
        isc_buffer_usedregion(&b, &r);
        ns_client_log(client, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_QUERY,
-                     ISC_LOG_DEBUG(1), "query: %s%.*s", namebuf,
+                     level, "query: %s%.*s", namebuf,
                      (int)r.length, (char *)r.base);
 }
 
index 6a4ab8649dab0baf8f73a37e5e97facab6079fba..1aa9a3d5256f33ed89a89923c400d6d2c4c633e5 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: xfrout.c,v 1.68.2.1 2000/08/07 22:04:31 gson Exp $ */
+/* $Id: xfrout.c,v 1.68.2.2 2000/08/22 01:45:11 bwelling Exp $ */
 
 #include <config.h>
 
@@ -1315,7 +1315,8 @@ sendstream(xfrout_ctx_t *xfr) {
                        break;
                }
 
-               log_rr(name, rdata, ttl); /* XXX */
+               if (isc_log_wouldlog(ns_g_lctx, XFROUT_RR_LOGLEVEL))
+                       log_rr(name, rdata, ttl); /* XXX */
                
                dns_message_gettempname(msg, &msgname);
                dns_name_init(msgname, NULL);
index b163ae6e4c72cf5c288a7a9bc50e6371553a6a1e..4d27d69aa9c1c4f82930fbd7a7ade04600b185fe 100644 (file)
@@ -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);
index b7274b4c1342a38bb863d66f5c986e91507a2816..96605ae1a646803ccc668f66a6cbb9102831b729 100644 (file)
@@ -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);
index 10c2516d02aad95f89c0b9cc5ed0f76ea19ded4b..48086fe45166ec5a9fe6df52287b1f34edf1e59c 100644 (file)
@@ -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);
index c6dd59e436dd2feda57baa5aee7cd9fe1e662268..2abc2ffd94dc16743603c845d67be2c80be97e49 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: zone.c,v 1.152.2.6 2000/08/21 20:51:47 bwelling Exp $ */
+/* $Id: zone.c,v 1.152.2.7 2000/08/22 01:45:20 bwelling Exp $ */
 
 #include <config.h>
 
@@ -3378,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))
index 091c76337139fedbc0fea7a7dc4ffc71cde770f7..f65e8cc0c9eda7603ce826e2fc43dd5b47d90e7b 100644 (file)
@@ -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);
 /*
index 93df1fe81643310e074f37bd8179b0f614bf38a3..55ee7cf34de87111430ab00df225d905eacc8d29 100644 (file)
@@ -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';
index 9f33588cd34ee9e85c8aa42d0af68ae3ea9227a9..04aa279afd0aa110d66e203a51df6259d50e9298 100644 (file)
@@ -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>
 
  * 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__,