]> granicus.if.org Git - apache/blobdiff - server/log.c
event: child_main() never returns, so remove some dead code after
[apache] / server / log.c
index 028eaecbad23df7929e39c010183b4fcdb4343d0..4f7bf081b6a1a97c9a6ede17b212d30843953f4b 100644 (file)
@@ -41,6 +41,9 @@
 #if APR_HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#if APR_HAVE_PROCESS_H
+#include <process.h>            /* for getpid() on Win32 */
+#endif
 
 #include "ap_config.h"
 #include "httpd.h"
@@ -193,16 +196,6 @@ AP_DECLARE(apr_file_t *) ap_piped_log_write_fd(piped_log *pl)
     return pl->write_fd;
 }
 
-/* clear_handle_list() is called when plog is cleared; at that
- * point we need to forget about our old list of pipe read
- * handles.  We let the plog cleanups close the actual pipes.
- */
-static apr_status_t clear_handle_list(void *v)
-{
-    read_handles = NULL;
-    return APR_SUCCESS;
-}
-
 /* remember to close this handle in the child process
  *
  * On Win32 this makes zero sense, because we don't
@@ -456,7 +449,7 @@ int ap_open_logs(apr_pool_t *pconf, apr_pool_t *p /* plog */,
      * between log phases, so we don't mind losing stderr's 
      * read_handle a little bit early.
      */
-    apr_pool_cleanup_register(p, NULL, clear_handle_list,
+    apr_pool_cleanup_register(p, &read_handles, ap_pool_cleanup_set_null,
                               apr_pool_cleanup_null);
 
     /* HERE we need a stdout log that outlives plog.
@@ -737,6 +730,25 @@ static int log_apr_status(const ap_errorlog_info *info, const char *arg,
     return len;
 }
 
+static int log_server_name(const ap_errorlog_info *info, const char *arg,
+                           char *buf, int buflen)
+{
+    if (info->r)
+        return cpystrn(buf, ap_get_server_name((request_rec *)info->r), buflen);
+
+    return 0;
+}
+
+static int log_virtual_host(const ap_errorlog_info *info, const char *arg,
+                            char *buf, int buflen)
+{
+    if (info->s)
+        return cpystrn(buf, info->s->server_hostname, buflen);
+
+    return 0;
+}
+
+
 static int log_table_entry(const apr_table_t *table, const char *name,
                            char *buf, int buflen)
 {
@@ -867,6 +879,8 @@ AP_DECLARE(void) ap_register_log_hooks(apr_pool_t *p)
     ap_register_errorlog_handler(p, "P", log_pid, 0);
     ap_register_errorlog_handler(p, "t", log_ctime, 0);
     ap_register_errorlog_handler(p, "T", log_tid, 0);
+    ap_register_errorlog_handler(p, "v", log_virtual_host, 0);
+    ap_register_errorlog_handler(p, "V", log_server_name, 0);
 }
 
 /*
@@ -1003,7 +1017,7 @@ static int do_errorlog_format(apr_array_header_t *fmt, ap_errorlog_info *info,
         else if (skipping) {
             continue;
         }
-        else if (item->min_loglevel > info->level) {
+        else if ((int)item->min_loglevel > info->level) {
             len = field_start;
             skipping = 1;
         }
@@ -1117,36 +1131,39 @@ static void log_error_core(const char *file, int line, int module_index,
             }
         }
 
-        sconf = ap_get_module_config(s->module_config, &core_module);
-        if (c && !c->log_id) {
-            add_log_id(c, NULL);
-            if (sconf->error_log_conn && sconf->error_log_conn->nelts > 0)
-                log_conn_info = 1;
-        }
-        if (r) {
-            if (r->main)
-                rmain = r->main;
-            else
-                rmain = r;
-
-            if (!rmain->log_id) {
-                /* XXX: do we need separate log ids for subrequests? */
-                if (sconf->error_log_req && sconf->error_log_req->nelts > 0)
-                    log_req_info = 1;
-                /*
-                 * XXX: potential optimization: only create log id if %L is
-                 * XXX: actually used
-                 */
-                add_log_id(c, rmain);
+        /* the faked server_rec from mod_cgid does not have s->module_config */
+        if (s->module_config) {
+            sconf = ap_get_module_config(s->module_config, &core_module);
+            if (c && !c->log_id) {
+                add_log_id(c, NULL);
+                if (sconf->error_log_conn && sconf->error_log_conn->nelts > 0)
+                    log_conn_info = 1;
+            }
+            if (r) {
+                if (r->main)
+                    rmain = r->main;
+                else
+                    rmain = r;
+
+                if (!rmain->log_id) {
+                    /* XXX: do we need separate log ids for subrequests? */
+                    if (sconf->error_log_req && sconf->error_log_req->nelts > 0)
+                        log_req_info = 1;
+                    /*
+                     * XXX: potential optimization: only create log id if %L is
+                     * XXX: actually used
+                     */
+                    add_log_id(c, rmain);
+                }
             }
         }
     }
 
     info.s             = s;
     info.c             = c;
-    info.file          = file;
-    info.line          = line;
-    info.status        = status;
+    info.file          = NULL;
+    info.line          = 0;
+    info.status        = 0;
     info.using_syslog  = (logf == NULL);
     info.startup       = ((level & APLOG_STARTUP) == APLOG_STARTUP);
 
@@ -1193,10 +1210,13 @@ static void log_error_core(const char *file, int line, int module_index,
         }
         else {
             /* the actual error message */
-            info.r = r;
-            info.rmain = rmain;
-            info.level = level_and_mask;
+            info.r            = r;
+            info.rmain        = rmain;
+            info.level        = level_and_mask;
             info.module_index = module_index;
+            info.file         = file;
+            info.line         = line;
+            info.status       = status;
             log_format = sconf ? sconf->error_log_format : NULL;
             done = 1;
         }