diff options
author | Joshua Colp <jcolp@digium.com> | 2007-07-16 18:24:29 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2007-07-16 18:24:29 +0000 |
commit | e498488bde119a98ecfc27880a2a9c9e9adfb223 (patch) | |
tree | 421e0b496d4bd2074e436c513a30b752557e35c7 /main/pbx.c | |
parent | ce8f95d750a4afce1867fac11d04cc66cc8e0880 (diff) |
For my next trick I will make it so dialplan functions no longer need to call ast_module_user_add and ast_module_user_remove. These are now called in the ast_func_read and ast_func_write functions outside of the module.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@75255 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/pbx.c')
-rw-r--r-- | main/pbx.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/main/pbx.c b/main/pbx.c index d47e0e8cc..ee88a0615 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -1410,13 +1410,15 @@ int ast_custom_function_unregister(struct ast_custom_function *acf) return acf ? 0 : -1; } -int ast_custom_function_register(struct ast_custom_function *acf) +int ast_custom_function_register2(struct ast_custom_function *acf, struct ast_module *mod) { struct ast_custom_function *cur; if (!acf) return -1; + acf->mod = mod; + AST_RWLIST_WRLOCK(&acf_root); AST_RWLIST_TRAVERSE(&acf_root, cur, acflist) { @@ -1476,8 +1478,16 @@ int ast_func_read(struct ast_channel *chan, const char *function, char *workspac ast_log(LOG_ERROR, "Function %s not registered\n", copy); else if (!acfptr->read) ast_log(LOG_ERROR, "Function %s cannot be read\n", copy); - else - return acfptr->read(chan, copy, args, workspace, len); + else { + int res; + struct ast_module_user *u = NULL; + if (acfptr->mod) + u = __ast_module_user_add(acfptr->mod, chan); + res = acfptr->read(chan, copy, args, workspace, len); + if (acfptr->mod && u) + __ast_module_user_remove(acfptr->mod, u); + return res; + } return -1; } @@ -1491,8 +1501,16 @@ int ast_func_write(struct ast_channel *chan, const char *function, const char *v ast_log(LOG_ERROR, "Function %s not registered\n", copy); else if (!acfptr->write) ast_log(LOG_ERROR, "Function %s cannot be written to\n", copy); - else - return acfptr->write(chan, copy, args, value); + else { + int res; + struct ast_module_user *u = NULL; + if (acfptr->mod) + u = __ast_module_user_add(acfptr->mod, chan); + res = acfptr->write(chan, copy, args, value); + if (acfptr->mod && u) + __ast_module_user_remove(acfptr->mod, u); + return res; + } return -1; } |