コード例 #1
0
static struct chanspy_ds *chanspy_ds_free(struct chanspy_ds *chanspy_ds)
{
	if (!chanspy_ds)
		return NULL;

	ast_mutex_lock(&chanspy_ds->lock);
	if (chanspy_ds->chan) {
		struct ast_datastore *datastore;
		struct ast_channel *chan;

		chan = chanspy_ds->chan;

		ast_channel_lock(chan);
		if ((datastore = ast_channel_datastore_find(chan, &chanspy_ds_info, chanspy_ds->unique_id))) {
			ast_channel_datastore_remove(chan, datastore);
			/* chanspy_ds->chan is NULL after this call */
			chanspy_ds_destroy(datastore->data);
			datastore->data = NULL;
			ast_channel_datastore_free(datastore);
		}
		ast_channel_unlock(chan);
	}
	ast_mutex_unlock(&chanspy_ds->lock);

	return NULL;
}
コード例 #2
0
ファイル: app_chanspy.c プロジェクト: pjalbrecht/asterisk
static struct chanspy_ds *chanspy_ds_free(struct chanspy_ds *chanspy_ds)
{
	struct ast_channel *chan;

	if (!chanspy_ds) {
		return NULL;
	}

	ast_mutex_lock(&chanspy_ds->lock);
	while ((chan = chanspy_ds->chan)) {
		struct ast_datastore *datastore;

		if (ast_channel_trylock(chan)) {
			DEADLOCK_AVOIDANCE(&chanspy_ds->lock);
			continue;
		}
		if ((datastore = ast_channel_datastore_find(chan, &chanspy_ds_info, chanspy_ds->unique_id))) {
			ast_channel_datastore_remove(chan, datastore);
			/* chanspy_ds->chan is NULL after this call */
			chanspy_ds_destroy(datastore->data);
			datastore->data = NULL;
			ast_channel_datastore_free(datastore);
		}
		ast_channel_unlock(chan);
		break;
	}
	ast_mutex_unlock(&chanspy_ds->lock);

	return NULL;
}