Skip to content

Commit

Permalink
Add a delay and retry if we failed to access ACL.
Browse files Browse the repository at this point in the history
  • Loading branch information
herve-er committed May 2, 2024
1 parent 8410114 commit 5b72f09
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libcommonserver/io/iohelper_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ static bool setRightsWindowsApi(const SyncPath &path, DWORD permission, ACCESS_M
}

static bool getRightsWindowsApi(const SyncPath &path, bool &read, bool &write, bool &exec, IoError &ioError,
log4cplus::Logger logger) noexcept { // Always return false if ioError != IoErrorSuccess, caller
log4cplus::Logger logger, bool retry = true) noexcept { // Always return false if ioError != IoErrorSuccess, caller
// should call _isExpectedError.
ioError = IoErrorSuccess;
WCHAR szFilePath[MAX_PATH_LENGTH_WIN_LONG];
Expand Down Expand Up @@ -472,9 +472,13 @@ static bool getRightsWindowsApi(const SyncPath &path, bool &read, bool &write, b
setRightsWindowsApi(path, READ_CONTROL, ACCESS_MODE::REVOKE_ACCESS, ioError, logger);
ioError = dWordError2ioError(result);
}
}
}

if (ioError != IoErrorSuccess) {
if (retry) {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
return getRightsWindowsApi(path, read, write, exec, ioError, logger, false);
}
LOGW_INFO(logger, L"Unexpected error: path='" << Utility::formatSyncPath(path) << L"',DWORD err='" << result << L"'");
return false; // Caller should call _isExpectedError
}
Expand Down

0 comments on commit 5b72f09

Please sign in to comment.