[Freeswitch-users] Configure aliases and auto-complete on start up. (untested PATCH included)

Anthony Minessale anthony.minessale at gmail.com
Sun Apr 6 02:49:30 MSD 2014


AGAIN, JIRA... Now for the 2nd time today there is a fix with no jira to
reference.

See https://jira.freeswitch.org/browse/FS-5832


On Sat, Apr 5, 2014 at 10:00 AM, <bruce at sqls.net> wrote:

>  Well, Brian, you may be right.
>
> I was trying to figure out how it worked and figured it probably stored
> the values in the FS database.  So I opened that up and saw the tables and
> noticed both the complete and aliases database has a "sticky" integer
> field.  So I tried the stickyadd sub-command for complete in fs_cli and it
> worked and created a record in the complete table with the sticky field set
> to 1.  Great.  Then I shut down FS and all the values (even those with
> sticky = 0) were still in the table.  Then I started FS and everything was
> wiped out.  I compared this to the aliases table where only the sticky=0
> records got wiped out.
>
> So, I'm a bit hazy on C but I tried to hunt down how it works.. It looks
> like in mod_commands.c the complete and alias commands get registered as
> console command and that points back to the function
> switch_console_set_complete/alias in switch_console.c.  In that function
> the code for "stickyadd" is already there for complete.
>
> So, the final culprit seems to be switch_core_sqldb.c where it
> clears/rebuilds the db when FS is started.  There's a line in there for the
> alias table to delete all non-sticky records but the complete table seems
> to be totally different.  There's a section around line 3484 that makes an
> array of complete, interfaces, and NULL then walks that array and deletes
> everything in the tables.  I think the NULL just causes the for loop to
> exit out.  So, all that code is just for two tables it seems.
>
> So, I don't know if there's a reason for that block of code at all.   I
> would think the safest is to just remove complete from the array and
> replicate a similar line below like the alias table has.  But I'm more
> curious if just taking that whole block out and then creating a line for
> complete and interfaces below would be even better and more consistent with
> everything else. Or at the least, remove all the array/loop business since
> it's a lot of code to loop over 1 item (once complete is removed) :)
>
> So, on the safe side, from a fresh git clone here's me learning C Brian.
> Of course I don't really know if any of this is right and I just starting
> using freeswitch last week and I haven't actually ran freeswitch with this
> code... So, well.. try at your own risk I guess, but it looks pretty
> straight forward to me.
>
>
> diff -u orig-switch_core_sqldb.c switch_core_sqldb.c
>
> --- orig-switch_core_sqldb.c    2014-04-05 08:38:09.547441223 -0500
> +++ switch_core_sqldb.c 2014-04-05 09:45:58.916440649 -0500
> @@ -3483,7 +3483,7 @@
>
>         if (switch_test_flag((&runtime), SCF_CLEAR_SQL)) {
>                 char sql[512] = "";
> -               char *tables[] = { "complete", "interfaces", NULL };
> +               char *tables[] = { "interfaces", NULL };
>                 int i;
>                 const char *hostname = switch_core_get_hostname();
>
> @@ -3494,6 +3494,7 @@
>         }
>
>         switch_cache_db_execute_sql(sql_manager.dbh, "delete from aliases
> where sticky=0", NULL);
> +       switch_cache_db_execute_sql(sql_manager.dbh, "delete from complete
> where sticky=0", NULL);
>         switch_cache_db_execute_sql(sql_manager.dbh, "delete from nat
> where sticky=0", NULL);
>         switch_cache_db_execute_sql(sql_manager.dbh, "create index alias1
> on aliases (alias)", NULL);
>         switch_cache_db_execute_sql(sql_manager.dbh, "create index tasks1
> on tasks (hostname,task_id)", NULL);
>
>
>
> Though, again.. I would question the need for that whole block at the top.
>
>
>
>
>
> ------ Original Message ------
> From: "Brian West" <brian at freeswitch.org>
> To: "FreeSWITCH Users Help" <freeswitch-users at lists.freeswitch.org>
> Sent: 4/4/2014 9:03:08 AM
> Subject: Re: [Freeswitch-users] Configure aliases and auto-complete on
> start up.
>
>
> This is a perfect project for someone to learn a little C on, We all have
> to start somewhere. :P
> --
> Brian West
> brian at freeswitch.org
> FreeSWITCH Solutions, LLC
> PO BOX 2531
> Brookfield, WI 53008-2531
> Twitter: @FreeSWITCH , @briankwest
> http://www.freeswitchbook.com
> http://www.freeswitchcookbook.com
>
> T: +1.918.420.9001 | F: +1.918.420.9002 | M: +1.918.424.WEST
> iNUM: +883 5100 1420 9001
> ISN: 410*543
> Skype:briankwest
> PGP Key: http://www.bkw.org/key.txt (AB93356707C76CED)
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Apr 3, 2014, at 2:18 PM, bruce at sqls.net wrote:
>
>
>
>  Thank you very much Steven! I hadn't seen any message you sent
> previously! That's perfect and will work great.
>
>  Thanks everybody for all the hand holding :)
>
>  ------ Original Message ------
>  From: "Steven Ayre" <steveayre at gmail.com>
>  To: bruce at sqls.net
>  Cc: "FreeSWITCH Users Help" <freeswitch-users at lists.freeswitch.org>
>  Sent: 4/3/2014 1:52:37 PM
>  Subject: Re: Re[2]: [Freeswitch-users] Configure aliases and
> auto-complete on start up.
>
>
>  I sent a mail with that - in case you didn't see it:
>
>  https://wiki.freeswitch.org/wiki/Mod_lua#Lua_scripts_at_startup
>
> https://wiki.freeswitch.org/wiki/Mod_lua#Make_API_calls_directly_from_Lua_code
>
>  Check the first link.
>
>
>
>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>


-- 
Anthony Minessale II       ♬ @anthmfs  ♬ @FreeSWITCH  ♬

☞ http://freeswitch.org/http://cluecon.com/http://twitter.com/FreeSWITCH
☞ irc.freenode.net #freeswitch ☞ *http://freeswitch.org/g+
<http://freeswitch.org/g+>*

ClueCon Weekly Development Call
☎ sip:888 at conference.freeswitch.org  ☎ +19193869900
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140405/9e1621ce/attachment.html 


Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-users mailing list