Skip to content

Commit

Permalink
Added extra reference to VideoRoom
Browse files Browse the repository at this point in the history
  • Loading branch information
lminiero committed Apr 2, 2021
1 parent bed081c commit 9bf29f9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugins/janus_videoroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -5826,6 +5826,7 @@ static void janus_videoroom_hangup_media_internal(gpointer session_data) {
is in this function and accessing to this function is synchronized
by sessions_mutex */
if(publisher != NULL) {
janus_refcount_increase(&publisher->ref);
/* Also notify event handlers */
if(notify_events && gateway->events_is_enabled()) {
json_t *info = json_object();
Expand All @@ -5838,6 +5839,7 @@ static void janus_videoroom_hangup_media_internal(gpointer session_data) {
publisher->subscribers = g_slist_remove(publisher->subscribers, subscriber);
janus_videoroom_hangup_subscriber(subscriber);
janus_mutex_unlock(&publisher->subscribers_mutex);
janus_refcount_decrease(&publisher->ref);
}
subscriber->e2ee = FALSE;
}
Expand Down

2 comments on commit 9bf29f9

@tmatth
Copy link
Contributor

@tmatth tmatth commented on 9bf29f9 Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a known issue or crash that this avoids?

@lminiero
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue was a race condition where the last reference for a publisher might be removed while we were updating the list of subscribers due to a subscriber leaving. I encountered this when testing a publisher with dozens of subscribers going away. I suspect it was related to #2582

Please sign in to comment.