Fix Concurrent extract + open race on train_last.onnx

This commit is contained in:
2026-04-24 11:29:28 +10:00
parent 91bdb3f96b
commit baa88bcc48
4 changed files with 206 additions and 8 deletions

View File

@@ -16,6 +16,8 @@
#include <vector>
#include <regex>
#include <stdio.h>
#include <memory>
#include <mutex>
//namespace logging = boost::log;
//namespace attrs = boost::log::attributes;
@@ -89,4 +91,12 @@ namespace fs = std::filesystem;
// For training engine
//bool ExtractPasswordProtectedZipForTrainingEgnine(const std::string& zipFileName, const std::string& password, const std::string& modelName, std::string& outputFolder, bool edgeDeviceModel = true);
ANSLICENSE_API bool ExtractProtectedZipFile(const std::string& zipFileName,const std::string& password,const std::string& modelName,const std::string outputFolder);
// Per-path mutex for a model folder. Used to serialize extract ↔ session
// creation on the same extracted folder so concurrent CreateANSODHandle calls
// cannot truncate/rewrite a model file while another thread is loading it.
// Keyed by folder path (not zip path) so both extractor and consumer agree.
// Returns std::timed_mutex so callers can bound their wait and avoid a hang
// if a peer thread deadlocks inside extraction or ORT session creation.
ANSLICENSE_API std::shared_ptr<std::timed_mutex> GetModelFolderLock(const std::string& folderPath);
#endif