summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-11-10 10:55:26 +0000
committerDmitry Stogov <dmitry@php.net>2006-11-10 10:55:26 +0000
commita5f951f27cf9937f0cfd43afe0ff8938faa7cfb4 (patch)
treee3148b17be7cd6158b43b139979cfe49d14743c1
parentab5268fc84c53396857b3b27ea54aa1438ffe024 (diff)
downloadphp-git-a5f951f27cf9937f0cfd43afe0ff8938faa7cfb4.tar.gz
Removed unnecessary checks for ISREG file and corresponding stat() calls on Windows
-rw-r--r--NEWS2
-rw-r--r--main/fopen_wrappers.c5
-rw-r--r--main/streams/plain_wrapper.c9
3 files changed, 11 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index a2aa33cd7a..0b11996f48 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2007, PHP 5.2.1
+- Windows related optimizations (Dmitry, Stas)
+ . removed unnecessary checks for ISREG file and corresponding stat() calls
- Zend Memory Manager Improvements (Dmitry)
. use HeapAlloc() instead of VirtualAlloc()
. use "win32" storage manager (instead of "malloc") on Windows by default
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 4c946a4ea2..b4f3fcb7d6 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -255,7 +255,9 @@ static FILE *php_fopen_and_set_opened_path(const char *path, const char *mode, c
PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC)
{
FILE *fp;
+#ifndef PHP_WIN32
struct stat st;
+#endif
char *path_info, *filename;
int length;
@@ -321,11 +323,14 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC)
}
fp = VCWD_FOPEN(filename, "rb");
+#ifndef PHP_WIN32
/* refuse to open anything that is not a regular file */
if (fp && (0 > fstat(fileno(fp), &st) || !S_ISREG(st.st_mode))) {
fclose(fp);
fp = NULL;
}
+#endif
+
if (!fp) {
STR_FREE(SG(request_info).path_translated); /* for same reason as above */
SG(request_info).path_translated = NULL;
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index f61bde5c06..f2f016709b 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -891,6 +891,8 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, cha
efree(persistent_id);
}
+ /* WIN32 always set ISREG flag */
+#ifndef PHP_WIN32
/* sanity checks for include/require.
* We check these after opening the stream, so that we save
* on fstat() syscalls */
@@ -899,15 +901,12 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, cha
int r;
r = do_fstat(self, 0);
- if (
-#ifndef PHP_WIN32
- (r != 0) || /* it is OK for fstat to fail under win32 */
-#endif
- (r == 0 && !S_ISREG(self->sb.st_mode))) {
+ if ((r == 0 && !S_ISREG(self->sb.st_mode))) {
php_stream_close(ret);
return NULL;
}
}
+#endif
return ret;
}