Beispiel #1
0
static void global_loaded(const char *object_type)
{
	char default_realm[MAX_REALM_LENGTH + 1];
	struct ast_sip_auth *fake_auth;
	char *identifier_order;

	/* Update using_auth_username */
	identifier_order = ast_sip_get_endpoint_identifier_order();
	if (identifier_order) {
		char *identify_method;
		char *io_copy = ast_strdupa(identifier_order);
		int new_using = 0;

		ast_free(identifier_order);
		while ((identify_method = ast_strip(strsep(&io_copy, ",")))) {
			if (!strcmp(identify_method, "auth_username")) {
				new_using = 1;
				break;
			}
		}
		using_auth_username = new_using;
	}

	/* Update default_realm of artificial_auth */
	ast_sip_get_default_realm(default_realm, sizeof(default_realm));
	fake_auth = ast_sip_get_artificial_auth();
	if (!fake_auth || strcmp(fake_auth->realm, default_realm)) {
		ao2_cleanup(fake_auth);

		fake_auth = alloc_artificial_auth(default_realm);
		if (fake_auth) {
			ao2_global_obj_replace_unref(artificial_auth, fake_auth);
		}
	}
	ao2_cleanup(fake_auth);

	ast_sip_get_unidentified_request_thresholds(&unidentified_count, &unidentified_period, &unidentified_prune_interval);

	/* Clean out the old task, if any */
	ast_sched_clean_by_callback(prune_context, prune_task, clean_task);
	/* Have to do something with the return value to shut up the stupid compiler. */
	if (ast_sched_add_variable(prune_context, unidentified_prune_interval * 1000, prune_task, NULL, 1) < 0) {
		return;
	}
}
/*!
 * \internal
 * \brief Set up a scheduled qualify contact check.
 */
static void schedule_qualify(struct ast_sip_contact *contact, int initial_interval)
{
	struct sched_data *data;

	data = sched_data_create(contact);
	if (!data) {
		return;
	}

	ast_assert(contact->qualify_frequency != 0);

	ao2_t_ref(data, +1, "Ref for qualify_contact_sched() scheduler entry");
	data->id = ast_sched_add_variable(sched, initial_interval,
		qualify_contact_sched, data, 1);
	if (data->id < 0) {
		ao2_t_ref(data, -1, "Cleanup failed scheduler add");
		ast_log(LOG_ERROR, "Unable to schedule qualify for contact %s\n",
			contact->uri);
	} else if (!ao2_link(sched_qualifies, data)) {
		AST_SCHED_DEL_UNREF(sched, data->id,
			ao2_t_ref(data, -1, "Cleanup scheduler for failed ao2_link"));
	}
	ao2_t_ref(data, -1, "Done setting up scheduler entry");
}
int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, void *data)
{
	return ast_sched_add_variable(con, when, callback, data, 0);
}