Skip to content

Commit

Permalink
Add support for using AsyncFileReader on filesystems without O_DIRECT…
Browse files Browse the repository at this point in the history
… support.

This fixes a test failure on the Linux tmpfs filesystem.

Fixes: microsoft#329
  • Loading branch information
pabs3 committed Apr 1, 2023
1 parent a965529 commit f3a5dcf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions AnnService/inc/Helper/AsyncFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ namespace SPTAG
std::uint16_t threadPoolSize = 4)
{
m_fileHandle = open(filePath, O_RDONLY | O_DIRECT);
// O_DIRECT isn't supported on some filesystems
if (m_fileHandle <= 0 && errno == EINVAL) {
m_fileHandle = open(filePath, O_RDONLY);
}
if (m_fileHandle <= 0) {
SPTAGLIB_LOG(LogLevel::LL_Error, "Failed to create file handle: %s\n", filePath);
return false;
Expand Down

0 comments on commit f3a5dcf

Please sign in to comment.