コード例 #1
0
static int qualify_and_schedule_cb(void *obj, void *arg, int flags)
{
	struct ast_sip_contact *contact = obj;
	struct ast_sip_aor *aor = arg;
	int initial_interval;
	int max_time = ast_sip_get_max_initial_qualify_time();

	contact->qualify_frequency = aor->qualify_frequency;
	contact->qualify_timeout = aor->qualify_timeout;
	contact->authenticate_qualify = aor->authenticate_qualify;

	/* Delay initial qualification by a random fraction of the specified interval */
	if (max_time && max_time < contact->qualify_frequency) {
		initial_interval = max_time;
	} else {
		initial_interval = contact->qualify_frequency;
	}

	initial_interval = (int)((initial_interval * 1000) * ast_random_double());

	unschedule_qualify(contact);
	if (contact->qualify_frequency) {
		schedule_qualify(contact, initial_interval);
	} else {
		update_contact_status(contact, UNKNOWN);
	}

	return 0;
}
コード例 #2
0
/*!
 * \internal
 * \brief Qualify the given contact and set up scheduling if configured.
 */
static void qualify_and_schedule(struct ast_sip_contact *contact)
{
	unschedule_qualify(contact);

	if (contact->qualify_frequency) {
		ao2_ref(contact, +1);
		if (ast_sip_push_task(NULL, qualify_contact_task, contact)) {
			ao2_ref(contact, -1);
		}

		schedule_qualify(contact, contact->qualify_frequency * 1000);
	} else {
		update_contact_status(contact, UNKNOWN);
	}
}
コード例 #3
0
/*!
 * \internal
 * \brief A contact has been deleted remove status tracking.
 */
static void contact_deleted(const void *obj)
{
	struct ast_sip_contact *contact = (struct ast_sip_contact *) obj;
	struct ast_sip_contact_status *status;

	unschedule_qualify(contact);

	status = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), CONTACT_STATUS,
		ast_sorcery_object_get_id(contact));
	if (!status) {
		return;
	}

	if (ast_sorcery_delete(ast_sip_get_sorcery(), status)) {
		ast_log(LOG_ERROR, "Unable to delete ast_sip_contact_status for contact %s\n",
			contact->uri);
	}
	ao2_ref(status, -1);
}
コード例 #4
0
ファイル: pjsip_options.c プロジェクト: litnimax/asterisk
static void qualify_and_schedule_contact(struct ast_sip_contact *contact)
{
	int initial_interval;
	int max_time = ast_sip_get_max_initial_qualify_time();

	/* Delay initial qualification by a random fraction of the specified interval */
	if (max_time && max_time < contact->qualify_frequency) {
		initial_interval = max_time;
	} else {
		initial_interval = contact->qualify_frequency;
	}

	initial_interval = (int)((initial_interval * 1000) * ast_random_double());

	unschedule_qualify(contact);
	if (contact->qualify_frequency) {
		schedule_qualify(contact, initial_interval);
	} else {
		update_contact_status(contact, UNKNOWN, 0);
	}
}
コード例 #5
0
static int unschedule_contact_cb(void *obj, void *arg, int flags)
{
	unschedule_qualify(obj);

	return CMP_MATCH;
}