From 2c0456680eda54d9e9e1653757378712d3a0f400 Mon Sep 17 00:00:00 2001 From: "mooredan@suncup.net" Date: Fri, 11 Feb 2011 03:52:31 +0000 Subject: [PATCH] Resolves issue #156 s3fs_readdir() now looks at stat_cache git-svn-id: http://s3fs.googlecode.com/svn/trunk@312 df820570-a93a-0410-bd06-b72b767a4274 --- configure.ac | 2 +- src/s3fs.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index ec8d395..92bd4d6 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT(s3fs, 1.38) +AC_INIT(s3fs, 1.39) AC_CANONICAL_SYSTEM diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 6ad2926..9092b88 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -3276,7 +3276,19 @@ static int s3fs_readdir( } } - if (Key.size() > 0) { + bool in_stat_cache = false; + pthread_mutex_lock(&stat_cache_lock); + stat_cache_t::iterator iter = stat_cache.find("/" + Key); + if(iter != stat_cache.end()) { + // in stat cache, skip http request + if(filler(buf, mybasename(Key).c_str(), 0, 0)) + break; + + in_stat_cache = true; + } + pthread_mutex_unlock(&stat_cache_lock); + + if (Key.size() > 0 && !in_stat_cache) { if (filler(buf, mybasename(Key).c_str(), 0, 0)) { break; }