From: William A. Rowe Jr Date: Thu, 23 Aug 2001 18:53:27 +0000 (+0000) Subject: Optimize out what is a very expensive in-request call to X-Git-Tag: 2.0.25~142 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2902f2da92013787043ddf9d504aa27b898542f6;p=apache Optimize out what is a very expensive in-request call to 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 --- diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index 85576e01f7..9b99d44cef 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -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) diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index e989d11557..6a01e18016 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -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)