[asterisk-bugs] [Asterisk 0010109]: [Realtime] Wrong Matching within extensions table
noreply at bugs.digium.com
noreply at bugs.digium.com
Wed Sep 26 12:49:41 CDT 2007
The following issue has been CLOSED
======================================================================
http://bugs.digium.com/view.php?id=10109
======================================================================
Reported By: Medozas
Assigned To:
======================================================================
Project: Asterisk
Issue ID: 10109
Category: Addons/res_config_mysql
Reproducibility: always
Severity: major
Priority: normal
Status: closed
Asterisk Version: 1.2.19
SVN Branch (only for SVN checkouts, not tarball releases): N/A
SVN Revision (number only!):
Disclaimer on File?: No
Request Review:
Resolution: won't fix
Fixed in Version:
======================================================================
Date Submitted: 07-03-2007 09:40 CDT
Last Modified: 09-26-2007 12:49 CDT
======================================================================
Summary: [Realtime] Wrong Matching within extensions table
Description:
First of all I'm sorry I can't supply any patches for this (as rather
newbie to patch-management), but I will describe it so hopefully everybody
understands what i mean.
We have a setup asterisk here with realtime backend for both flat
(cat_metric, var_metric, etc.) and dynamic (sippeers, iaxpeers, etc.)
running successfully and stable.
But: with in extconfig.conf setup "extensions =>
mysql,<DATABASE>,<EXTENSIONS-TABLE>" everything works ok actually, but the
matching is incorrect.
Example:
Extension defined in extensions table:
-> "_0."
-> "_0174."
The following happens:
at line 255 of res_config_mysql.c (asterisk-addons package) and
at line 250 of res/res_config_odbc.c (asterisk core)
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " ORDER BY %s",
initfield);
all extensions are being sorted ASCENDING. This behaviour is wrong, as to
limit Queries sent to database ARA hits the first match, and executes
app/appdata with first found match.
So even now calling 0174123 will first be matched with the _0. rule, even
if _0174. is more precise.
Please see query examples at "Additional Information"
The easiest fix for this problem is to sort DESCENDING, as the order of
matching now is the same as with flat file configuration (->best match).
So changing above stated line to
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " ORDER BY %s
DESC", initfield);
returns expected results. Now when 0174. is being called, it matches 0174.
first, and only when different from 0174. pattern it goes to next _0. and
fires that one successfully.
This problem is only with pattern matching, as before making the pattern
lookup realtime always tries to find the exact match of dialed number:
[output already with patched version (DESC)]
Jul 3 15:03:59 DEBUG[19101] res_config_mysql.c: MySQL RealTime: Retrieve
SQL: SELECT * FROM config_extensions WHERE exten = '0174XXXXXXX' AND
context = 'TERMINATION' AND priority = '1'
Jul 3 15:03:59 DEBUG[19101] res_config_mysql.c: MySQL RealTime:
Everything is fine.
Jul 3 15:03:59 DEBUG[19101] res_config_mysql.c: MySQL RealTime: Retrieve
SQL: SELECT * FROM config_extensions WHERE exten LIKE '\\_%' AND context =
'TERMINATION' AND priority = '1' ORDER BY exten DESC
Jul 3 15:03:59 DEBUG[19101] res_config_mysql.c: MySQL RealTime:
Everything is fine.
As ARA always tries to lookup priority directly by number, it doesn't
matter how the priority gets sorted anyways, and so this isn't a problem
(AND priority = '1' / AND priority = '2', etc.)'
Changing this line has no sideeffects as we have seen, as the flat config
has own ordering (cat_metric/var_metric, etc.) and all other tables like
sippeers or iaxpeers make no difference even if they would sort DESC.
As said above we have this change running now on our LIVE installation and
there is no difference in 100% functionality except now using correct
matchind for dial patterns.
Sorry if there might be something unclear, as this is my first bug-report
with asterisk ;)
======================================================================
----------------------------------------------------------------------
Corydon76 - 09-26-07 12:49
----------------------------------------------------------------------
Sorry, it's nice that you got the behavior you were looking for, but it's
not the behavior that Asterisk intentionally has and was documented to
have. So I'm closing this bug as a "Won't fix".
Issue History
Date Modified Username Field Change
======================================================================
09-26-07 12:49 Corydon76 Note Added: 0071119
09-26-07 12:49 Corydon76 Status new => closed
09-26-07 12:49 Corydon76 Resolution open => won't fix
======================================================================
More information about the asterisk-bugs
mailing list