Esempio n. 1
0
/* RTSP connection disconnected */
static apt_bool_t rtsp_client_on_disconnect(rtsp_client_t *client, rtsp_client_connection_t *rtsp_connection)
{
	rtsp_client_session_t *session;
	rtsp_message_t *request;
	rtsp_message_t *response;
	apr_size_t remaining_handles = 0;
	apr_size_t cancelled_requests = 0;

	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"TCP Peer Disconnected %s", rtsp_connection->base->id);
	apt_net_client_connection_close(client->task,rtsp_connection->base);

	/* Cancel in-progreess requests */
	do {
		session = apt_list_pop_front(rtsp_connection->inprogress_request_queue);
		if(session && session->active_request) {
			request = session->active_request;
			session->active_request = NULL;
			cancelled_requests++;

			response = rtsp_response_create(
								request,
								RTSP_STATUS_CODE_INTERNAL_SERVER_ERROR,
								RTSP_REASON_PHRASE_INTERNAL_SERVER_ERROR,
								session->pool);
			rtsp_client_session_response_process(client,session,request,response);
		}
	}
	while(session);

	/* Walk through RTSP handles and raise termination event for them */
	remaining_handles = apr_hash_count(rtsp_connection->handle_table);
	if(remaining_handles) {
		void *val;
		apr_hash_index_t *it;
		apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Terminate Remaining RTSP Handles [%d]",remaining_handles);
		it = apr_hash_first(rtsp_connection->base->pool,rtsp_connection->session_table);
		for(; it; it = apr_hash_next(it)) {
			apr_hash_this(it,NULL,NULL,&val);
			session = val;
			if(session) {
				rtsp_client_session_terminate_raise(client,session);
			}
		}
		remaining_handles = apr_hash_count(rtsp_connection->session_table);
	}

	if(!remaining_handles && !cancelled_requests) {
		rtsp_client_connection_destroy(client,rtsp_connection);
	}
	return TRUE;
}
Esempio n. 2
0
/* RTSP connection disconnected */
static apt_bool_t rtsp_client_on_disconnect(rtsp_client_t *client, rtsp_client_connection_t *rtsp_connection)
{
	rtsp_client_session_t *session;
	apr_size_t remaining_handles;

	apt_log(RTSP_LOG_MARK,APT_PRIO_INFO,"RTSP Peer Disconnected %s", rtsp_connection->id);
	rtsp_client_connection_close(client,rtsp_connection);

	/* Cancel in-progreess requests */
	do {
		session = apt_list_pop_front(rtsp_connection->inprogress_request_queue);
		if(session) {
			if(rtsp_client_request_cancel(
						client,
						session,
						RTSP_STATUS_CODE_INTERNAL_SERVER_ERROR,
						RTSP_REASON_PHRASE_INTERNAL_SERVER_ERROR) == TRUE) {
				apt_timer_kill(session->request_timer);
			}
		}
	}
	while(session);

	/* Walk through RTSP handles and raise termination event for them */
	remaining_handles = apr_hash_count(rtsp_connection->handle_table);
	if(remaining_handles) {
		void *val;
		apr_hash_index_t *it;
		apt_log(RTSP_LOG_MARK,APT_PRIO_NOTICE,"Terminate Remaining RTSP Handles [%"APR_SIZE_T_FMT"]",remaining_handles);
		it = apr_hash_first(rtsp_connection->pool,rtsp_connection->session_table);
		for(; it; it = apr_hash_next(it)) {
			apr_hash_this(it,NULL,NULL,&val);
			session = val;
			if(session) {
				rtsp_client_session_terminate_raise(client,session);
			}
		}
	}

	return TRUE;
}