httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allen Pulsifer" <pulsif...@comcast.net>
Subject patch for spurious open attempt on ".../file.html/.htaccess"
Date Wed, 13 Jun 2007 12:09:09 GMT
server/request.c lines 930 to 940 currently read:

            if (r->finfo.filetype
#ifdef CASE_BLIND_FILESYSTEM
                && (filename_len <= canonical_len)
#endif
                && ((opts.opts & (OPT_SYM_OWNER | OPT_SYM_LINKS)) ==
OPT_SYM_LINKS))
            {

                thisinfo.filetype = APR_DIR;
                ++seg;
                continue;
            }


Here is the corrected code that fixes the spurious open attempt on the file
".../file.html/.htaccess":

            if (r->finfo.filetype
#ifdef CASE_BLIND_FILESYSTEM
                && (filename_len <= canonical_len)
#endif
                && (opts.opts & OPT_SYM_LINKS) )
            {
                ++seg;

                if (r->finfo.filetype == APR_REG
                    && (!r->path_info || !*r->path_info) )
                {
	              thisinfo.filetype = APR_REG;
                    break;
                }

                thisinfo.filetype = APR_DIR;
                continue;
            }


A note on what this fix and the optimization accomplishes:

In the best case (under Linux with FollowSymLinks and AllowOverride's
enabled), this code makes the following accesses to disk:

1. An initial stat on the file to serve
2. An open attempt on the .htaccess in each directory along the path to the
file
3. An open on the file to serve

As far as I can see, the only way this could be optimized further would be
to eliminate the initial stat on the file to serve, or to turn it into a
file open, and then hold the file open until it is served.

Allen


Mime
View raw message