fix(sysman): fixes multithread access issue with FDCache

Related-To: NEO-9720

Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
This commit is contained in:
Kulkarni, Ashwin Kumar
2023-12-07 07:40:17 +00:00
committed by Compute-Runtime-Automation
parent f395bdbdab
commit a064388ba8
6 changed files with 66 additions and 2 deletions

View File

@@ -46,6 +46,7 @@ void FdCache::eraseLeastUsedEntryFromCache() {
}
int FdCache::getFd(std::string file) {
std::unique_lock<std::mutex> lock(fdMutex);
int fd = -1;
if (fdMap.find(file) == fdMap.end()) {
fd = NEO::SysCalls::open(file.c_str(), O_RDONLY);

View File

@@ -18,6 +18,7 @@
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <sstream>
#include <string>
#include <sys/stat.h>
@@ -41,6 +42,7 @@ class FdCache {
std::map<std::string, std::pair<int, uint32_t>> fdMap = {};
private:
std::mutex fdMutex{};
void eraseLeastUsedEntryFromCache();
};