mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 06:48:25 +00:00
make datastore creation and destruction a generic API since it is not really channel related, and add the ability to add/find/remove datastores to manager sessions
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@135680 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -189,7 +189,7 @@ static int enum_query_read(struct ast_channel *chan, const char *cmd, char *data
|
||||
|
||||
snprintf(buf, len, "%u", erds->id);
|
||||
|
||||
if (!(datastore = ast_channel_datastore_alloc(&enum_result_datastore_info, buf))) {
|
||||
if (!(datastore = ast_datastore_alloc(&enum_result_datastore_info, buf))) {
|
||||
ast_free(erds->context);
|
||||
ast_free(erds);
|
||||
goto finish;
|
||||
|
||||
@@ -158,7 +158,7 @@ static int shared_write(struct ast_channel *chan, const char *cmd, char *data, c
|
||||
ast_channel_lock(chan);
|
||||
|
||||
if (!(varstore = ast_channel_datastore_find(chan, &shared_variable_info, NULL))) {
|
||||
if (!(varstore = ast_channel_datastore_alloc(&shared_variable_info, NULL))) {
|
||||
if (!(varstore = ast_datastore_alloc(&shared_variable_info, NULL))) {
|
||||
ast_log(LOG_ERROR, "Unable to allocate new datastore. Shared variable not set.\n");
|
||||
ast_channel_unlock(chan);
|
||||
return -1;
|
||||
@@ -166,7 +166,7 @@ static int shared_write(struct ast_channel *chan, const char *cmd, char *data, c
|
||||
|
||||
if (!(varshead = ast_calloc(1, sizeof(*varshead)))) {
|
||||
ast_log(LOG_ERROR, "Unable to allocate variable structure. Shared variable not set.\n");
|
||||
ast_channel_datastore_free(varstore);
|
||||
ast_datastore_free(varstore);
|
||||
ast_channel_unlock(chan);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ static int get_lock(struct ast_channel *chan, char *lockname, int try)
|
||||
|
||||
if (!lock_store) {
|
||||
ast_debug(1, "Channel %s has no lock datastore, so we're allocating one.\n", chan->name);
|
||||
lock_store = ast_channel_datastore_alloc(&lock_info, NULL);
|
||||
lock_store = ast_datastore_alloc(&lock_info, NULL);
|
||||
if (!lock_store) {
|
||||
ast_log(LOG_ERROR, "Unable to allocate new datastore. No locks will be obtained.\n");
|
||||
return -1;
|
||||
@@ -105,7 +105,7 @@ static int get_lock(struct ast_channel *chan, char *lockname, int try)
|
||||
list = ast_calloc(1, sizeof(*list));
|
||||
if (!list) {
|
||||
ast_log(LOG_ERROR, "Unable to allocate datastore list head. %sLOCK will fail.\n", try ? "TRY" : "");
|
||||
ast_channel_datastore_free(lock_store);
|
||||
ast_datastore_free(lock_store);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -480,7 +480,7 @@ end_acf_read:
|
||||
struct ast_datastore *odbc_store;
|
||||
uid = ast_atomic_fetchadd_int(&resultcount, +1) + 1;
|
||||
snprintf(buf, len, "%d", uid);
|
||||
odbc_store = ast_channel_datastore_alloc(&odbc_info, buf);
|
||||
odbc_store = ast_datastore_alloc(&odbc_info, buf);
|
||||
if (!odbc_store) {
|
||||
ast_log(LOG_ERROR, "Rows retrieved, but unable to store it in the channel. Results fail.\n");
|
||||
odbc_datastore_free(resultset);
|
||||
@@ -550,7 +550,7 @@ static int acf_fetch(struct ast_channel *chan, const char *cmd, char *data, char
|
||||
if (!row) {
|
||||
/* Cleanup datastore */
|
||||
ast_channel_datastore_remove(chan, store);
|
||||
ast_channel_datastore_free(store);
|
||||
ast_datastore_free(store);
|
||||
return -1;
|
||||
}
|
||||
pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", resultset->names);
|
||||
@@ -584,7 +584,7 @@ static int exec_odbcfinish(struct ast_channel *chan, void *data)
|
||||
if (!store) /* Already freed; no big deal. */
|
||||
return 0;
|
||||
ast_channel_datastore_remove(chan, store);
|
||||
ast_channel_datastore_free(store);
|
||||
ast_datastore_free(store);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -151,12 +151,12 @@ static int speex_write(struct ast_channel *chan, const char *cmd, char *data, co
|
||||
if (!(datastore = ast_channel_datastore_find(chan, &speex_datastore, NULL))) {
|
||||
ast_channel_unlock(chan);
|
||||
|
||||
if (!(datastore = ast_channel_datastore_alloc(&speex_datastore, NULL))) {
|
||||
if (!(datastore = ast_datastore_alloc(&speex_datastore, NULL))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(si = ast_calloc(1, sizeof(*si)))) {
|
||||
ast_channel_datastore_free(datastore);
|
||||
ast_datastore_free(datastore);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ static int speex_write(struct ast_channel *chan, const char *cmd, char *data, co
|
||||
ast_log(LOG_ERROR, "Invalid argument provided to the %s function\n", cmd);
|
||||
|
||||
if (is_new) {
|
||||
ast_channel_datastore_free(datastore);
|
||||
ast_datastore_free(datastore);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -237,7 +237,7 @@ static int speex_write(struct ast_channel *chan, const char *cmd, char *data, co
|
||||
ast_audiohook_detach(&si->audiohook);
|
||||
}
|
||||
|
||||
ast_channel_datastore_free(datastore);
|
||||
ast_datastore_free(datastore);
|
||||
}
|
||||
|
||||
if (is_new) {
|
||||
|
||||
@@ -106,10 +106,10 @@ static int volume_write(struct ast_channel *chan, const char *cmd, char *data, c
|
||||
|
||||
if (!(datastore = ast_channel_datastore_find(chan, &volume_datastore, NULL))) {
|
||||
/* Allocate a new datastore to hold the reference to this volume and audiohook information */
|
||||
if (!(datastore = ast_channel_datastore_alloc(&volume_datastore, NULL)))
|
||||
if (!(datastore = ast_datastore_alloc(&volume_datastore, NULL)))
|
||||
return 0;
|
||||
if (!(vi = ast_calloc(1, sizeof(*vi)))) {
|
||||
ast_channel_datastore_free(datastore);
|
||||
ast_datastore_free(datastore);
|
||||
return 0;
|
||||
}
|
||||
ast_audiohook_init(&vi->audiohook, AST_AUDIOHOOK_TYPE_MANIPULATE, "Volume");
|
||||
|
||||
Reference in New Issue
Block a user