With suggestions and support from Ben Kummer ([EMAIL PROTECTED]) I made a
small bug fix.

Here is the diff command line I used:

diff proxy_cache.c.org proxy_cache.c >proxy_cache.c.diff

The result of the diff is:

----------------------------------------------------
403,406c403,405
< /* is it a temporary file? */
<       if (strncmp(ent->d_name, "tmp", 3) == 0) {
< /* then stat it to see how old it is; delete temporary files > 1 day old
*/
<           if (stat(filename, &buf) == -1) {
---
> 
>       /* stat the file to get type and date */
>     if (stat(filename, &buf) == -1) {
410,411c409,412
<           }
<           else if (garbage_now != -1 && buf.st_atime < garbage_now -
SEC_ONE_DAY &&
---
>     }
> /* is it a temporary file? */
>       if (strncmp(ent->d_name, "tmp", 3) == 0) {
>           if (garbage_now != -1 && buf.st_atime < garbage_now -
SEC_ONE_DAY &&
450,464d450
< /* read the file */
<       fd = open(filename, O_RDONLY | O_BINARY);
<       if (fd == -1) {
<           if (errno != ENOENT)
<               ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
<                            "proxy gc: open(%s)", filename);
<           continue;
<       }
<       if (fstat(fd, &buf) == -1) {
<           ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
<                        "proxy gc: fstat(%s)", filename);
<           close(fd);
<           continue;
<       }
< 
466a453
> /* use stat from above */
469d455
<           close(fd);
487a474,484
> 
>       /* read the file */
>       fd = open(filename, O_RDONLY | O_BINARY);
>       if (fd == -1) {
>           if (errno != ENOENT)
>               ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
>                            "proxy gc: open(%s)", filename);
>           continue;
>       }
> 
>       /* stat already done */
----------------------------------------------------


Problem description:

A stat was only made if the file is a .tmp file. Otherwise the file is
opened (failed for directory on WinNT) and the file desciptor is used to
call fstat().

I used only one stat() call for all types of files and removed the fstat().
The file is only opened if it's not a directory.


Please review the changes and add it to further Win32 releases
Thanks
Klaus Mueller

Reply via email to