summaryrefslogtreecommitdiff
path: root/sysdeps/unix/readdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/readdir.c')
-rw-r--r--sysdeps/unix/readdir.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sysdeps/unix/readdir.c b/sysdeps/unix/readdir.c
index 00446a2d2b..5d0c40fdc1 100644
--- a/sysdeps/unix/readdir.c
+++ b/sysdeps/unix/readdir.c
@@ -40,6 +40,8 @@ readdir (DIR *dirp)
return NULL;
}
+ __libc_lock_lock (dirp->lock);
+
do
{
size_t reclen;
@@ -62,7 +64,10 @@ readdir (DIR *dirp)
base = dirp->filepos;
bytes = __getdirentries (dirp->fd, dirp->data, maxread, &base);
if (bytes <= 0)
- return NULL;
+ {
+ dp = NULL;
+ break;
+ }
dirp->size = (size_t) bytes;
/* Reset the offset into the buffer. */
@@ -96,5 +101,7 @@ readdir (DIR *dirp)
/* Skip deleted files. */
} while (dp->d_ino == 0);
+ __libc_lock_unlock (dirp->lock);
+
return dp;
}