Revision 78955474 plugins/janus_voicemail.c

View differences:

plugins/janus_voicemail.c
216 216
	int seq;
217 217
	gboolean started;
218 218
	gboolean stopping;
219
	guint64 destroyed;	/* Time at which this session was marked as destroyed */
219
	gboolean hangingup;
220
	gint64 destroyed;	/* Time at which this session was marked as destroyed */
220 221
} janus_voicemail_session;
221 222
static GHashTable *sessions;
222 223
static GList *old_sessions;
......
477 478
	}
478 479
	janus_mutex_lock(&sessions_mutex);
479 480
	if(!session->destroyed) {
480
		session->destroyed = janus_get_monotonic_time();
481 481
		JANUS_LOG(LOG_VERB, "Removing VoiceMail session...\n");
482 482
		g_hash_table_remove(sessions, handle);
483 483
		janus_voicemail_hangup_media(handle);
484
		session->destroyed = janus_get_monotonic_time();
484 485
		/* Cleaning up and removing the session is done in a lazy way */
485 486
		old_sessions = g_list_append(old_sessions, session);
486 487
	}
......
609 610
		JANUS_LOG(LOG_ERR, "No session associated with this handle...\n");
610 611
		return;
611 612
	}
612
	if(session->destroyed)
613
		return;
614 613
	session->started = FALSE;
614
	if(session->destroyed || session->hangingup)
615
		return;
616
	session->hangingup = TRUE;
615 617
	/* Close and reset stuff */
616 618
	if(session->file)
617 619
		fclose(session->file);
......
619 621
	if(session->stream)
620 622
		ogg_stream_destroy(session->stream);
621 623
	session->stream = NULL;
624
	/* Done */
625
	session->hangingup = FALSE;
622 626
}
623 627

  
624 628
/* Thread to handle incoming messages */

Also available in: Unified diff