rbb 99/07/27 12:26:17
Modified: apr/file_io/unix dir.c fileacc.c fileio.h filestat.c open.c Log: Cleanup file I/O code. We no longer do a stat on every open, but when a user calls ap_getfileinfo, we are caching the results of that stat automatically. I am also continuing with the APRDOC effort in the unix tree. Revision Changes Path 1.17 +12 -0 apache-apr/apr/file_io/unix/dir.c Index: dir.c =================================================================== RCS file: /home/cvs/apache-apr/apr/file_io/unix/dir.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- dir.c 1999/07/06 17:01:38 1.16 +++ dir.c 1999/07/27 19:26:12 1.17 @@ -280,6 +280,12 @@ return APR_SUCCESS; } +/* ***APRDOC******************************************************** + * ap_status_t ap_get_os_dir(ap_dir_t *, ap_os_dir_t *) + * convert the dir from apr type to os specific type. + * arg 1) The apr dir to convert. + * arg 2) The os specific dir we are converting to + */ ap_status_t ap_get_os_dir(struct dir_t *dir, ap_os_dir_t *thedir) { if (dir == NULL) { @@ -289,6 +295,12 @@ return APR_SUCCESS; } +/* ***APRDOC******************************************************** + * ap_status_t ap_get_os_dir(ap_dir_t *, ap_os_dir_t *) + * convert the dir from os specific type to apr type. + * arg 1) The os specific dir to convert + * arg 2) The apr dir we are converting to. + */ ap_status_t ap_put_os_dir(ap_context_t *cont, struct dir_t **dir, ap_os_dir_t *thedir) { 1.15 +15 -0 apache-apr/apr/file_io/unix/fileacc.c Index: fileacc.c =================================================================== RCS file: /home/cvs/apache-apr/apr/file_io/unix/fileacc.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- fileacc.c 1999/06/21 18:28:09 1.14 +++ fileacc.c 1999/07/27 19:26:13 1.15 @@ -118,6 +118,9 @@ ap_status_t ap_get_filesize(struct file_t *file, ap_ssize_t *size) { if (file != NULL) { + if (!file->stated) { + ap_getfileinfo(file); + } *size = file->size; return APR_SUCCESS; } @@ -136,6 +139,9 @@ ap_status_t ap_get_fileperms(struct file_t *file, ap_fileperms_t *perm) { if (file != NULL) { + if (!file->stated) { + ap_getfileinfo(file); + } *perm = file->protection; return APR_SUCCESS; } @@ -154,6 +160,9 @@ ap_status_t ap_get_fileatime(struct file_t *file, time_t *time) { if (file != NULL) { + if (!file->stated) { + ap_getfileinfo(file); + } *time = file->atime; return APR_SUCCESS; } @@ -172,6 +181,9 @@ ap_status_t ap_get_filectime(struct file_t *file, time_t *time) { if (file != NULL) { + if (!file->stated) { + ap_getfileinfo(file); + } *time = file->ctime; return APR_SUCCESS; } @@ -190,6 +202,9 @@ ap_status_t ap_get_filemtime(struct file_t *file, time_t *time) { if (file != NULL) { + if (!file->stated) { + ap_getfileinfo(file); + } *time = file->mtime; return APR_SUCCESS; } 1.8 +1 -0 apache-apr/apr/file_io/unix/fileio.h Index: fileio.h =================================================================== RCS file: /home/cvs/apache-apr/apr/file_io/unix/fileio.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- fileio.h 1999/05/21 19:53:13 1.7 +++ fileio.h 1999/07/27 19:26:13 1.8 @@ -71,6 +71,7 @@ int filedes; char * fname; int buffered; + int stated; mode_t protection; uid_t user; gid_t group; 1.8 +4 -6 apache-apr/apr/file_io/unix/filestat.c Index: filestat.c =================================================================== RCS file: /home/cvs/apache-apr/apr/file_io/unix/filestat.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- filestat.c 1999/06/01 12:05:42 1.7 +++ filestat.c 1999/07/27 19:26:13 1.8 @@ -59,12 +59,9 @@ #include "apr_errno.h" /* ***APRDOC******************************************************** - * ap_status_t ap_remove_file(ap_context_t *, char *) - * delete the specified file. - * arg 1) The context to use. - * arg 2) The full path to the file (using / on all systems) - * NOTE: If the file is open, it won't be removed until all instances are - * closed. + * ap_status_t ap_getfileinfo(ap_file_t *) + * get the specified file's stats.. + * arg 1) The full to get information about. */ ap_status_t ap_getfileinfo(struct file_t *thefile) { @@ -79,6 +76,7 @@ thefile->atime = info.st_atime; thefile->mtime = info.st_mtime; thefile->ctime = info.st_ctime; + thefile->stated = 1; return APR_SUCCESS; } else { 1.31 +15 -9 apache-apr/apr/file_io/unix/open.c Index: open.c =================================================================== RCS file: /home/cvs/apache-apr/apr/file_io/unix/open.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- open.c 1999/07/06 17:01:39 1.30 +++ open.c 1999/07/27 19:26:14 1.31 @@ -146,15 +146,9 @@ (*new)->filedes = -1; return errno; } - - if (ap_getfileinfo(*new) == APR_SUCCESS) { - ap_register_cleanup((*new)->cntxt, (void *)(*new), file_cleanup, NULL); - return APR_SUCCESS; - } - else { - (*new)->filedes = -1; - return APR_ENOSTAT; - } + (*new)->stated = 0; /* we haven't called stat for this file yet. */ + ap_register_cleanup((*new)->cntxt, (void *)(*new), file_cleanup, NULL); + return APR_SUCCESS; } /* ***APRDOC******************************************************** @@ -191,6 +185,12 @@ } } +/* ***APRDOC******************************************************** + * ap_status_t ap_get_os_file(ap_file_t *, ap_os_file_t *) + * convert the file from apr type to os specific type. + * arg 1) The apr file to convert. + * arg 2) The os specific file we are converting to + */ ap_status_t ap_get_os_file(struct file_t *file, ap_os_file_t *thefile) { if (file == NULL) { @@ -200,6 +200,12 @@ return APR_SUCCESS; } +/* ***APRDOC******************************************************** + * ap_status_t ap_get_os_file(ap_file_t *, ap_os_file_t *) + * convert the file from os specific type to apr type. + * arg 1) The os specific file to convert + * arg 2) The apr file we are converting to. + */ ap_status_t ap_put_os_file(ap_context_t *cont, struct file_t **file, ap_os_file_t *thefile) {