看板 DFBSD_commit 關於我們 聯絡資訊
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) {