Skip to content

Commit

Permalink
fix race condition in audiobridge plugin changeroom request (meetecho…
Browse files Browse the repository at this point in the history
  • Loading branch information
JeckLabs authored Jan 25, 2021
1 parent 3edb780 commit 674367a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions plugins/janus_audiobridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -5734,13 +5734,6 @@ static void *janus_audiobridge_handler(void *data) {
}
} else if(!strcasecmp(request_text, "changeroom")) {
/* The participant wants to leave the current room and join another one without reconnecting (e.g., a sidebar) */
janus_audiobridge_participant *participant = (janus_audiobridge_participant *)session->participant;
if(participant == NULL || participant->room == NULL) {
JANUS_LOG(LOG_ERR, "Can't change room (not in a room in the first place)\n");
error_code = JANUS_AUDIOBRIDGE_ERROR_NOT_JOINED;
g_snprintf(error_cause, 512, "Can't change room (not in a room in the first place)");
goto error;
}
JANUS_VALIDATE_JSON_OBJECT(root, join_parameters,
error_code, error_cause, TRUE,
JANUS_AUDIOBRIDGE_ERROR_MISSING_ELEMENT, JANUS_AUDIOBRIDGE_ERROR_INVALID_ELEMENT);
Expand Down Expand Up @@ -5768,6 +5761,14 @@ static void *janus_audiobridge_handler(void *data) {
room_id_str = (char *)json_string_value(room);
}
janus_mutex_lock(&rooms_mutex);
janus_audiobridge_participant *participant = (janus_audiobridge_participant *)session->participant;
if(participant == NULL || participant->room == NULL) {
janus_mutex_unlock(&rooms_mutex);
JANUS_LOG(LOG_ERR, "Can't change room (not in a room in the first place)\n");
error_code = JANUS_AUDIOBRIDGE_ERROR_NOT_JOINED;
g_snprintf(error_cause, 512, "Can't change room (not in a room in the first place)");
goto error;
}
/* Is this the same room we're in? */
if(participant->room && ((!string_ids && participant->room->room_id == room_id) ||
(string_ids && participant->room->room_id_str && !strcmp(participant->room->room_id_str, room_id_str)))) {
Expand Down

0 comments on commit 674367a

Please sign in to comment.