]> granicus.if.org Git - apache/commitdiff
Optimize out what is a very expensive in-request call to
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 23 Aug 2001 18:53:27 +0000 (18:53 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 23 Aug 2001 18:53:27 +0000 (18:53 +0000)
  ap_server_root_relative (and is becoming more expensive).
  Now the call happens in the config phase where it belongs.
  Note someone can hop in and transpose the stat and open
  with an open and getfileinfo if you are a performance hound.

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

modules/generators/mod_cgi.c
modules/generators/mod_cgid.c

index 85576e01f70d0147b0412140d40f0d98263cf117..9b99d44cefa833bd81706ac4523f31b9e191816f 100644 (file)
@@ -185,7 +185,7 @@ static const char *set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg)
     cgi_server_conf *conf = ap_get_module_config(s->module_config,
                                                  &cgi_module);
 
-    conf->logname = arg;
+    conf->logname = ap_server_root_relative(cmd->pool, arg);
     return NULL;
 }
 
@@ -233,11 +233,12 @@ static int log_scripterror(request_rec *r, cgi_server_conf * conf, int ret,
     ap_log_rerror(APLOG_MARK, log_flags, rv, r, 
                   "%s: %s", error, r->filename);
 
+    /* XXX Very expensive mainline case! Open, then getfileinfo! */
     if (!conf->logname ||
-        ((apr_stat(&finfo, ap_server_root_relative(r->pool, conf->logname),
+        ((apr_stat(&finfo, conf->logname,
                    APR_FINFO_SIZE, r->pool) == APR_SUCCESS)
          &&  (finfo.size > conf->logbytes)) ||
-          (apr_file_open(&f, ap_server_root_relative(r->pool, conf->logname),
+          (apr_file_open(&f, conf->logname,
                    APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT, r->pool)
               != APR_SUCCESS)) {
        return ret;
@@ -285,11 +286,12 @@ static int log_script(request_rec *r, cgi_server_conf * conf, int ret,
     apr_finfo_t finfo;
     char time_str[APR_CTIME_LEN];
 
+    /* XXX Very expensive mainline case! Open, then getfileinfo! */
     if (!conf->logname ||
-        ((apr_stat(&finfo, ap_server_root_relative(r->pool, conf->logname),
+        ((apr_stat(&finfo, conf->logname,
                    APR_FINFO_SIZE, r->pool) == APR_SUCCESS)
          &&  (finfo.size > conf->logbytes)) ||
-         (apr_file_open(&f, ap_server_root_relative(r->pool, conf->logname),
+         (apr_file_open(&f, conf->logname,
                   APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) {
        /* Soak up script output */
        while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_in) == 0)
index e989d11557c43009e60d70ea48ce46d1679ecda7..6a01e180165ef68d15e796676f8614d151df7c61 100644 (file)
@@ -690,7 +690,7 @@ static const char *set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg)
     cgid_server_conf *conf = ap_get_module_config(s->module_config,
                                                   &cgid_module); 
 
-    conf->logname = arg; 
+    conf->logname = ap_server_root_relative(cfg->pool, arg);
     return NULL; 
 } 
 
@@ -749,10 +749,11 @@ static int log_scripterror(request_rec *r, cgid_server_conf * conf, int ret,
     ap_log_rerror(APLOG_MARK, log_flags, rv, r, 
                 "%s: %s", error, r->filename); 
 
+    /* XXX Very expensive mainline case! Open, then getfileinfo! */
     if (!conf->logname || 
-        ((stat(ap_server_root_relative(r->pool, conf->logname), &finfo) == 0) 
+        ((stat(conf->logname, &finfo) == 0) 
          && (finfo.st_size > conf->logbytes)) || 
-         (apr_file_open(&f, ap_server_root_relative(r->pool, conf->logname),
+         (apr_file_open(&f, r->pool, conf->logname,
                   APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) { 
         return ret; 
     } 
@@ -781,10 +782,11 @@ static int log_script(request_rec *r, cgid_server_conf * conf, int ret,
     struct stat finfo; 
     char time_str[APR_CTIME_LEN];
 
+    /* XXX Very expensive mainline case! Open, then getfileinfo! */
     if (!conf->logname || 
-        ((stat(ap_server_root_relative(r->pool, conf->logname), &finfo) == 0) 
+        ((stat(conf->logname, &finfo) == 0) 
          && (finfo.st_size > conf->logbytes)) || 
-         (apr_file_open(&f, ap_server_root_relative(r->pool, conf->logname)
+         (apr_file_open(&f, conf->logname
                   APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) { 
         /* Soak up script output */ 
         while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_in) == 0)