diff options
author | Mark Michelson <mmichelson@digium.com> | 2010-04-19 18:42:31 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2010-04-19 18:42:31 +0000 |
commit | 6640f309a9fe161c7779fcbdd4c9b0bc20ba0cdb (patch) | |
tree | 6d756d2e9266ec85b7b6c3157081799dc6d64c83 /funcs/func_srv.c | |
parent | 9674766487e729f2cd46fa7ed4ac68b45e5ad60d (diff) |
Commit compromise I suggested on review 608.
This allows for multiple SRV queries to be done
from the dialplan for the same service on a single call while
still allowing one to bypass the call to SRVQUERY if they so
please.
Taking action since no comments had been left for a while.
This can easily be reverted if needed. External tests
still pass.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@257851 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs/func_srv.c')
-rw-r--r-- | funcs/func_srv.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/funcs/func_srv.c b/funcs/func_srv.c index dc936c07a..de48f0d06 100644 --- a/funcs/func_srv.c +++ b/funcs/func_srv.c @@ -125,6 +125,8 @@ static struct srv_context *srv_datastore_setup(const char *service, struct ast_c static int srv_query_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { + struct ast_datastore *datastore; + if (!chan) { ast_log(LOG_WARNING, "%s cannot be used without a channel\n", cmd); return -1; @@ -134,7 +136,19 @@ static int srv_query_read(struct ast_channel *chan, const char *cmd, char *data, ast_log(LOG_WARNING, "%s requires a service as an argument\n", cmd); return -1; } + + /* If they already called SRVQUERY for this service once, + * we need to kill the old datastore. + */ + ast_channel_lock(chan); + datastore = ast_channel_datastore_find(chan, &srv_result_datastore_info, data); + ast_channel_unlock(chan); + if (datastore) { + ast_channel_datastore_remove(chan, datastore); + ast_datastore_free(datastore); + } + if (!srv_datastore_setup(data, chan)) { return -1; } |