mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-22 08:48:55 +00:00
Fixed a possible memory leak in the stat cache where
- items with an initial hit count of 0 would not be deleted Added an additiional integration test git-svn-id: http://s3fs.googlecode.com/svn/trunk@383 df820570-a93a-0410-bd06-b72b767a4274
This commit is contained in:
parent
6d12f31676
commit
2a09e0864e
@ -18,6 +18,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
@ -58,6 +59,9 @@ void add_stat_cache_entry(const char *path, struct stat *st) {
|
||||
if(foreground)
|
||||
cout << " add_stat_cache_entry[path=" << path << "]" << endl;
|
||||
|
||||
if(max_stat_cache_size < 1)
|
||||
return;
|
||||
|
||||
if(stat_cache.size() > max_stat_cache_size)
|
||||
truncate_stat_cache();
|
||||
|
||||
@ -87,8 +91,10 @@ void truncate_stat_cache() {
|
||||
for(iter = stat_cache.begin(); iter != stat_cache.end(); iter++) {
|
||||
hit_count = (* iter).second.hit_count;
|
||||
|
||||
if(!lowest_hit_count)
|
||||
if(!lowest_hit_count) {
|
||||
lowest_hit_count = hit_count;
|
||||
path_to_delete = (* iter).first;
|
||||
}
|
||||
|
||||
if(lowest_hit_count > hit_count)
|
||||
path_to_delete = (* iter).first;
|
||||
@ -97,5 +103,5 @@ void truncate_stat_cache() {
|
||||
stat_cache.erase(path_to_delete);
|
||||
pthread_mutex_unlock(&stat_cache_lock);
|
||||
|
||||
cout << " purged " << path_to_delete << " from the stat cache" << endl;
|
||||
printf(" purged %s from the stat cache\n", path_to_delete.c_str());
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ int curl_get_headers(const char *path, headers_t &meta) {
|
||||
return result;
|
||||
|
||||
// file exists in s3
|
||||
// fixme: clean this up. yuck.
|
||||
// fixme: clean this up.
|
||||
for (headers_t::iterator iter = responseHeaders.begin(); iter != responseHeaders.end(); ++iter) {
|
||||
string key = (*iter).first;
|
||||
string value = (*iter).second;
|
||||
|
@ -56,7 +56,6 @@ fi
|
||||
##########################################################
|
||||
echo "Testing mv file function ..."
|
||||
|
||||
|
||||
# if the rename file exists, delete it
|
||||
if [ -e $ALT_TEST_TEXT_FILE ]
|
||||
then
|
||||
@ -106,7 +105,7 @@ fi
|
||||
##########################################################
|
||||
# Rename test (individual directory)
|
||||
##########################################################
|
||||
echo "Testing directory mv directory function ..."
|
||||
echo "Testing mv directory function ..."
|
||||
if [ -e $TEST_DIR ]; then
|
||||
echo "Unexpected, this file/directory exists: ${TEST_DIR}"
|
||||
exit 1
|
||||
@ -241,6 +240,39 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
##########################################################
|
||||
# File permissions test (individual file)
|
||||
##########################################################
|
||||
echo "Testing chown file function ..."
|
||||
|
||||
# create the test file again
|
||||
echo $TEST_TEXT > $TEST_TEXT_FILE
|
||||
if [ ! -e $TEST_TEXT_FILE ]
|
||||
then
|
||||
echo "Could not create file ${TEST_TEXT_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ORIGINAL_PERMISSIONS=$(stat --format=%u:%g $TEST_TEXT_FILE)
|
||||
|
||||
chown 1000:1000 $TEST_TEXT_FILE;
|
||||
|
||||
# if they're the same, we have a problem.
|
||||
if [ $(stat --format=%a $TEST_TEXT_FILE) == $ORIGINAL_PERMISSIONS ]
|
||||
then
|
||||
echo "Could not modify $TEST_TEXT_FILE ownership"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# clean up
|
||||
rm $TEST_TEXT_FILE
|
||||
|
||||
if [ -e $TEST_TEXT_FILE ]
|
||||
then
|
||||
echo "Could not cleanup file ${TEST_TEXT_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
# Tests are finished
|
||||
#####################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user