[Pkg-voip-commits] [janus] 57/163: Make sure handles are removed right away in case of a session timeout (see #963)

Jonas Smedegaard dr at jones.dk
Sat Oct 28 01:22:09 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.2.5-1
in repository janus.

commit aa880c14750722b1640e7c739b33c7dce078e297
Author: Lorenzo Miniero <lminiero at gmail.com>
Date:   Wed Aug 2 14:58:44 2017 +0200

    Make sure handles are removed right away in case of a session timeout (see #963)
---
 janus.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/janus.c b/janus.c
index 25c12e2..d2e3c90 100644
--- a/janus.c
+++ b/janus.c
@@ -427,7 +427,24 @@ static gboolean janus_check_sessions(gpointer user_data) {
 			gint64 now = janus_get_monotonic_time();
 			if (now - session->last_activity >= (gint64)session_timeout * G_USEC_PER_SEC && !session->timeout) {
 				JANUS_LOG(LOG_INFO, "Timeout expired for session %"SCNu64"...\n", session->session_id);
-
+				/* Mark the session as over, we'll deal with it later */
+				janus_mutex_lock(&session->mutex);
+				session->timeout = 1;
+				/* Remove all handles */
+				if(session->ice_handles != NULL && g_hash_table_size(session->ice_handles) > 0) {
+					GHashTableIter iter;
+					gpointer value;
+					g_hash_table_iter_init(&iter, session->ice_handles);
+					while(g_hash_table_iter_next(&iter, NULL, &value)) {
+						janus_ice_handle *h = value;
+						if(!h || g_atomic_int_get(&stop)) {
+							continue;
+						}
+						janus_ice_handle_destroy(session, h->handle_id);
+						g_hash_table_iter_remove(&iter);
+					}
+				}
+				janus_mutex_unlock(&session->mutex);
 				/* Notify the transport */
 				if(session->source) {
 					json_t *event = json_object();
@@ -442,8 +459,6 @@ static gboolean janus_check_sessions(gpointer user_data) {
 				if(janus_events_is_enabled())
 					janus_events_notify_handlers(JANUS_EVENT_TYPE_SESSION, session->session_id, "timeout", NULL);
 
-				/* Mark the session as over, we'll deal with it later */
-				session->timeout = 1;
 				/* FIXME Is this safe? apparently it causes hash table errors on the console */
 				g_hash_table_iter_remove(&iter);
 				g_hash_table_insert(old_sessions, janus_uint64_dup(session->session_id), session);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/janus.git



More information about the Pkg-voip-commits mailing list