Index: src/modules/rlm_sql/sql.c
===================================================================
RCS file: /source/radiusd/src/modules/rlm_sql/sql.c,v
retrieving revision 1.79.2.3
diff -u -r1.79.2.3 sql.c
--- src/modules/rlm_sql/sql.c	26 Aug 2005 00:37:47 -0000	1.79.2.3
+++ src/modules/rlm_sql/sql.c	19 Mar 2007 16:52:33 -0000
@@ -496,7 +496,9 @@
 
 	if (ret == SQL_DOWN) {
 	        /* close the socket that failed */
-	        (inst->module->sql_close)(sqlsocket, inst->config);
+		if (sqlsocket->conn) {
+			(inst->module->sql_close)(sqlsocket, inst->config);
+		}
 
 		/* reconnect the socket */
 		if (connect_single_socket(sqlsocket, inst) < 0) {
@@ -539,7 +541,9 @@
 
 	if (ret == SQL_DOWN) {
 	        /* close the socket that failed */
-	        (inst->module->sql_close)(sqlsocket, inst->config);
+		if (sqlsocket->conn) {
+			(inst->module->sql_close)(sqlsocket, inst->config);
+		}
 
 		/* reconnect the socket */
 		if (connect_single_socket(sqlsocket, inst) < 0) {
