diff options
author | David M. Lee <dlee@digium.com> | 2012-10-04 15:48:24 +0000 |
---|---|---|
committer | David M. Lee <dlee@digium.com> | 2012-10-04 15:48:24 +0000 |
commit | c5acf22cec226026b7316a328d0fdd06fa9eb5b8 (patch) | |
tree | 43cd224c6eb424e83341579fbae405bd50d7778b /res | |
parent | d78f7f92b2afa033ff959e84bf164454ca9a5de8 (diff) |
Fix DBDelTree error codes for AMI, CLI and AGI
The AMI DBDelTree command will return Success/Key tree deleted successfully even
if the given key does not exist. The CLI command 'database deltree' had a
similar problem, but was saved because it actually responded with '0 database
entries removed'. AGI had a slightly different error, where it would return
success if the database was unavailable.
This came from confusion about the ast_db_deltree retval, which is -1 in the
event of a database error, or number of entries deleted (including 0 for
deleting nothing).
* Changed some poorly named res variables to num_deleted
* Specified specific errors when calling ast_db_deltree (database unavailable
vs. entry not found vs. success)
* Fixed similar bug in AGI database deltree, where 'Database unavailable'
results in successful result
(closes issue AST-967)
Reported by: John Bigelow
Review: https://reviewboard.asterisk.org/r/2138/
........
Merged revisions 374426 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 374427 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 374428 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374429 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r-- | res/res_agi.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/res/res_agi.c b/res/res_agi.c index a7ed8b53e..b92ccdbdc 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -2785,16 +2785,18 @@ static int handle_dbdel(struct ast_channel *chan, AGI *agi, int argc, const char static int handle_dbdeltree(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[]) { - int res; + int num_deleted; - if ((argc < 3) || (argc > 4)) + if ((argc < 3) || (argc > 4)) { return RESULT_SHOWUSAGE; - if (argc == 4) - res = ast_db_deltree(argv[2], argv[3]); - else - res = ast_db_deltree(argv[2], NULL); + } + if (argc == 4) { + num_deleted = ast_db_deltree(argv[2], argv[3]); + } else { + num_deleted = ast_db_deltree(argv[2], NULL); + } - ast_agi_send(agi->fd, chan, "200 result=%c\n", res ? '0' : '1'); + ast_agi_send(agi->fd, chan, "200 result=%c\n", num_deleted > 0 ? '0' : '1'); return RESULT_SUCCESS; } |