[Home]

Summary:ASTERISK-05350: [patch?] Every second reload of cdr_odbc will produce an error.
Reporter:Jason Parker (jparker)Labels:
Date Opened:2005-10-22 01:25:33Date Closed:2008-01-15 15:52:00.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:CDR/cdr_odbc
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:If you reload cdr_odbc.so, it will fail to connect every other time (unless a record has been saved since the last reload, in which case it will fail).

The problem stems from not setting the connected state to 0 when disconnecting and unloading the module in odbc_unload_module.  On reload, it will assume it's still connected, and not allocate the needed handles.

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

This is so simple that I'm not even going to include a patch (it's a one liner).

On approx line 210 of cdr_odbc.c, add a connected = 0, after all three handles are freed (with SQLFreeHandle) (or right after the disconnect...it doesn't really matter I don't think).
Comments:By: Jason Parker (jparker) 2005-10-22 01:25:59

example..

       if (connected) {
               if (option_verbose > 10)
                       ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Disconnecting from %s\n", dsn);
               SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt);
               SQLDisconnect(ODBC_con);
               SQLFreeHandle(SQL_HANDLE_DBC, ODBC_con);
               SQLFreeHandle(SQL_HANDLE_ENV, ODBC_env);
               connected = 0;
       }

By: Russell Bryant (russell) 2005-10-22 11:36:50

fixed in cvs head, thanks!

By: Digium Subversion (svnbot) 2008-01-15 15:52:00.000-0600

Repository: asterisk
Revision: 6843

U   trunk/cdr/cdr_odbc.c

------------------------------------------------------------------------
r6843 | russell | 2008-01-15 15:51:59 -0600 (Tue, 15 Jan 2008) | 2 lines

fix reload problem - unload_module was not setting connected to 0 (issue ASTERISK-5350)

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

http://svn.digium.com/view/asterisk?view=rev&revision=6843