Permalink
Browse files

o use readdir_r() - looks like readdir is indeed not really multi-thread

  aware.
  • Loading branch information...
1 parent 11c2493 commit bf030afb4c0fe8c4e9fe1a64b048ac13b17334f7 @hzeller committed Sep 29, 2012
Showing with 7 additions and 2 deletions.
  1. +1 −1 Makefile
  2. +6 −1 folve-main.cc
View
@@ -6,7 +6,7 @@ F_VERSION=$(shell git log -n1 --date=short --format="%cd (commit=%h)" 2>/dev/nul
CFLAGS=-D_FILE_OFFSET_BITS=64 -Wall -O2 -DFOLVE_VERSION='"$(F_VERSION)"'
CXXFLAGS=$(CFLAGS)
-LDFLAGS=-lfuse -lsndfile -lzita-convolver -lmicrohttpd -lboost_thread-mt -lfftw3f
+LDFLAGS=-lfuse -lsndfile -lzita-convolver -lmicrohttpd -lfftw3f
ifdef LINK_STATIC
# static linking requires us to be much more explicit when linking
View
@@ -86,7 +86,11 @@ static int folve_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
if (dp == NULL)
return -errno;
- while ((de = readdir(dp)) != NULL) {
+ // Entry size is a bit shaky to calculate, but this should be the upper bound.
+ const size_t entry_size = sizeof(struct dirent) + PATH_MAX;
+ struct dirent *entry_buf = (struct dirent *) malloc(entry_size);
+
+ while (readdir_r(dp, entry_buf, &de) == 0 && de != NULL) {
struct stat st;
memset(&st, 0, sizeof(st));
st.st_ino = de->d_ino;
@@ -95,6 +99,7 @@ static int folve_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
if (filler(buf, entry_name, &st, 0))
break;
}
+ free(entry_buf);
closedir(dp);
return 0;

0 comments on commit bf030af

Please sign in to comment.