Added deepelement signal disconnect#502
Conversation
|
Pull request must be merged with a description containing the required fields, Summary: If there is no jira releated to this change, please put 'Jira: NO-JIRA'. Description can be changed by editing the top comment on your pull request and making a new commit. |
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent late/async deep-element-added GStreamer callbacks from interacting with a tearing-down GstGenericPlayer, by tracking the signal handler ID, disconnecting it during destruction, and adding synchronization around worker-thread access.
Changes:
- Store the
deep-element-addedsignal handler ID and disconnect it duringGstGenericPlayerdestruction. - Add a shutdown fence (
m_isShuttingDown) and guarddeepElementAdded()against late callbacks. - Add a mutex to serialize worker-thread access between callbacks and teardown.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| media/server/gstplayer/source/GstGenericPlayer.cpp | Track/disconnect deep-element-added, add shutdown guard and mutex usage in callback + worker teardown. |
| media/server/gstplayer/include/GstGenericPlayer.h | Add new members for shutdown fencing, mutex protection, and handler ID storage. |
Comments suppressed due to low confidence (1)
media/server/gstplayer/source/GstGenericPlayer.cpp:299
resetWorkerThread()now guards writes tom_workerThreadwithm_workerThreadMutex, anddeepElementAdded()guards reads with the same mutex. However other GStreamer signal callbacks in this file (e.g.setupSource()/setupElement()) still readm_workerThreadwithout taking this mutex, so concurrent teardown can still cause a C++ data race/UB. To actually make this thread-safe, the same synchronization (mutex and/orm_isShuttingDowncheck) needs to be applied consistently to all callbacks/threads that accessm_workerThread.
void GstGenericPlayer::resetWorkerThread()
{
std::lock_guard<std::mutex> lock{m_workerThreadMutex};
if (!m_workerThread)
{
return;
}
// Shutdown task thread
m_workerThread->enqueueTask(m_taskFactory->createShutdown(*this));
m_workerThread->join();
m_workerThread.reset();
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Disconnect deep-element callback before worker teardown. | ||
| if (m_context.pipeline && m_deepElementAddedHandlerId != 0) | ||
| { | ||
| g_signal_handler_disconnect(m_context.pipeline, m_deepElementAddedHandlerId); | ||
| m_deepElementAddedHandlerId = 0; | ||
| } |
|
Coverage statistics of your commit: |
No description provided.