MT#55283 fix session reference booboo

If we remove a session that is not the session we're looking for
(re-used session ID after a removal race), we must return the incorrect
session to the hash table.

Change-Id: Iab73e1994251e5be766406b4e537a954b0e81f07
pull/1870/head
Richard Fuchs 1 year ago
parent 7b9fcae055
commit 164f688fc1

@ -1465,8 +1465,11 @@ static const char *janus_destroy(struct websocket_message *wm, JsonReader *reade
struct janus_session *ht_session = NULL; struct janus_session *ht_session = NULL;
t_hash_table_steal_extended(janus_sessions, &session->id, NULL, &ht_session); t_hash_table_steal_extended(janus_sessions, &session->id, NULL, &ht_session);
if (ht_session != session) if (ht_session != session) {
if (ht_session) // return wrongly stolen session
t_hash_table_insert(janus_sessions, &ht_session->id, ht_session);
return "Sesssion ID not found"; // already removed/destroyed return "Sesssion ID not found"; // already removed/destroyed
}
janus_session_cleanup(session); janus_session_cleanup(session);
obj_put(session); obj_put(session);

Loading…
Cancel
Save