diff options
author | Sascha Schumann <sas@php.net> | 2000-05-23 15:13:16 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 2000-05-23 15:13:16 +0000 |
commit | 2aaa538aef24cd8140ff6aa80e544978dd7035fd (patch) | |
tree | 1aa8491f80a1d81bb80ca0f118b19f98e5b21163 /ext/standard/dir.c | |
parent | be6afb3fccd20f2b0fab5816bc05362fb7e0326f (diff) | |
download | php-git-2aaa538aef24cd8140ff6aa80e544978dd7035fd.tar.gz |
Use reentrant version of readdir. If the target platform does not support
the POSIX-like readdir_r, we fall back to readdir. In ZTS mode, this will
cause php_readdir_r calls to be serialized.
Diffstat (limited to 'ext/standard/dir.c')
-rw-r--r-- | ext/standard/dir.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 18c33db4ce..9b00a3879e 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -273,14 +273,14 @@ PHP_FUNCTION(readdir) { pval **id, **tmp, *myself; php_dir *dirp; - struct dirent *direntp; + struct dirent entry; + struct dirent *result; DIRLS_FETCH(); FETCH_DIRP(); - - direntp = readdir(dirp->dir); - if (direntp) { - RETURN_STRINGL(direntp->d_name, strlen(direntp->d_name), 1); + + if (php_readdir_r(dirp->dir, &entry, &result) == 0 && result) { + RETURN_STRINGL(result->d_name, strlen(result->d_name), 1); } RETURN_FALSE; } |