[Home]

Summary:ASTERISK-05741: error in cdr_addon_mysql
Reporter:Jon Leren Schøpzinsky (jonleren)Labels:
Date Opened:2005-11-30 07:19:21.000-0600Date Closed:2005-12-01 18:35:18.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:cdr_addon_mysql has an error with connection handling. It does not close the connection in the event of an error. There error is with this code:

if (connected) {
  if (mysql_real_query(&mysql, sqlcmd, strlen(sqlcmd))) {
ast_log(LOG_ERROR, "mysql_cdr: Failed to insert into database: (%d) %s", mysql_errno(&mysql), mysql_error(&mysql));
connected = 0;
  } else {
records++;
totalrecords++;
  }
}

This snippet sets the connected value to 0 but does not close the connection.
The connected value is set in various parts of the mysql_log function, and therefore a fix would to add this snippet:

if(connected==0) {
 mysql_close(&mysql);
}

at line 234 before:
ast_mutex_unlock(&mysql_lock);

On another note, it shouldnt be necessary to disconnect from the database in event of every little mysql error. I would suggest some better connection handling for cdr_addon_mysql

Jon
Comments:By: Russell Bryant (russell) 2005-11-30 08:30:30.000-0600

Please attatch your proposed changes in 'svn diff' format.  Also, we will need a disclaimer from you to consider merging your changes.

Thanks!

By: Kevin P. Fleming (kpfleming) 2005-12-01 18:34:58.000-0600

Committed to branch 1.2, will auto-merge to trunk. Thanks!