]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
remove log initialization checks from named
authorAydın Mercan <aydin@isc.org>
Fri, 28 Feb 2025 09:43:56 +0000 (09:43 +0000)
committerAydın Mercan <aydin@isc.org>
Fri, 28 Feb 2025 10:31:46 +0000 (10:31 +0000)
This check is now redundant as there is a default global log context
created during libisc's constructor.

bin/named/include/named/globals.h
bin/named/log.c
bin/named/main.c

index a739df0ed8caa1ae9b8b4fbc7f9ca60478e323e4..9713859fff277ce405a09a9df4d0eb63662d26f2 100644 (file)
@@ -86,7 +86,6 @@ EXTERN named_server_t *named_g_server INIT(NULL);
 /*
  * Logging.
  */
-EXTERN bool named_g_logging           INIT(false);
 EXTERN unsigned int named_g_debuglevel INIT(0);
 
 /*
index 52eb05c86e33cc426f405687dd5099e54cf668e9..1afc0d4f2d2d2bc509bcd89429b17150f1219bcc 100644 (file)
@@ -52,8 +52,6 @@ named_log_init(bool safe) {
        named_log_setdefaultsslkeylogfile(lcfg);
        rcu_read_unlock();
 
-       named_g_logging = true;
-
        return ISC_R_SUCCESS;
 
 cleanup:
index 6b21a2d4209a2d75c5306988b7cfa241243d3f67..9e2208befbc9b10da3926d8555e61ecd7fbf0d6e 100644 (file)
@@ -155,15 +155,8 @@ named_main_earlywarning(const char *format, ...) {
        va_list args;
 
        va_start(args, format);
-       if (named_g_logging) {
-               isc_log_vwrite(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
-                              ISC_LOG_WARNING, format, args);
-       } else {
-               fprintf(stderr, "%s: ", program_name);
-               vfprintf(stderr, format, args);
-               fprintf(stderr, "\n");
-               fflush(stderr);
-       }
+       isc_log_vwrite(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
+                      ISC_LOG_WARNING, format, args);
        va_end(args);
 }
 
@@ -172,18 +165,10 @@ named_main_earlyfatal(const char *format, ...) {
        va_list args;
 
        va_start(args, format);
-       if (named_g_logging) {
-               isc_log_vwrite(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
-                              ISC_LOG_CRITICAL, format, args);
-               isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
-                             ISC_LOG_CRITICAL,
-                             "exiting (due to early fatal error)");
-       } else {
-               fprintf(stderr, "%s: ", program_name);
-               vfprintf(stderr, format, args);
-               fprintf(stderr, "\n");
-               fflush(stderr);
-       }
+       isc_log_vwrite(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
+                      ISC_LOG_CRITICAL, format, args);
+       isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
+                     ISC_LOG_CRITICAL, "exiting (due to early fatal error)");
        va_end(args);
 
        _exit(EXIT_FAILURE);
@@ -200,26 +185,19 @@ assertion_failed(const char *file, int line, isc_assertiontype_t type,
         * Handle assertion failures.
         */
 
-       if (named_g_logging) {
-               /*
-                * Reset the assertion callback in case it is the log
-                * routines causing the assertion.
-                */
-               isc_assertion_setcallback(NULL);
-
-               isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
-                             ISC_LOG_CRITICAL, "%s:%d: %s(%s) failed", file,
-                             line, isc_assertion_typetotext(type), cond);
-               isc_backtrace_log(NAMED_LOGCATEGORY_GENERAL,
-                                 NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL);
-               isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
-                             ISC_LOG_CRITICAL,
-                             "exiting (due to assertion failure)");
-       } else {
-               fprintf(stderr, "%s:%d: %s(%s) failed\n", file, line,
-                       isc_assertion_typetotext(type), cond);
-               fflush(stderr);
-       }
+       /*
+        * Reset the assertion callback in case it is the log
+        * routines causing the assertion.
+        */
+       isc_assertion_setcallback(NULL);
+
+       isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
+                     ISC_LOG_CRITICAL, "%s:%d: %s(%s) failed", file, line,
+                     isc_assertion_typetotext(type), cond);
+       isc_backtrace_log(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
+                         ISC_LOG_CRITICAL);
+       isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
+                     ISC_LOG_CRITICAL, "exiting (due to assertion failure)");
 
        if (named_g_coreok) {
                abort();
@@ -238,27 +216,20 @@ library_fatal_error(const char *file, int line, const char *func,
         * Handle isc_error_fatal() calls from our libraries.
         */
 
-       if (named_g_logging) {
-               /*
-                * Reset the error callback in case it is the log
-                * routines causing the assertion.
-                */
-               isc_error_setfatal(NULL);
-
-               isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
-                             ISC_LOG_CRITICAL,
-                             "%s:%d:%s(): fatal error: ", file, line, func);
-               isc_log_vwrite(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
-                              ISC_LOG_CRITICAL, format, args);
-               isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
-                             ISC_LOG_CRITICAL,
-                             "exiting (due to fatal error in library)");
-       } else {
-               fprintf(stderr, "%s:%d:%s(): fatal error: ", file, line, func);
-               vfprintf(stderr, format, args);
-               fprintf(stderr, "\n");
-               fflush(stderr);
-       }
+       /*
+        * Reset the error callback in case it is the log
+        * routines causing the assertion.
+        */
+       isc_error_setfatal(NULL);
+
+       isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
+                     ISC_LOG_CRITICAL, "%s:%d:%s(): fatal error: ", file, line,
+                     func);
+       isc_log_vwrite(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
+                      ISC_LOG_CRITICAL, format, args);
+       isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
+                     ISC_LOG_CRITICAL,
+                     "exiting (due to fatal error in library)");
 
        if (named_g_coreok) {
                abort();
@@ -278,19 +249,11 @@ library_unexpected_error(const char *file, int line, const char *func,
         * Handle isc_error_unexpected() calls from our libraries.
         */
 
-       if (named_g_logging) {
-               isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
-                             ISC_LOG_ERROR,
-                             "%s:%d:%s(): unexpected error: ", file, line,
-                             func);
-               isc_log_vwrite(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
-                              ISC_LOG_ERROR, format, args);
-       } else {
-               fprintf(stderr, "%s:%d:%s(): fatal error: ", file, line, func);
-               vfprintf(stderr, format, args);
-               fprintf(stderr, "\n");
-               fflush(stderr);
-       }
+       isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
+                     ISC_LOG_ERROR, "%s:%d:%s(): unexpected error: ", file,
+                     line, func);
+       isc_log_vwrite(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN,
+                      ISC_LOG_ERROR, format, args);
 }
 
 static void