DragonFly BSD
DragonFly commits List (threaded) for 2005-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: cvs commit: src/include dirent.h stdio.h src/lib/libc Makefile Makefile.inc src/lib/libc/compat-43 creat.c sigcompat.c src/lib/libc/db/btree bt_close.c bt_open.c src/lib/libc/db/hash hash.c hash_page.c src/lib/libc/db/mpool mpool.c ...


From: YONETANI Tomokazu <qhwt+dfly@xxxxxxxxxx>
Date: Tue, 8 Feb 2005 11:17:36 +0900

On Mon, Jan 31, 2005 at 02:29:48PM -0800, Matthew Dillon wrote:
> http://www.dragonflybsd.org/cvsweb/src/lib/libc/gen/readdir.c.diff?r1=1.2&r2=1.3&f=u

Shouldn't "dp = readdir(dirp)" removed now that we use _readdir_unlocked()?

@@ -90,32 +107,26 @@ readdir_r(dirp, entry, result)
        struct dirent *dp;
        int ret, saved_errno;

-#ifdef _THREAD_SAFE
-       if ((ret = _FD_LOCK(dirp->dd_fd, FD_READ, NULL)) != 0)
-               return (ret);
-#endif
-
        saved_errno = errno;
        errno = 0;
        dp = readdir(dirp);	<<=== REMOVE THIS
+       if (__isthreaded) {
+               _pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
+               if ((dp = _readdir_unlocked(dirp)) != NULL)
+                       memcpy(entry, dp, sizeof *entry);
+               _pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
+       }
+       else if ((dp = _readdir_unlocked(dirp)) != NULL)
+               memcpy(entry, dp, sizeof *entry);
+
        if (errno != 0) {
                if (dp == NULL) {



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]