[asterisk-commits] mmichelson: branch 12 r410592 - in /branches/12: main/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 14 13:10:53 CDT 2014


Author: mmichelson
Date: Fri Mar 14 13:10:47 2014
New Revision: 410592

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=410592
Log:
Handle the return values of realtime updates and stores more accurately.

Realtime backends' update and store callbacks return the number of rows affected,
or -1 if there was a failure. There were a couple of issues:

* The config API was treating 0 as a successful return, and positive values as
  a failure. Now the config API treats anything >= 0 as a success.

* res_sorcery_realtime was treating 0 as a successful return from the store
  procedure, and any positive values as a failure. Now sorcery treats anything
  > 0 as a success. It still considers 0 a "failure" since there is no change
  to report to observers.

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


Modified:
    branches/12/main/config.c
    branches/12/res/res_sorcery_realtime.c

Modified: branches/12/main/config.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/config.c?view=diff&rev=410592&r1=410591&r2=410592
==============================================================================
--- branches/12/main/config.c (original)
+++ branches/12/main/config.c Fri Mar 14 13:10:47 2014
@@ -2936,8 +2936,8 @@
 
 	for (i = 1; ; i++) {
 		if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) {
-			/* If the update succeeds, it returns 0. */
-			if (eng->update_func && !(res = eng->update_func(db, table, keyfield, lookup, fields))) {
+			/* If the update succeeds, it returns >= 0. */
+			if (eng->update_func && ((res = eng->update_func(db, table, keyfield, lookup, fields)) >= 0)) {
 				break;
 			}
 		} else {
@@ -3017,8 +3017,8 @@
 
 	for (i = 1; ; i++) {
 		if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) {
-			/* If the store succeeds, it returns 0. */
-			if (eng->store_func && !(res = eng->store_func(db, table, fields))) {
+			/* If the store succeeds, it returns >= 0*/
+			if (eng->store_func && ((res = eng->store_func(db, table, fields)) >= 0)) {
 				break;
 			}
 		} else {

Modified: branches/12/res/res_sorcery_realtime.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_sorcery_realtime.c?view=diff&rev=410592&r1=410591&r2=410592
==============================================================================
--- branches/12/res/res_sorcery_realtime.c (original)
+++ branches/12/res/res_sorcery_realtime.c Fri Mar 14 13:10:47 2014
@@ -79,7 +79,7 @@
 	id->next = fields;
 	fields = id;
 
-	return ast_store_realtime_fields(family, fields) ? -1 : 0;
+	return (ast_store_realtime_fields(family, fields) <= 0) ? -1 : 0;
 }
 
 /*! \brief Internal helper function which returns a filtered objectset. 




More information about the asterisk-commits mailing list