Skip to content

Commit

Permalink
CameraHandler: Do not call streamStop() with lock held
Browse files Browse the repository at this point in the history
The problem is that streamStop() needs to wait for eventThread to
finish which in turn might hold the same lock if there is a work
to do, see CommandHandler::onFrameDoneCallback() for details.

If the streamStop() *must* be protected by the lock, we need either
consider dropping the lock from onFrameDoneCallback() or terminate
eventThread forcely.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
  • Loading branch information
Oleksandr Tyshchenko authored and otyshchenko1 committed Mar 8, 2023
1 parent 518ebba commit b12d493
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/CameraHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,16 @@ void CameraHandler::streamStop(domid_t domId, const xencamera_req& aReq,
return;
}

std::lock_guard<std::mutex> lock(mLock);
std::unique_lock<std::mutex> lock(mLock);

DLOG(mLog, DEBUG) << "Handle command [STREAM STOP] dom " <<
std::to_string(domId);

mStreamingNow.erase(domId);
if (!mStreamingNow.size())
if (!mStreamingNow.size()) {
lock.unlock();
mCamera->streamStop();
}
}

void CameraHandler::release()
Expand Down

0 comments on commit b12d493

Please sign in to comment.