[asterisk-commits] tilghman: branch 1.6.1 r145754 - in /branches/1.6.1: ./ res/res_odbc.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 2 10:19:58 CDT 2008


Author: tilghman
Date: Thu Oct  2 10:19:58 2008
New Revision: 145754

URL: http://svn.digium.com/view/asterisk?view=rev&rev=145754
Log:
Merged revisions 145752 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r145752 | tilghman | 2008-10-02 10:17:16 -0500 (Thu, 02 Oct 2008) | 10 lines
  
  Merged revisions 145751 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r145751 | tilghman | 2008-10-02 10:13:21 -0500 (Thu, 02 Oct 2008) | 3 lines
    
    Some sanity checks that may have led to prior crashes, found by codefreeze-lap
    (murf) on IRC.  Also some cleanup of incorrectly-used constants.
  ........
................

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/res/res_odbc.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/res/res_odbc.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/res/res_odbc.c?view=diff&rev=145754&r1=145753&r2=145754
==============================================================================
--- branches/1.6.1/res/res_odbc.c (original)
+++ branches/1.6.1/res/res_odbc.c Thu Oct  2 10:19:58 2008
@@ -758,17 +758,23 @@
 	short int mlen;
 	unsigned char msg[200], stat[10];
 
+	/* Nothing to disconnect */
+	if (!obj->con) {
+		return ODBC_SUCCESS;
+	}
+
 	ast_mutex_lock(&obj->lock);
 
 	res = SQLDisconnect(obj->con);
 
-	if (res == ODBC_SUCCESS) {
+	if (res == SQL_SUCCESS || res == SQL_SUCCESS_WITH_INFO) {
 		ast_log(LOG_DEBUG, "Disconnected %d from %s [%s]\n", res, obj->parent->name, obj->parent->dsn);
 	} else {
 		ast_log(LOG_DEBUG, "res_odbc: %s [%s] already disconnected\n", obj->parent->name, obj->parent->dsn);
 	}
 
-	if ((res = SQLFreeHandle(SQL_HANDLE_DBC, obj->con) == ODBC_SUCCESS)) {
+	if ((res = SQLFreeHandle(SQL_HANDLE_DBC, obj->con) == SQL_SUCCESS)) {
+		obj->con = NULL;
 		ast_log(LOG_DEBUG, "Database handle deallocated\n");
 	} else {
 		SQLGetDiagRec(SQL_HANDLE_DBC, obj->con, 1, stat, &err, msg, 100, &mlen);
@@ -792,6 +798,13 @@
 #endif
 	ast_mutex_lock(&obj->lock);
 
+	if (obj->up) {
+		odbc_obj_disconnect(obj);
+		ast_log(LOG_NOTICE, "Re-connecting %s\n", obj->parent->name);
+	} else {
+		ast_log(LOG_NOTICE, "Connecting %s\n", obj->parent->name);
+	}
+
 	res = SQLAllocHandle(SQL_HANDLE_DBC, obj->parent->env, &obj->con);
 
 	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
@@ -805,13 +818,6 @@
 	SQLSetConnectAttr(obj->con, SQL_ATTR_TRACE, &enable, SQL_IS_INTEGER);
 	SQLSetConnectAttr(obj->con, SQL_ATTR_TRACEFILE, tracefile, strlen(tracefile));
 #endif
-
-	if (obj->up) {
-		odbc_obj_disconnect(obj);
-		ast_log(LOG_NOTICE, "Re-connecting %s\n", obj->parent->name);
-	} else {
-		ast_log(LOG_NOTICE, "Connecting %s\n", obj->parent->name);
-	}
 
 	res = SQLConnect(obj->con,
 		   (SQLCHAR *) obj->parent->dsn, SQL_NTS,




More information about the asterisk-commits mailing list