Skip to content

Commit 8e2dc85

Browse files
[CS Issue][Batch Plugin] Fix CS issue in Batch Plugin (openvinotoolkit#25683)
### Details: - the issue the static analyzer is complaining about is wait_for() not being in the loop - *...* ### Tickets: - CVS-145094 --------- Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com> Co-authored-by: Chen Peter <peter.chen@intel.com>
1 parent cc4cf68 commit 8e2dc85

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/plugins/auto_batch/src/async_infer_request.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ AsyncInferRequest::AsyncInferRequest(const std::shared_ptr<SyncInferRequest>& re
6969
// it is ok to call size() here as the queue only grows (and the bulk removal happens under the mutex)
7070
const int sz = static_cast<int>(workerInferRequest->_tasks.size());
7171
if (sz == workerInferRequest->_batch_size) {
72+
workerInferRequest->_is_wakeup = true;
7273
workerInferRequest->_cond.notify_one();
7374
}
7475
};

src/plugins/auto_batch/src/compiled_model.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ CompiledModel::GetWorkerInferRequest() const {
6464
workerRequestPtr->_infer_request_batched._so = m_compiled_model_with_batch._so;
6565
workerRequestPtr->_batch_size = m_device_info.device_batch_size;
6666
workerRequestPtr->_completion_tasks.resize(workerRequestPtr->_batch_size);
67+
workerRequestPtr->_is_wakeup = false;
6768
workerRequestPtr->_infer_request_batched->set_callback(
6869
[workerRequestPtr](std::exception_ptr exceptionPtr) mutable {
6970
if (exceptionPtr)
@@ -74,6 +75,7 @@ CompiledModel::GetWorkerInferRequest() const {
7475
workerRequestPtr->_completion_tasks[c]();
7576
}
7677
// reset the timeout
78+
workerRequestPtr->_is_wakeup = true;
7779
workerRequestPtr->_cond.notify_one();
7880
});
7981

@@ -83,6 +85,9 @@ CompiledModel::GetWorkerInferRequest() const {
8385
{
8486
std::unique_lock<std::mutex> lock(workerRequestPtr->_mutex);
8587
status = workerRequestPtr->_cond.wait_for(lock, std::chrono::milliseconds(m_time_out));
88+
if ((status != std::cv_status::timeout) && (workerRequestPtr->_is_wakeup == false))
89+
continue;
90+
workerRequestPtr->_is_wakeup = false;
8691
}
8792
if (m_terminate) {
8893
break;

src/plugins/auto_batch/src/compiled_model.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class CompiledModel : public ov::ICompiledModel {
3030
std::condition_variable _cond;
3131
std::mutex _mutex;
3232
std::exception_ptr _exception_ptr;
33+
bool _is_wakeup;
3334
};
3435

3536
CompiledModel(const std::shared_ptr<ov::Model>& model,

0 commit comments

Comments
 (0)