[Home]

Summary:ASTERISK-11968: Fails to load if sock not specified in config
Reporter:Niklas Larsson (pnlarsson)Labels:
Date Opened:2008-05-04 03:50:49Date Closed:2008-05-04 22:44:04
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Addons/cdr_mysql
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) cdr_addon_mysql.c.patch
Description:If the socket is not specified in the config file, cdr_addons_mysql will fail to load. This is where mysql is running on the same machine.

The patch attached solves this issue, without the patch the dbsock->str contains (null) and then fails the ast_strlen_zero test.

****** ADDITIONAL INFORMATION ******

Pre-patch:

[May  4 09:52:07] DEBUG[30570] config.c: Parsing /etc/asterisk/cdr_mysql.conf
[May  4 09:52:07] DEBUG[30570] cdr_addon_mysql.c: Got hostname of localhost
[May  4 09:52:07] DEBUG[30570] cdr_addon_mysql.c: Got port of 0
[May  4 09:52:07] DEBUG[30570] cdr_addon_mysql.c: Got a timeout of 0
[May  4 09:52:07] DEBUG[30570] cdr_addon_mysql.c: Got sock file of (null)
[May  4 09:52:07] DEBUG[30570] cdr_addon_mysql.c: Got user of asteriskuser
[May  4 09:52:07] DEBUG[30570] cdr_addon_mysql.c: Got dbname of asteriskcdrdb
[May  4 09:52:07] DEBUG[30570] cdr_addon_mysql.c: Got password of amp109
[May  4 09:52:07] DEBUG[30570] cdr_addon_mysql.c: Not running in calldate compatibility mode

Post-patch:

[May  4 10:47:17] DEBUG[778] config.c: Parsing /etc/asterisk/cdr_mysql.conf
[May  4 10:47:17] DEBUG[778] cdr_addon_mysql.c: Got hostname of localhost
[May  4 10:47:17] DEBUG[778] cdr_addon_mysql.c: Got port of 0
[May  4 10:47:17] DEBUG[778] cdr_addon_mysql.c: Got a timeout of 0
[May  4 10:47:17] DEBUG[778] cdr_addon_mysql.c: Got sock file of
[May  4 10:47:17] DEBUG[778] cdr_addon_mysql.c: Got user of asteriskuser
[May  4 10:47:17] DEBUG[778] cdr_addon_mysql.c: Got dbname of asteriskcdrdb
[May  4 10:47:17] DEBUG[778] cdr_addon_mysql.c: Got password of amp109
[May  4 10:47:17] DEBUG[778] cdr_addon_mysql.c: Running in calldate compatibility mode
[May  4 10:47:17] DEBUG[778] cdr_addon_mysql.c: Successfully connected to MySQL database.
Comments:By: Michiel van Baak (mvanbaak) 2008-05-04 16:46:47

+1 from me.
Looks correct, and indeed fixes the issue.
Tested on Debian etch and Ubuntu 8.04 with latest trunk version of asterisk and addons.

By: Tilghman Lesher (tilghman) 2008-05-04 21:55:51

No, this is incorrect.  Check the MySQL API, which states quite clearly that dbsock should be NULL if the default value should be used.

By: Tilghman Lesher (tilghman) 2008-05-04 21:58:59

Furthermore, it is not clear what test of ast_strlen_zero you're talking about.  That is a common API, and there are 4 different occurrences of that API call in that source file alone.

By: Digium Subversion (svnbot) 2008-05-04 22:31:27

Repository: asterisk-addons
Revision: 586

U   trunk/cdr/cdr_addon_mysql.c

------------------------------------------------------------------------
r586 | tilghman | 2008-05-04 22:31:26 -0500 (Sun, 04 May 2008) | 9 lines

If you pass NULL as the default to my_load_config_string(), you get a string of
"(null)", which is NOT zero-length, and so things succeed where they should
fail.
(Closes issue ASTERISK-11968)
Reported by: pnlarsson
Patches:
      cdr_addon_mysql.c.patch uploaded by pnlarsson (license 79)
Tested by: mvanbaak

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk-addons?view=rev&revision=586

By: Tilghman Lesher (tilghman) 2008-05-04 22:32:13

On further review, you are correct, but you missed several other places which would cause errant results.  Fixed in tree.

By: Digium Subversion (svnbot) 2008-05-04 22:44:04

Repository: asterisk-addons
Revision: 587

_U  branches/1.6.0/
U   branches/1.6.0/cdr/cdr_addon_mysql.c

------------------------------------------------------------------------
r587 | tilghman | 2008-05-04 22:44:04 -0500 (Sun, 04 May 2008) | 17 lines

Merged revisions 586 via svnmerge from
https://origsvn.digium.com/svn/asterisk-addons/trunk

........
r586 | tilghman | 2008-05-04 22:37:10 -0500 (Sun, 04 May 2008) | 9 lines

If you pass NULL as the default to my_load_config_string(), you get a string of
"(null)", which is NOT zero-length, and so things succeed where they should
fail.
(Closes issue ASTERISK-11968)
Reported by: pnlarsson
Patches:
      cdr_addon_mysql.c.patch uploaded by pnlarsson (license 79)
Tested by: mvanbaak

........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk-addons?view=rev&revision=587