117 ast_debug(2,
"odbc_txn_free(%p) called\n", vdata);
129 .
type =
"ODBC_Transaction",
146 oldlist = txn_store->
data;
149 ast_log(
LOG_ERROR,
"Unable to allocate a new datastore. Cannot create a new transaction.\n");
154 if (!(oldlist =
ast_calloc(1,
sizeof(*oldlist)))) {
155 ast_log(
LOG_ERROR,
"Unable to allocate datastore list head. Cannot create a new transaction.\n");
161 txn_store->
data = oldlist;
167 txn =
ast_calloc(1,
sizeof(*txn) + strlen(name) + 1);
172 strcpy(txn->
name, name);
182 if (SQLSetConnectAttr(txn->
obj->
con, SQL_ATTR_AUTOCOMMIT, (
void *)SQL_AUTOCOMMIT_OFF, 0) == SQL_ERROR) {
190 if (SQLSetConnectAttr(txn->
obj->
con, SQL_ATTR_TXN_ISOLATION, (
void *)(
long)txn->
isolation, 0) == SQL_ERROR) {
214 if (!chan || (!active && !name)) {
227 oldlist = txn_store->
data;
235 }
else if (!strcasecmp(txn->
name, name)) {
250 ast_debug(2,
"release_transaction(%p) called (tx->obj = %p\n", tx, tx->
obj);
252 ast_debug(1,
"called on a transactional handle with %s\n", tx->
forcecommit ?
"COMMIT" :
"ROLLBACK");
253 if (SQLEndTran(SQL_HANDLE_DBC, tx->
obj->
con, tx->
forcecommit ? SQL_COMMIT : SQL_ROLLBACK) == SQL_ERROR) {
263 if (SQLSetConnectAttr(tx->
obj->
con, SQL_ATTR_AUTOCOMMIT, (
void *)SQL_AUTOCOMMIT_ON, 0) == SQL_ERROR) {
286 if (SQLEndTran(SQL_HANDLE_DBC, tx->
obj->
con, SQL_COMMIT) == SQL_ERROR) {
308 if (SQLEndTran(SQL_HANDLE_DBC, tx->
obj->
con, SQL_ROLLBACK) == SQL_ERROR) {
325 if (strcasecmp(
args.property,
"transaction") == 0) {
330 }
else if (strcasecmp(
args.property,
"isolation") == 0) {
340 }
else if (strcasecmp(
args.property,
"forcecommit") == 0) {
375 oldlist = txn_store->
data;
387 return active ? 0 : -1;
399 if (strcasecmp(
args.property,
"transaction") == 0) {
409 }
else if (strcasecmp(
args.property,
"forcecommit") == 0) {
432 }
else if (strcasecmp(
args.property,
"isolation") == 0) {
449 if (isolation == 0) {
452 }
else if (SQLSetConnectAttr(tx->
obj->
con, SQL_ATTR_TXN_ISOLATION, (
void *)(
long)isolation, 0) == SQL_ERROR) {
472 if (!chan || !objname) {
479 oldlist = txn_store->
data;
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
#define AST_LIST_LOCK(head)
Locks a list.
Asterisk main include file. File version handling, generic pbx functions.
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
unsigned int active
Is this record the current active transaction within the channel? Note that the active flag is really...
static int mark_transaction_active(struct ast_channel *chan, struct odbc_txn_frame *tx)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static struct odbc_txn_frame * find_transaction(struct ast_channel *chan, const char *name, int active)
static const char *const app_commit
Structure for a data store type.
static struct odbc_txn_frame * release_transaction(struct odbc_txn_frame *tx)
Structure for a data store object.
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
#define ast_strlen_zero(foo)
#define AST_LIST_HEAD_DESTROY(head)
Destroys a list head structure.
static int load_module(void)
static int commit_exec(struct ast_channel *chan, const char *data)
#define ast_debug(level,...)
Log a DEBUG message.
unsigned int ast_odbc_class_get_isolation(struct odbc_class *class)
Get the transaction isolation setting for an ODBC class.
static void odbc_txn_free(void *vdata)
General Asterisk PBX channel definitions.
static int acf_transaction_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
Data structure associated with a custom dialplan function.
static int rollback_exec(struct ast_channel *chan, const char *data)
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
const char * ast_odbc_isolation2text(int iso)
Convert from numeric transaction isolation values to their textual counterparts.
struct odbc_class * parent
Core PBX routines and definitions.
static int unload_module(void)
struct ast_str * ast_odbc_print_errors(SQLSMALLINT handle_type, SQLHANDLE handle, const char *operation)
Shortcut for printing errors to logs after a failed SQL operation.
static int acf_transaction_write(struct ast_channel *chan, const char *cmd, char *s, const char *value)
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.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
static const struct ast_datastore_info txn_info
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
int ast_odbc_text2isolation(const char *txt)
Convert from textual transaction isolation values to their numeric constants.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static struct odbc_txn_frame * create_transaction(struct ast_channel *chan, const char *name, const char *dsn)
unsigned int ast_odbc_class_get_forcecommit(struct odbc_class *class)
Get the transaction forcecommit setting for an ODBC class.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define ast_channel_unlock(chan)
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_odbc_request_obj(a, b)
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
static struct ast_custom_function odbc_function
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
#define ast_datastore_alloc(info, uid)
struct odbc_txn_frame::@470 list
void ast_odbc_release_obj(struct odbc_obj *obj)
Releases an ODBC object previously allocated by ast_odbc_request_obj()
static const char *const app_rollback
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_custom_function_register(acf)
Register a custom function.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
const char * ast_odbc_class_get_name(struct odbc_class *class)
Get the name of an ODBC class.
#define AST_APP_ARG(name)
Define an application argument.