From 41c19905cd8c33f0ed524b6b08a4bd2505416c8a Mon Sep 17 00:00:00 2001 From: Kyungwook Tak Date: Fri, 10 Jun 2016 16:57:14 +0900 Subject: [PATCH] Skip errored directory on file system visitor Silently skip unable to read directory stream to reduce side-effect to whole other directories. Change-Id: Ied216e0efcb0598251f5f7fad8d7f9abdabd17b6 Signed-off-by: Kyungwook Tak --- src/framework/service/file-system.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/framework/service/file-system.cpp b/src/framework/service/file-system.cpp index 2c37315..16be24d 100644 --- a/src/framework/service/file-system.cpp +++ b/src/framework/service/file-system.cpp @@ -274,8 +274,20 @@ FsVisitor::~FsVisitor() FilePtr FsVisitor::next() { struct dirent *result = nullptr; - while (readdir_r(this->m_dirptr.get(), this->m_entryBuf, &result) == 0) { - if (result == nullptr) { // end of dir stream + while (true) { + bool isDone = false; + + if (readdir_r(this->m_dirptr.get(), this->m_entryBuf, &result) != 0) { + ERROR("readdir_r error on dir: " << this->m_dirs.front() << + " with errno: " << errno << ". Silently ignore this error & dir stream" + " to reduce side-effect of traversing all the other file systems."); + isDone = true; + } else if (result == nullptr) { + DEBUG("End of stream of dir: " << this->m_dirs.front()); + isDone = true; + } + + if (isDone) { this->m_dirs.pop(); while (!this->m_dirs.empty() && !(this->m_dirptr = openDir(this->m_dirs.front()))) -- 2.7.4