Skip to content

Commit 8826889

Browse files
author
Yucheng Low
committed
Merge pull request #182 from haijieg/fix_cache_stream_race
Fix incorrect cache eviction
2 parents ea65a77 + 12cd0ac commit 8826889

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

oss_src/fileio/union_fstream.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ union_fstream::union_fstream(std::string url,
6868
input_stream = (*cachestream)->get_underlying_stream();
6969
if (input_stream == nullptr) input_stream = cachestream;
7070
m_file_size = (*cachestream)->file_size();
71+
original_input_stream_handle = std::static_pointer_cast<std::istream>(cachestream);
7172
}
7273
} else if (boost::starts_with(url, "s3://")) {
7374
// the S3 file type currently works by download/uploading a local file
@@ -80,6 +81,7 @@ union_fstream::union_fstream(std::string url,
8081
input_stream = (*s3stream)->get_underlying_stream();
8182
if (input_stream == nullptr) input_stream = s3stream;
8283
m_file_size = (*s3stream)->file_size();
84+
original_input_stream_handle = std::static_pointer_cast<std::istream>(s3stream);
8385
}
8486
} else {
8587
// must be local file

oss_src/fileio/union_fstream.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class union_fstream {
6666

6767
std::shared_ptr<std::istream> input_stream;
6868
std::shared_ptr<std::ostream> output_stream;
69+
70+
// Hold the input stream from cache or s3 stream.
71+
std::shared_ptr<std::istream> original_input_stream_handle;
6972
};
7073

7174
} // namespace graphlab

0 commit comments

Comments
 (0)