Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterating through listeners GHashTable requires listeners_mutex lock #116

Open
mattc1170 opened this issue Feb 17, 2022 · 2 comments
Open

Comments

@mattc1170
Copy link

We are using gstinterpipe in a large video media server product that can have 100s of gstinterpipesrc and gstinterpipesink elements. Our application has seen crashes when gstinterpipesrc elements are being removed at the same time that gstinterpipesink elements are either being added or removed. When a gstinterpipesink element is added or removed, a call to gst_inter_pipe_node_add() or gst_inter_pipe_node_remove() is made wherein g_hash_table_foreach() will iterate through the listeners hash table to notify the listeners that a node has been added. This iteration can happen while a listener is being removed from the hash table by another thread.

The g_hash_table_foreach() calls need to be protected. Initial testing of a locking mechanism revealed that using the existing GMutex listeners_mutex would cause deadlock because the same thread would need to lock the mutex twice under certain circumstances. Changing the listeners_mutex to a GRecMutex and protecting the g_hash_table_foreach() calls with this new mutex seems to have fixed the crashes in our application.

I will submit a patch or PR with our suggested code changes.

@michaelgruner
Copy link
Collaborator

Thanks! looking forward to the PR

@mattc1170
Copy link
Author

Pull Request submitted: #117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants