]> granicus.if.org Git - apache/commitdiff
Modify ap_open_logs (an internal function) to follow the hook open_logs
authorWilliam A. Rowe Jr <wrowe@apache.org>
Sun, 15 Sep 2002 22:04:01 +0000 (22:04 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Sun, 15 Sep 2002 22:04:01 +0000 (22:04 +0000)
  argument schema so it can be directly invoked by the hook handler.  Also
  clean up the open_logs processing to return an error rather than simply
  exit()ing.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96829 13f79535-47bb-0310-9956-ffa450edef68

include/http_log.h
server/core.c
server/log.c

index 669c564a1aff53be3eccd60289bfb2d321b29384..94927419571ab32238651362e201fb743e219ba6 100644 (file)
@@ -148,10 +148,15 @@ AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p,
 
 /**
  * Open the error log and replace stderr with it.
+ * @param pconf Not used
+ * @param plog  The pool to allocate the logs from
+ * @param ptemp Pool used for temporary allocations
  * @param s_main The main server
- * @param p The pool to allocate out of
+ * @tip ap_open_logs isn't expected to be used by modules, it is
+ * an internal core function 
  */
-void ap_open_logs (server_rec *s_main, apr_pool_t *p);
+int ap_open_logs(apr_pool_t *pconf, apr_pool_t *plog, 
+                 apr_pool_t *ptemp, server_rec *s_main);
 
 /* 
  * The three primary logging functions, ap_log_error, ap_log_rerror, and 
index 2dc2887a35f936da4a8ed60baacbc842927e5ae6..51275d7ee5c23426c3d525f2444c9dd15298bd68 100644 (file)
@@ -3932,12 +3932,6 @@ static int core_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pte
     return OK;
 }
 
-static int core_open_logs(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
-{
-    ap_open_logs(s, plog);
-    return OK;
-}
-
 static void core_insert_filter(request_rec *r)
 {
     core_dir_config *conf = (core_dir_config *)
@@ -4111,7 +4105,7 @@ static void register_hooks(apr_pool_t *p)
     ap_hook_post_config(core_post_config,NULL,NULL,APR_HOOK_REALLY_FIRST);
     ap_hook_translate_name(ap_core_translate,NULL,NULL,APR_HOOK_REALLY_LAST);
     ap_hook_map_to_storage(core_map_to_storage,NULL,NULL,APR_HOOK_REALLY_LAST);
-    ap_hook_open_logs(core_open_logs,NULL,NULL,APR_HOOK_MIDDLE);
+    ap_hook_open_logs(ap_open_logs,NULL,NULL,APR_HOOK_REALLY_FIRST);
     ap_hook_handler(default_handler,NULL,NULL,APR_HOOK_REALLY_LAST);
     /* FIXME: I suspect we can eliminate the need for these do_nothings - Ben */
     ap_hook_type_checker(do_nothing,NULL,NULL,APR_HOOK_REALLY_LAST);
index 4522ea24cf5b945912c9f6b1b326ca8af73c9da5..24c8034262ae614646938223ca6446b05b378f70 100644 (file)
@@ -197,7 +197,7 @@ AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p,
         ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT,
                      APR_EBADPATH, NULL, "Invalid -E error log file %s",
                      fname);
-        exit(1);
+        return APR_EBADPATH;
     }
     if ((rc = apr_file_open(&stderr_file, filename,
                             APR_APPEND | APR_READ | APR_WRITE | APR_CREATE,
@@ -254,7 +254,7 @@ static int log_child(apr_pool_t *p, const char *progname,
     return rc;
 }
 
-static void open_error_log(server_rec *s, apr_pool_t *p)
+static int open_error_log(server_rec *s, apr_pool_t *p)
 {
     const char *fname;
     int rc;
@@ -267,7 +267,7 @@ static void open_error_log(server_rec *s, apr_pool_t *p)
         if (rc != APR_SUCCESS) {
             ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
                          "Couldn't start ErrorLog process");
-            exit(1);
+            return DONE;
         }
 
         s->error_log = dummy;
@@ -284,7 +284,7 @@ static void open_error_log(server_rec *s, apr_pool_t *p)
                     openlog(ap_server_argv0, LOG_NDELAY|LOG_CONS|LOG_PID,
                             fac->t_val);
                     s->error_log = NULL;
-                    return;
+                    return OK;
                 }
             }
         }
@@ -301,7 +301,7 @@ static void open_error_log(server_rec *s, apr_pool_t *p)
             ap_log_error(APLOG_MARK, APLOG_STARTUP, APR_EBADPATH, NULL,
                          "%s: Invalid error log path %s.",
                          ap_server_argv0, s->error_fname);
-            exit(1);
+            return DONE;
         }
         if ((rc = apr_file_open(&s->error_log, fname,
                                APR_APPEND | APR_READ | APR_WRITE | APR_CREATE,
@@ -309,21 +309,26 @@ static void open_error_log(server_rec *s, apr_pool_t *p)
             ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
                          "%s: could not open error log file %s.",
                          ap_server_argv0, fname);
-            exit(1);
+            return DONE;
         }
 
         apr_file_inherit_set(s->error_log);
     }
+
+    return OK;
 }
 
-void ap_open_logs(server_rec *s_main, apr_pool_t *p)
+int ap_open_logs(apr_pool_t *pconf, apr_pool_t *p /* plog */, 
+                 apr_pool_t *ptemp, server_rec *s_main)
 {
     apr_status_t rc = APR_SUCCESS;
     server_rec *virt, *q;
     int replace_stderr;
     apr_file_t *errfile = NULL;
 
-    open_error_log(s_main, p);
+    if (open_error_log(s_main, p) != OK) {
+        return DONE;
+    }
 
     replace_stderr = 1;
     if (s_main->error_log) {
@@ -360,7 +365,9 @@ void ap_open_logs(server_rec *s_main, apr_pool_t *p)
             }
 
             if (q == virt) {
-                open_error_log(virt, p);
+                if (open_error_log(virt, p) != OK) {
+                    return DONE;
+                }
             }
             else {
                 virt->error_log = q->error_log;
@@ -370,6 +377,7 @@ void ap_open_logs(server_rec *s_main, apr_pool_t *p)
             virt->error_log = s_main->error_log;
         }
     }
+    return OK;
 }
 
 AP_DECLARE(void) ap_error_log2stderr(server_rec *s) {
@@ -856,7 +864,7 @@ AP_DECLARE(piped_log *) ap_open_piped_log(apr_pool_t *p, const char *program)
     if (rc != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
                      "Couldn't start piped log process");
-        exit (1);
+        return NULL;
     }
 
     pl = apr_palloc(p, sizeof (*pl));