Summary:ASTERISK-07899: [patch] Extension for Realtime API
Reporter:Sergey Tamkovich (sergee)Labels:
Date Opened:2006-10-09 04:02:03Date Closed:2007-04-11 08:49:03
Versions:Frequency of
Environment:Attachments:( 0) 8118.diffc
( 1) 8118.diffi
( 2) mysql-config-store-destroy-r311.diff
( 3) mysql-config-store-destroy-r349.diff
( 4) rt-store-destroy-r44332.diff
( 5) rt-store-destroy-r59850.fix.diff
Description:This patch extends RT API with 2 new methods (store_func and destroy_func). With this 2 methods, RT API become a complete DB Abstraction Layer, you don't need to use DB realted stuff from your apps any more (eg: ODBC Storage in voicemail), just use Realtime!


// Disclaimer was sent by fax at 5th october 2006.
Comments:By: Sergey Tamkovich (sergee) 2006-10-09 04:04:29

2nd patch (mysql-config-store-destroy-r311) - implements new API calls (store_func,destroy_func) in res_config_mysql.c (asterisk-addons)

By: Olle Johansson (oej) 2006-10-29 14:34:00.000-0600

Remember that realtime is *not* a DB abstraction layer. It's a storage abstraction layer that includes LDAP... Just a note.

By: Sergey Tamkovich (sergee) 2006-10-29 15:12:31.000-0600

oej, LDAP is not my strong side but IMHO, store_func and destroy_func aren't contrary to storage abstraction layer ideology, am i wrong?

By: Sergey Tamkovich (sergee) 2006-11-17 00:49:04.000-0600

murf, any ideas, any suggestions? :)

By: Steve Murphy (murf) 2006-11-17 10:56:45.000-0600

sergee - I see an unhealthy thing in the res_config_mysql.c file:

res_config_mysql.c:545: warning: ?cur_cat? may be used uninitialized in this function

And, roughly at line 604, I see this:

                       if(strcmp(last, row[0]) || last_cat_metric != atoi(row[3])) {
                               cur_cat = ast_category_new(row[0]);
                               if (!cur_cat) {
                                       ast_log(LOG_WARNING, "Out of memory!\n");
                               strcpy(last, row[0]);
                               last_cat_metric = atoi(row[3]);
                               ast_category_append(cfg, cur_cat);
                       new_v = ast_variable_new(row[1], row[2]);
                       ast_variable_append(cur_cat, new_v);  /* DANGER! what if cur_cat is NULL */

And if cur_cat is null, and the if statement tests false?

I smell a crash waiting to happen?

By: flot (flot) 2006-11-20 10:55:40.000-0600

I have:
Asterisk SVN-trunk-r47186M
gcc version 3.4.5
patch 2.5.9

# patch <../mysql-config-store-destroy-r311.diff
patching file res_config_mysql.c
patch: **** malformed patch at line 160: +      return -1;

By: Steve Murphy (murf) 2006-11-20 12:53:48.000-0600


I saw this, too, but the patch is very readable. I applied it by hand.

By: flot (flot) 2006-11-21 02:31:32.000-0600

I applied it by hand too. After that, have ceased to work all realtime sip accounts. I have been compelled to return all back.

By: Sergey Tamkovich (sergee) 2006-12-03 02:40:07.000-0600

Murf, i missed that place with cur_cat, probably we should add there small check for cur_cat == NULL.

OR we should move
                        new_v = ast_variable_new(row[1], row[2]);
^^^^^^ Before that " if(strcmp(last, row[0]) || last_cat_metric != atoi(row[3])) {"

                       ast_variable_append(cur_cat, new_v); /* DANGER! what if cur_cat is NULL */

^^^^ inside that "if()"

By: Steve Murphy (murf) 2007-01-03 13:36:59.000-0600


Just to be sure I get your intentions correctly, please, upload another patch with the change you advise in it. Also, we need to address the comments of flot -- it would be utter disaster if we broke everyone's existing realtime setups!!!

By: jmls (jmls) 2007-03-09 04:46:15.000-0600

any news on the new patch ?

By: Sergey Tamkovich (sergee) 2007-03-16 06:12:08

New patch uploaded.

Patch is not malformed anymore :) (sory to all for that). Issue pointed out by murf is fixed.

Testers are welcome!

By: Steve Murphy (murf) 2007-03-23 14:57:23


I've uploaded two patch files, one for the config.h stuff
and one for the res_config_mysql.c file; I modified the
file to follow the asterisk coding standards better; although
I don't know if such is required in the asterisk_addons.

Please, test this out, and report if all is OK, and I will commit.

By: Sergey Tamkovich (sergee) 2007-03-24 15:51:53

Murf, just tested your patches, everything works fine! Thank you very much for code cleanup, i totaly forgot about CODING-GUIDELINES.

By: Steve Murphy (murf) 2007-03-27 09:46:06

OK, in asterisk-addons, the changes to res_config_mysql.c are in r. 353 of the trunk branch there.

The 2 lines of addition to config.c are committed into the trunk via r. 59253.

By: Leif Madsen (lmadsen) 2007-04-03 07:03:19

Reopened per sergee in IRC

By: Sergey Tamkovich (sergee) 2007-04-03 07:54:02

Part of patch ( rt-store-destroy-r44332.diff ) was lost during code cleanup.
Uploading patch rt-store-destroy-r59850.fix.diff that contains lost part, this aligned with current svn trunk.

By: Sergey Tamkovich (sergee) 2007-04-04 08:06:35

if you have error like "undefined symbol ast_store_realtime()" - then you need to apply last patch from bug # 8118:


By: Steve Murphy (murf) 2007-04-11 08:48:59

The missing code patch was applied to trunk via 61374. Many thanks for the update!