Commit 7bd72f44 authored by William A. Rowe Jr's avatar William A. Rowe Jr
Browse files

  The changes required for the APR_FINFO_wanted argument to
  apr_stat/lstat/getfileinfo.  These are -NOT- optimal, they
  are simply the required changes to get the server working.
  The size of the patch is a warning about how we need to
  really look at what we are trying to accomplish with all
  of these stat/lstat calls.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87760 13f79535-47bb-0310-9956-ffa450edef68
parent 9df7f24e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1238,7 +1238,8 @@ static const char *isapi_cmd_cachefile(cmd_parms *cmd, void *dummy,
    char *fspec;
    
    fspec = ap_os_case_canonical_filename(cmd->pool, filename);
    if (apr_stat(&tmp, fspec, cmd->temp_pool) != APR_SUCCESS) { 
    if (apr_stat(&tmp, fspec, 
                 APR_FINFO_NORM, cmd->temp_pool) != APR_SUCCESS) { 
	ap_log_error(APLOG_MARK, APLOG_WARNING, errno, cmd->server,
	    "ISAPI: unable to stat(%s), skipping", filename);
	return NULL;
+8 −42
Original line number Diff line number Diff line
@@ -157,39 +157,6 @@ static void *create_server_config(apr_pool_t *p, server_rec *s)
    return sconf;
}

#if APR_HAS_SENDFILE
static apr_status_t open_file(apr_file_t **file, const char *filename, int flg1, int flg2, 
                             apr_pool_t *p)
{
    apr_status_t rv;
#ifdef WIN32
    /* The Windows file needs to be opened for overlapped i/o, which APR doesn't
     * support.
     */
    HANDLE hFile;
    /* XXX: This is wrong for unicode FS ... and it doesn't belong in httpd */
    hFile = CreateFile(filename,          /* pointer to name of the file */
                       GENERIC_READ,      /* access (read-write) mode */
                       FILE_SHARE_READ,   /* share mode */
                       NULL,              /* pointer to security attributes */
                       OPEN_EXISTING,     /* how to create */
                       FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN, /* file attributes */
                       NULL);            /* handle to file with attributes to copy */
    if (hFile != INVALID_HANDLE_VALUE) {
        rv = apr_put_os_file(file, &hFile, p);
    }
    else {
        rv = GetLastError();
        *file = NULL;
    }
#else
    rv = apr_open(file, filename, flg1, flg2, p);
#endif

    return rv;
}
#endif /* APR_HAS_SENDFILE */

static apr_status_t cleanup_file_cache(void *sconfv)
{
    a_server_config *sconf = sconfv;
@@ -219,8 +186,8 @@ static const char *cachefile(cmd_parms *cmd, void *dummy, const char *filename)
{
    /* ToDo:
     * Disable the file cache on a Windows 9X box. APR_HAS_SENDFILE will be
     * defined in an Apache for Windows build, but apr_sendfile is not
     * implemened on Windows 9X because TransmitFile is not available.
     * defined in an Apache for Windows build, but apr_sendfile returns
     * APR_ENOTIMPL on Windows 9X because TransmitFile is not available.
     */

#if APR_HAS_SENDFILE
@@ -232,7 +199,9 @@ static const char *cachefile(cmd_parms *cmd, void *dummy, const char *filename)

    /* canonicalize the file name? */
    /* os_canonical... */
    if ((rc = apr_stat(&tmp.finfo, filename, cmd->temp_pool)) != APR_SUCCESS) {
    /* XXX: uh... yea, or expect them to be -very- accurate typists */
    if ((rc = apr_stat(&tmp.finfo, filename, APR_FINFO_NORM, 
                       cmd->temp_pool)) != APR_SUCCESS) {
	ap_log_error(APLOG_MARK, APLOG_WARNING, rc, cmd->server,
	    "mod_file_cache: unable to stat(%s), skipping", filename);
	return NULL;
@@ -243,11 +212,7 @@ static const char *cachefile(cmd_parms *cmd, void *dummy, const char *filename)
	return NULL;
    }

    /* Note: open_file should call apr_open for Unix and CreateFile for Windows.
     * The Windows file needs to be opened for async I/O to allow multiple threads
     * to serve it up at once.
     */
    rc = open_file(&fd, filename, APR_READ, APR_OS_DEFAULT, cmd->pool);
    rc = apr_open(&fd, filename, APR_READ | APR_XTHREAD, APR_OS_DEFAULT, cmd->pool);
    if (rc != APR_SUCCESS) {
        ap_log_error(APLOG_MARK, APLOG_WARNING, rc, cmd->server,
                     "mod_file_cache: unable to open(%s, O_RDONLY), skipping", filename);
@@ -285,7 +250,8 @@ static const char *mmapfile(cmd_parms *cmd, void *dummy, const char *filename)
    const char *fspec;

    fspec = ap_os_case_canonical_filename(cmd->pool, filename);
    if ((rc = apr_stat(&tmp.finfo, fspec, cmd->temp_pool)) != APR_SUCCESS) {
    if ((rc = apr_stat(&tmp.finfo, fspec, APR_FINFO_NORM, 
                       cmd->temp_pool)) != APR_SUCCESS) {
	ap_log_error(APLOG_MARK, APLOG_WARNING, rc, cmd->server,
	    "mod_file_cache: unable to stat(%s), skipping", filename);
	return NULL;
+3 −3
Original line number Diff line number Diff line
@@ -446,7 +446,7 @@ static dav_datum dav_fs_build_key(apr_pool_t *p, const dav_resource *resource)
    apr_finfo_t finfo;

    /* ### use lstat() ?? */
    if (apr_stat(&finfo, file, p) == 0) {
    if (apr_stat(&finfo, file, APR_FINFO_NORM, p) == APR_SUCCESS) {

	/* ### can we use a buffer for this? */
	key.dsize = 1 + sizeof(finfo.inode) + sizeof(finfo.device);
@@ -663,7 +663,7 @@ static dav_error * dav_fs_load_lock_record(dav_lockdb *lockdb, dav_datum key,
		    apr_finfo_t finfo;

		    /* if we don't see the file, then it's a locknull */
		    if (apr_lstat(&finfo, fname, p) != 0) {
		    if (apr_lstat(&finfo, fname, APR_FINFO_NORM, p) != APR_SUCCESS) {
			if ((err = dav_fs_remove_locknull_member(p, fname, &buf)) != NULL) {
                            /* ### push a higher-level description? */
                            return err;
@@ -833,7 +833,7 @@ static dav_error * dav_fs_load_locknull_list(apr_pool_t *p, const char *dirpath,
	return NULL;
    }

    if (apr_getfileinfo(&finfo, file) != APR_SUCCESS) {
    if (apr_getfileinfo(&finfo, APR_FINFO_NORM, file) != APR_SUCCESS) {
	err = dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
			    apr_psprintf(p,
					"Opened but could not stat file %s",
+7 −5
Original line number Diff line number Diff line
@@ -427,7 +427,7 @@ static dav_error * dav_fs_copymove_state(
    src = apr_pstrcat(p, src_dir, "/" DAV_FS_STATE_DIR "/", src_file, NULL);

    /* the source file doesn't exist */
    if (apr_stat(&src_finfo, src, p) != 0) {
    if (apr_stat(&src_finfo, src, APR_FINFO_NORM, p) != APR_SUCCESS) {
	return NULL;
    }

@@ -447,7 +447,7 @@ static dav_error * dav_fs_copymove_state(
    }

    /* get info about the state directory */
    if (apr_stat(&dst_state_finfo, dst, p) != 0) {
    if (apr_stat(&dst_state_finfo, dst, APR_FINFO_NORM, p) != APR_SUCCESS) {
	/* Ack! Where'd it go? */
	/* ### use something besides 500? */
	return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
@@ -735,7 +735,8 @@ static dav_resource * dav_fs_get_parent_resource(const dav_resource *resource)
	parent_resource->uri = uri;
    }

    if (apr_stat(&parent_ctx->finfo, parent_ctx->pathname, ctx->pool) == 0) {
    if (apr_stat(&parent_ctx->finfo, parent_ctx->pathname, 
                 APR_FINFO_NORM, ctx->pool) == APR_SUCCESS) {
        parent_resource->exists = 1;
    }

@@ -1138,7 +1139,7 @@ static dav_error * dav_fs_move_resource(
	 * so try it
	 */
	dirpath = ap_make_dirstr_parent(dstinfo->pool, dstinfo->pathname);
	if (apr_stat(&finfo, dirpath, dstinfo->pool) == 0
	if (apr_stat(&finfo, dirpath, APR_FINFO_NORM, dstinfo->pool) == 0
	    && finfo.device == srcinfo->finfo.device) {
	    can_rename = 1;
	}
@@ -1386,7 +1387,8 @@ static dav_error * dav_fs_walker(dav_fs_walker_context *fsctx, int depth)
	/* append this file onto the path buffer (copy null term) */
	dav_buffer_place_mem(pool, &fsctx->path1, name, len + 1, 0);

	if (apr_lstat(&fsctx->info1.finfo, fsctx->path1.buf, pool) != 0) {
        if (apr_lstat(&fsctx->info1.finfo, fsctx->path1.buf, 
                      APR_FINFO_NORM, pool) != APR_SUCCESS) {
	    /* woah! where'd it go? */
	    /* ### should have a better error here */
	    err = dav_new_error(pool, HTTP_NOT_FOUND, 0, NULL);
+5 −5
Original line number Diff line number Diff line
@@ -1268,6 +1268,7 @@ static int find_file(request_rec *r, const char *directive, const char *tag,
    request_rec *rr = NULL;
    int ret=0;
    char *error_fmt = NULL;
    apr_status_t rv = APR_SUCCESS;

    if (!strcmp(tag, "file")) {
        /* be safe; only files in this directory or below allowed */
@@ -1284,7 +1285,8 @@ static int find_file(request_rec *r, const char *directive, const char *tag,

            if (rr->status == HTTP_OK && rr->finfo.protection != 0) {
                to_send = rr->filename;
                if (apr_stat(finfo, to_send, rr->pool) != APR_SUCCESS) {
                if (apr_stat(finfo, to_send, 
                             APR_FINFO_NORM, rr->pool) != APR_SUCCESS) {
                    error_fmt = "unable to get information about \"%s\" "
                        "in parsed file %s";
                }
@@ -1297,10 +1299,8 @@ static int find_file(request_rec *r, const char *directive, const char *tag,

        if (error_fmt) {
            ret = -1;
            /* TODO: pass APLOG_NOERRNO if no apr_stat() failure; pass rv from apr_stat()
             * otherwise
             */
            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, error_fmt, to_send, r->filename);
            ap_log_rerror(APLOG_MARK, APLOG_ERR | (rv ? 0 : APLOG_NOERRNO),
                          rv, r, error_fmt, to_send, r->filename);
        }

        if (rr) ap_destroy_sub_req(rr);
Loading