Asterisk - The Open Source Telephony Project GIT-master-8f1982c
|
#include "asterisk.h"
#include "asterisk/res_odbc.h"
#include "asterisk/res_odbc_transaction.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/module.h"
Go to the source code of this file.
Data Structures | |
struct | odbc_txn_frame |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | acf_transaction_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
static int | acf_transaction_write (struct ast_channel *chan, const char *cmd, char *s, const char *value) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
struct odbc_obj * | ast_odbc_retrieve_transaction_obj (struct ast_channel *chan, const char *objname) |
Retrieve an ODBC transaction connection with the given ODBC class name. More... | |
static int | commit_exec (struct ast_channel *chan, const char *data) |
static struct odbc_txn_frame * | create_transaction (struct ast_channel *chan, const char *name, const char *dsn) |
static struct odbc_txn_frame * | find_transaction (struct ast_channel *chan, const char *name, int active) |
static int | load_module (void) |
static int | mark_transaction_active (struct ast_channel *chan, struct odbc_txn_frame *tx) |
static void | odbc_txn_free (void *vdata) |
static struct odbc_txn_frame * | release_transaction (struct odbc_txn_frame *tx) |
static int | rollback_exec (struct ast_channel *chan, const char *data) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "ODBC transaction resource" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_REALTIME_DEPEND, } |
static const char *const | app_commit = "ODBC_Commit" |
static const char *const | app_rollback = "ODBC_Rollback" |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_custom_function | odbc_function |
static const struct ast_datastore_info | txn_info |
|
static |
Definition at line 539 of file res_odbc_transaction.c.
|
static |
Definition at line 539 of file res_odbc_transaction.c.
|
static |
Definition at line 325 of file res_odbc_transaction.c.
References args, AST_APP_ARG, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_odbc_isolation2text(), AST_STANDARD_APP_ARGS, ast_strlen_zero(), buf, find_transaction(), odbc_txn_frame::forcecommit, odbc_txn_frame::isolation, len(), odbc_txn_frame::name, and NULL.
|
static |
Definition at line 399 of file res_odbc_transaction.c.
References args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_false(), ast_log, ast_odbc_print_errors(), ast_odbc_text2isolation(), AST_STANDARD_APP_ARGS, ast_strlen_zero(), ast_true(), odbc_obj::con, create_transaction(), find_transaction(), odbc_txn_frame::forcecommit, odbc_txn_frame::isolation, LOG_ERROR, mark_transaction_active(), NULL, odbc_txn_frame::obj, pbx_builtin_setvar_helper(), S_OR, and value.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 539 of file res_odbc_transaction.c.
struct odbc_obj * ast_odbc_retrieve_transaction_obj | ( | struct ast_channel * | chan, |
const char * | objname | ||
) |
Retrieve an ODBC transaction connection with the given ODBC class name.
XXX This function is majorly flawed because it ignores properties of transactions and simply finds one that corresponds to the given DSN. The problem here is that transactions have names and they maintain which transaction is "active" for operations like transaction creation, commit, and rollback. However, when it comes to intermediary operations to be made on the transactions, all that is ignored. It means that if a channel has created multiple transactions for the same DSN, it's a crapshoot which of those transactions the operation will be performed on. This can potentially lead to baffling errors under the right circumstances.
XXX The semantics of this function make for writing some awkward code. If you use func_odbc as an example, it has to first try to retrieve a transactional connection, then failing that, create a non-transactional connection. The result is that it has to remember which type of connection it's using and know whether to release the connection when completed or not. It would be much better if callers did not have to jump through such hoops.
chan | Channel on which the ODBC transaction was created |
objname | The name of the ODBC class configured in res_odbc.conf |
NULL | Transaction connection could not be found. |
non-NULL | A transactional connection |
Definition at line 475 of file res_odbc_transaction.c.
References ast_channel_datastore_find(), ast_channel_lock, ast_channel_unlock, AST_LIST_HEAD, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_odbc_class_get_name(), ast_datastore::data, odbc_txn_frame::list, NULL, odbc_txn_frame::obj, odbc_obj::parent, and txn_info.
Referenced by acf_odbc_write().
|
static |
Definition at line 281 of file res_odbc_transaction.c.
References ast_odbc_print_errors(), ast_str_buffer(), ast_strlen_zero(), odbc_obj::con, find_transaction(), NULL, odbc_txn_frame::obj, and pbx_builtin_setvar_helper().
Referenced by load_module().
|
static |
Definition at line 142 of file res_odbc_transaction.c.
References odbc_txn_frame::active, ast_calloc, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_channel_lock, ast_channel_unlock, ast_datastore_alloc, ast_datastore_free(), ast_free, AST_LIST_HEAD, AST_LIST_HEAD_INIT, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log, ast_odbc_class_get_forcecommit(), ast_odbc_class_get_isolation(), ast_odbc_print_errors(), ast_odbc_release_obj(), ast_odbc_request_obj, ast_strlen_zero(), odbc_obj::con, ast_datastore::data, odbc_txn_frame::forcecommit, odbc_txn_frame::isolation, odbc_txn_frame::list, LOG_ERROR, odbc_txn_frame::name, name, NULL, odbc_txn_frame::obj, odbc_obj::parent, and txn_info.
Referenced by acf_transaction_write().
|
static |
Definition at line 217 of file res_odbc_transaction.c.
References odbc_txn_frame::active, ast_channel_datastore_find(), ast_channel_lock, ast_channel_unlock, AST_LIST_HEAD, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_datastore::data, odbc_txn_frame::list, odbc_txn_frame::name, name, NULL, and txn_info.
Referenced by acf_transaction_read(), acf_transaction_write(), commit_exec(), and rollback_exec().
|
static |
Definition at line 526 of file res_odbc_transaction.c.
References app_commit, app_rollback, ast_custom_function_register, ast_register_application_xml, commit_exec(), odbc_function, and rollback_exec().
|
static |
Definition at line 368 of file res_odbc_transaction.c.
References odbc_txn_frame::active, ast_channel_datastore_find(), ast_channel_lock, ast_channel_unlock, AST_LIST_HEAD, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_datastore::data, odbc_txn_frame::list, NULL, and txn_info.
Referenced by acf_transaction_write().
|
static |
Definition at line 121 of file res_odbc_transaction.c.
References ast_debug, ast_free, AST_LIST_HEAD, AST_LIST_HEAD_DESTROY, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, odbc_txn_frame::list, and release_transaction().
|
static |
Definition at line 253 of file res_odbc_transaction.c.
References ast_debug, ast_free, ast_odbc_print_errors(), ast_odbc_release_obj(), odbc_obj::con, odbc_txn_frame::forcecommit, NULL, and odbc_txn_frame::obj.
Referenced by odbc_txn_free().
|
static |
Definition at line 303 of file res_odbc_transaction.c.
References ast_odbc_print_errors(), ast_str_buffer(), ast_strlen_zero(), odbc_obj::con, find_transaction(), NULL, odbc_txn_frame::obj, and pbx_builtin_setvar_helper().
Referenced by load_module().
|
static |
Definition at line 521 of file res_odbc_transaction.c.
|
static |
Definition at line 539 of file res_odbc_transaction.c.
|
static |
Definition at line 513 of file res_odbc_transaction.c.
Referenced by load_module().
|
static |
Definition at line 514 of file res_odbc_transaction.c.
Referenced by load_module().
|
static |
Definition at line 539 of file res_odbc_transaction.c.
|
static |
Definition at line 507 of file res_odbc_transaction.c.
Referenced by load_module().
|
static |
Definition at line 137 of file res_odbc_transaction.c.
Referenced by ast_odbc_retrieve_transaction_obj(), create_transaction(), find_transaction(), and mark_transaction_active().