mirror of
https://github.com/php/php-src.git
synced 2026-04-30 03:33:17 +02:00
Removed unnecessary checks for ISREG file and corresponding stat() calls on Windows
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user