Skip to content

Commit

Permalink
Fix get_modified_time to avoid race condition on Windows
Browse files Browse the repository at this point in the history
If multiple processes tried to read the same input file simultaneously,
get_modified_time would fail. With this change, get_modified_time
does not need to actually open the file in order to read the metadata.
  • Loading branch information
speth committed Mar 31, 2016
1 parent 2bfbd73 commit 05198dd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/base/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static std::mutex xml_mutex;

static int get_modified_time(const std::string& path) {
#ifdef _WIN32
HANDLE hFile = CreateFile(path.c_str(), GENERIC_READ, FILE_SHARE_WRITE,
HANDLE hFile = CreateFile(path.c_str(), NULL, NULL,
NULL, OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
throw CanteraError("get_modified_time", "Couldn't open file:" + path);
Expand Down

0 comments on commit 05198dd

Please sign in to comment.