You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Roy Fielding <fi...@hyperreal.com> on 1997/02/10 16:17:47 UTC
cvs commit: apache/src CHANGES http_core.h http_core.c http_request.c
fielding 97/02/10 07:17:46
Modified: src CHANGES http_core.h http_core.c http_request.c
Log:
Extensive performance improvements. Cleaned up inefficient use of
auto initializers, multiple is_matchexp calls on a static string,
and excessive merging of response_code_strings[].
Submitted by: Dean Gaudet
Reviewed by: Randy Terbush, Chuck Murcko, Roy Fielding
Revision Changes Path
1.156 +2 -0 apache/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache/src/CHANGES,v
retrieving revision 1.155
retrieving revision 1.156
diff -C3 -r1.155 -r1.156
*** CHANGES 1997/02/10 14:03:48 1.155
--- CHANGES 1997/02/10 15:17:42 1.156
***************
*** 1,5 ****
--- 1,7 ----
Changes with Apache 1.2b7
+ *) Extensive performance improvements. [Dean Gaudet]
+
*) Several fixes for suexec wrapper. [Randy Terbush]
- Make wrapper work for files on NFS filesystem.
- Fix portability problem of MAXPATHLEN.
1.19 +10 -1 apache/src/http_core.h
Index: http_core.h
===================================================================
RCS file: /export/home/cvs/apache/src/http_core.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C3 -r1.18 -r1.19
*** http_core.h 1997/01/01 18:10:18 1.18
--- http_core.h 1997/02/10 15:17:43 1.19
***************
*** 128,133 ****
--- 128,139 ----
typedef struct {
char *d;
+ /* since is_matchexp(conf->d) was being called so frequently in
+ * directory_walk() and its relatives, this field was created and
+ * is set to the result of that call.
+ */
+ int d_is_matchexp;
+
allow_options_t opts;
allow_options_t opts_add;
allow_options_t opts_remove;
***************
*** 150,158 ****
int content_md5;
/* Custom response config. These can contain text or a URL to redirect to.
*/
! char *response_code_strings[RESPONSE_CODES];
/* Hostname resolution etc */
int hostname_lookups;
--- 156,167 ----
int content_md5;
/* Custom response config. These can contain text or a URL to redirect to.
+ * if response_code_strings is NULL then there are none in the config,
+ * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES.
+ * This lets us do quick merges in merge_core_dir_configs().
*/
! char **response_code_strings;
/* Hostname resolution etc */
int hostname_lookups;
1.68 +24 -3 apache/src/http_core.c
Index: http_core.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_core.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -C3 -r1.67 -r1.68
*** http_core.c 1997/02/10 11:57:27 1.67
--- http_core.c 1997/02/10 15:17:43 1.68
***************
*** 83,88 ****
--- 83,90 ----
if (!dir || dir[strlen(dir) - 1] == '/') conf->d = dir;
else conf->d = pstrcat (a, dir, "/", NULL);
+ conf->d_is_matchexp = conf->d ? is_matchexp( conf->d ) : 0;
+
conf->opts = dir ? OPT_UNSET : OPT_ALL;
conf->opts_add = conf->opts_remove = OPT_NONE;
***************
*** 120,125 ****
--- 122,128 ----
memcpy ((char *)conf, (const char *)base, sizeof(core_dir_config));
conf->d = new->d;
+ conf->d_is_matchexp = new->d_is_matchexp;
conf->r = new->r;
if (new->opts != OPT_UNSET) conf->opts = new->opts;
***************
*** 133,141 ****
if (new->auth_name) conf->auth_name = new->auth_name;
if (new->requires) conf->requires = new->requires;
! for (i = 0; i < RESPONSE_CODES; ++i)
! if (new->response_code_strings[i] != NULL)
! conf->response_code_strings[i] = new->response_code_strings[i];
if (new->hostname_lookups != 2)
conf->hostname_lookups = new->hostname_lookups;
if ((new->do_rfc1413 & 2) == 0) conf->do_rfc1413 = new->do_rfc1413;
--- 136,153 ----
if (new->auth_name) conf->auth_name = new->auth_name;
if (new->requires) conf->requires = new->requires;
! if( new->response_code_strings ) {
! if( conf->response_code_strings == NULL ) {
! conf->response_code_strings = palloc(a,
! sizeof(*conf->response_code_strings) * RESPONSE_CODES );
! memcpy( conf->response_code_strings, new->response_code_strings,
! sizeof(*conf->response_code_strings) * RESPONSE_CODES );
! } else {
! for (i = 0; i < RESPONSE_CODES; ++i)
! if (new->response_code_strings[i] != NULL)
! conf->response_code_strings[i] = new->response_code_strings[i];
! }
! }
if (new->hostname_lookups != 2)
conf->hostname_lookups = new->hostname_lookups;
if ((new->do_rfc1413 & 2) == 0) conf->do_rfc1413 = new->do_rfc1413;
***************
*** 299,304 ****
--- 311,319 ----
core_dir_config *conf =
(core_dir_config *)get_module_config(r->per_dir_config, &core_module);
+ if( conf->response_code_strings == NULL ) {
+ return NULL;
+ }
return conf->response_code_strings[error_index];
}
***************
*** 436,441 ****
--- 451,460 ----
/* Store it... */
+ if( conf->response_code_strings == NULL ) {
+ conf->response_code_strings = pcalloc(cmd->pool,
+ sizeof(*conf->response_code_strings) * RESPONSE_CODES );
+ }
conf->response_code_strings[index_number] = pstrdup (cmd->pool, line);
return NULL;
***************
*** 665,670 ****
--- 684,690 ----
conf = (core_dir_config *)get_module_config(new_url_conf, &core_module);
conf->d = pstrdup(cmd->pool, cmd->path); /* No mangling, please */
+ conf->d_is_matchexp = is_matchexp( conf->d );
conf->r = r;
add_per_url_conf (cmd->server, new_url_conf);
***************
*** 715,720 ****
--- 735,741 ----
conf = (core_dir_config *)get_module_config(new_file_conf, &core_module);
conf->d = pstrdup(cmd->pool, cmd->path);
+ conf->d_is_matchexp = is_matchexp( conf->d );
conf->r = r;
add_file_conf (c, new_file_conf);
1.42 +15 -15 apache/src/http_request.c
Index: http_request.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_request.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -C3 -r1.41 -r1.42
*** http_request.c 1997/02/10 10:24:49 1.41
--- http_request.c 1997/02/10 15:17:44 1.42
***************
*** 286,292 ****
if (!regexec(entry_core->r, test_filename, 0, NULL, 0))
this_conf = entry_config;
}
! else if (is_matchexp(entry_dir)) {
if (!strcmp_match(test_filename, entry_dir))
this_conf = entry_config;
}
--- 286,292 ----
if (!regexec(entry_core->r, test_filename, 0, NULL, 0))
this_conf = entry_config;
}
! else if (entry_core->d_is_matchexp) {
if (!strcmp_match(test_filename, entry_dir))
this_conf = entry_config;
}
***************
*** 319,337 ****
for (i = 1; i <= num_dirs; ++i) {
core_dir_config *core_dir =
(core_dir_config *)get_module_config(per_dir_defaults, &core_module);
! int allowed_here = core_dir->opts;
! int overrides_here = core_dir->override;
void *this_conf = NULL, *htaccess_conf = NULL;
char *this_dir = make_dirstr (r->pool, test_filename, i);
- char *config_name = make_full_path(r->pool, this_dir,
- sconf->access_name);
int j;
/* Do symlink checks first, because they are done with the
* permissions appropriate to the *parent* directory...
*/
! if ((res = check_symlinks (this_dir, allowed_here)))
{
log_reason("Symbolic link not allowed", this_dir, r);
return res;
--- 319,334 ----
for (i = 1; i <= num_dirs; ++i) {
core_dir_config *core_dir =
(core_dir_config *)get_module_config(per_dir_defaults, &core_module);
! int overrides_here;
void *this_conf = NULL, *htaccess_conf = NULL;
char *this_dir = make_dirstr (r->pool, test_filename, i);
int j;
/* Do symlink checks first, because they are done with the
* permissions appropriate to the *parent* directory...
*/
! if ((res = check_symlinks (this_dir, core_dir->opts)))
{
log_reason("Symbolic link not allowed", this_dir, r);
return res;
***************
*** 363,390 ****
this_conf = entry_config;
}
}
! else if (is_matchexp(entry_dir) &&
!strcmp_match(this_dir, entry_dir)) {
sec[j] = NULL;
this_conf = entry_config;
}
else if (!strcmp (this_dir, entry_dir))
this_conf = entry_config;
- }
! if (this_conf)
! {
! per_dir_defaults =
! merge_per_dir_configs (r->pool, per_dir_defaults, this_conf);
! core_dir =(core_dir_config *)get_module_config(per_dir_defaults,
&core_module);
}
overrides_here = core_dir->override;
/* If .htaccess files are enabled, check for one.
*/
if (overrides_here) {
res = parse_htaccess (&htaccess_conf, r, overrides_here,
this_dir, config_name);
if (res) return res;
--- 360,390 ----
this_conf = entry_config;
}
}
! else if (entry_core->d_is_matchexp &&
!strcmp_match(this_dir, entry_dir)) {
sec[j] = NULL;
this_conf = entry_config;
}
else if (!strcmp (this_dir, entry_dir))
this_conf = entry_config;
! if (this_conf)
! {
! per_dir_defaults =
! merge_per_dir_configs (r->pool, per_dir_defaults, this_conf);
! core_dir =(core_dir_config *)get_module_config(per_dir_defaults,
&core_module);
+ }
}
+
overrides_here = core_dir->override;
/* If .htaccess files are enabled, check for one.
*/
if (overrides_here) {
+ char *config_name = make_full_path(r->pool, this_dir,
+ sconf->access_name);
res = parse_htaccess (&htaccess_conf, r, overrides_here,
this_dir, config_name);
if (res) return res;
***************
*** 456,462 ****
if (!regexec(entry_core->r, test_location, 0, NULL, 0))
this_conf = entry_config;
}
! else if (is_matchexp(entry_url)) {
if (!strcmp_match(test_location, entry_url))
this_conf = entry_config;
}
--- 456,462 ----
if (!regexec(entry_core->r, test_location, 0, NULL, 0))
this_conf = entry_config;
}
! else if( entry_core->d_is_matchexp ) {
if (!strcmp_match(test_location, entry_url))
this_conf = entry_config;
}
***************
*** 518,524 ****
if (!regexec(entry_core->r, test_file, 0, NULL, 0))
this_conf = entry_config;
}
! else if (is_matchexp(entry_file)) {
if (!strcmp_match(test_file, entry_file))
this_conf = entry_config;
}
--- 518,524 ----
if (!regexec(entry_core->r, test_file, 0, NULL, 0))
this_conf = entry_config;
}
! else if ( entry_core->d_is_matchexp ) {
if (!strcmp_match(test_file, entry_file))
this_conf = entry_config;
}