You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Michael Friedel <mf...@lbell.slctnet.com> on 1999/03/26 07:19:19 UTC

mod_proxy/4139: Garbage collection fails

>Number:         4139
>Category:       mod_proxy
>Synopsis:       Garbage collection fails
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Thu Mar 25 22:20:01 PST 1999
>Last-Modified:
>Originator:     mfriedel@lbell.slctnet.com
>Organization:
apache
>Release:        1.3.6
>Environment:
WIN32/NT4.0 SP4
>Description:
Garbage collection fails becaus on the WIN32 platform the open() function does not work with directories.
>How-To-Repeat:
Turn on garbage collection
>Fix:
The solution is to use stat instead of open/fstat to differentiate between files/directories.

Here is the patch:

--- ..\..\..\org\proxy_cache.c	Sun Feb 07 12:48:32 1999
+++ proxy_cache.c	Thu Mar 25 22:21:42 1999
@@ -56,7 +56,6 @@
  */
 
 /* Cache and garbage collection routines for Apache proxy */
-
 #include "mod_proxy.h"
 #include "http_conf_globals.h"
 #include "http_log.h"
@@ -448,6 +447,16 @@
 #endif
 
 /* read the file */
+#if defined(WIN32)
+    /* On WIN32 open does not work for directories, so we us stat instead
+	of fstat to determine if the file is a directory */
+	if (stat(filename, &buf) == -1) {
+	    ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
+			 "proxy gc: stat(%s)", filename);
+	    continue;
+	}
+	fd = -1;
+#else
 	fd = open(filename, O_RDONLY | O_BINARY);
 	if (fd == -1) {
 	    if (errno != ENOENT)
@@ -461,12 +470,15 @@
 	    close(fd);
 	    continue;
 	}
+#endif
 
 /* In OS/2 this has already been done above */
 #ifndef OS2
 	if (S_ISDIR(buf.st_mode)) {
 	    char newcachedir[HUGE_STRING_LEN];
+#if !defined(WIN32)
 	    close(fd);
+#endif
 	    ap_snprintf(newcachedir, sizeof(newcachedir),
 			"%s%s/", cachesubdir, ent->d_name);
 	    if (!sub_garbage_coll(r, files, cachebasedir, newcachedir)) {
@@ -484,6 +496,21 @@
 	    }
 	    continue;
 	}
+#endif
+
+#if defined(WIN32)
+	/* 
+	   Since we have determined that the file is not a directory,
+	   we shouldbe able to open it now 
+	*/
+	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) = %d", filename, errno);
+	    continue;
+	}
+
 #endif
 
 	i = read(fd, line, 26);

>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, ]
[you need to include <ap...@Apache.Org> in the Cc line ]
[and leave the subject line UNCHANGED.  This is not done]
[automatically because of the potential for mail loops. ]
[If you do not include this Cc, your reply may be ig-   ]
[nored unless you are responding to an explicit request ]
[from a developer.                                      ]
[Reply only with text; DO NOT SEND ATTACHMENTS!         ]