예제 #1
0
struct stasis_caching_topic *stasis_caching_unsubscribe(struct stasis_caching_topic *caching_topic)
{
	if (!caching_topic) {
		return NULL;
	}

	/*
	 * The subscription may hold the last reference to this caching
	 * topic, but we want to make sure the unsubscribe finishes
	 * before kicking of the caching topic's dtor.
	 */
	ao2_ref(caching_topic, +1);

	if (stasis_subscription_is_subscribed(caching_topic->sub)) {
		/*
		 * Increment the reference to hold on to it past the
		 * unsubscribe. Will be cleaned up in dtor.
		 */
		ao2_ref(caching_topic->sub, +1);
		stasis_unsubscribe(caching_topic->sub);
	} else {
		ast_log(LOG_ERROR, "stasis_caching_topic unsubscribed multiple times\n");
	}
	ao2_cleanup(caching_topic);
	return NULL;
}
예제 #2
0
static void send_mwi_notify(struct mwi_subscription *sub)
{
	struct ast_sip_message_accumulator counter = {
		.old_msgs = 0,
		.new_msgs = 0,
	};
	struct ast_sip_body_data data = {
		.body_type = AST_SIP_MESSAGE_ACCUMULATOR,
		.body_data = &counter,
	};

	ao2_callback(sub->stasis_subs, OBJ_NODATA, get_message_count, &counter);

	if (sub->is_solicited) {
		ast_sip_subscription_notify(sub->sip_sub, &data, 0);
		return;
	}

	send_unsolicited_mwi_notify(sub, &counter);
}

static int unsubscribe_stasis(void *obj, void *arg, int flags)
{
	struct mwi_stasis_subscription *mwi_stasis = obj;
	if (mwi_stasis->stasis_sub) {
		ast_debug(3, "Removing stasis subscription to mailbox %s\n", mwi_stasis->mailbox);
		mwi_stasis->stasis_sub = stasis_unsubscribe(mwi_stasis->stasis_sub);
	}
	return CMP_MATCH;
}

static void mwi_subscription_shutdown(struct ast_sip_subscription *sub)
{
	struct mwi_subscription *mwi_sub;
	RAII_VAR(struct ast_datastore *, mwi_datastore,
			ast_sip_subscription_get_datastore(sub, MWI_DATASTORE), ao2_cleanup);

	if (!mwi_datastore) {
		return;
	}

	mwi_sub = mwi_datastore->data;
	ao2_callback(mwi_sub->stasis_subs, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, unsubscribe_stasis, NULL);
}

static struct ast_datastore_info mwi_ds_info = { };

static int add_mwi_datastore(struct mwi_subscription *sub)
{
	RAII_VAR(struct ast_datastore *, mwi_datastore, NULL, ao2_cleanup);

	mwi_datastore = ast_sip_subscription_alloc_datastore(&mwi_ds_info, MWI_DATASTORE);
	if (!mwi_datastore) {
		return -1;
	}
	mwi_datastore->data = sub;

	ast_sip_subscription_add_datastore(sub->sip_sub, mwi_datastore);
	return 0;
}
void stasis_message_router_unsubscribe(struct stasis_message_router *router)
{
	if (!router) {
		return;
	}

	stasis_unsubscribe(router->subscription);
}
예제 #4
0
static int unload_module(void)
{
	if (stasis_rtp_subscription) {
		stasis_rtp_subscription = stasis_unsubscribe(stasis_rtp_subscription);
	}

	return 0;
}
예제 #5
0
static void parked_subscription_datastore_destroy(void *data)
{
	struct parked_subscription_datastore *subscription_datastore = data;

	stasis_unsubscribe(subscription_datastore->parked_subscription);
	subscription_datastore->parked_subscription = NULL;

	ast_free(subscription_datastore);
}
void stasis_message_router_unsubscribe(struct stasis_message_router *router)
{
	if (!router) {
		return;
	}

	ao2_lock(router);
	router->subscription = stasis_unsubscribe(router->subscription);
	ao2_unlock(router);
}
예제 #7
0
static int unload_module(void)
{
	if (security_stasis_sub) {
		security_stasis_sub = stasis_unsubscribe(security_stasis_sub);
	}

	ast_logger_unregister_level(LOG_SECURITY_NAME);

	ast_verb(3, "Security Logging Disabled\n");

	return 0;
}
예제 #8
0
파일: stasis.c 프로젝트: GGGO/asterisk
struct stasis_subscription *stasis_unsubscribe_and_join(
	struct stasis_subscription *subscription)
{
	if (!subscription) {
		return NULL;
	}

	/* Bump refcount to hold it past the unsubscribe */
	ao2_ref(subscription, +1);
	stasis_unsubscribe(subscription);
	stasis_subscription_join(subscription);
	/* Now decrement the refcount back */
	ao2_cleanup(subscription);
	return NULL;
}
예제 #9
0
/*! \brief Event callback which fires initial unsolicited MWI NOTIFY messages when we're fully booted */
static void mwi_startup_event_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
{
	struct ast_json_payload *payload;
	const char *type;

	if (stasis_message_type(message) != ast_manager_get_generic_type()) {
		return;
	}

	payload = stasis_message_data(message);
	type = ast_json_string_get(ast_json_object_get(payload->json, "type"));

	if (strcmp(type, "FullyBooted")) {
		return;
	}

	ast_sip_push_task(NULL, send_initial_notify_all, NULL);

	stasis_unsubscribe(sub);
}
예제 #10
0
static void parking_manager_disable_stasis(void)
{
	parking_sub = stasis_unsubscribe(parking_sub);
}