]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Return NULL when no results returned for realtime_multientry
authorTerry Wilson <twilson@digium.com>
Tue, 25 Oct 2011 01:25:52 +0000 (01:25 +0000)
committerTerry Wilson <twilson@digium.com>
Tue, 25 Oct 2011 01:25:52 +0000 (01:25 +0000)
It was not documented what the return value should be when no entries
were returned with the multientry realtime callback. This change forces
consistent behavior even if the backends return an empty ast_config.

Review: https://reviewboard.asterisk.org/r/1521/
........

Merged revisions 342223 from http://svn.asterisk.org/svn/asterisk/branches/1.8

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@342224 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/config.h
main/config.c

index 56401bf46db781eef2c6e765e9319f077903e32c..932404d14c2d67e95f4b242448e33fd6f9edbfcb 100644 (file)
@@ -358,6 +358,9 @@ int ast_realtime_require_field(const char *family, ...) attribute_sentinel;
  * is thus stored inside a traditional ast_config structure rather than
  * just returning a linked list of variables.
  *
+ * \return An ast_config with one or more results
+ * \retval NULL Error or no results returned
+ *
  * \note You should use the constant SENTINEL to terminate arguments, in
  * order to preserve cross-platform compatibility.
  */
index e432de33db78c2acb081b3d78d1d5d49a08fab94..6381a53f578ef10d1e1af83765cb3f4a975ee2f4 100644 (file)
@@ -2446,6 +2446,11 @@ struct ast_config *ast_load_realtime_multientry(const char *family, ...)
        for (i = 1; ; i++) {
                if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) {
                        if (eng->realtime_multi_func && (res = eng->realtime_multi_func(db, table, ap))) {
+                               /* If we were returned an empty cfg, destroy it and return NULL */
+                               if (!res->root) {
+                                       ast_config_destroy(res);
+                                       res = NULL;
+                               }
                                break;
                        }
                } else {