Index: trunk/docs/Changelog
===================================================================
--- trunk/docs/Changelog	(revision 426)
+++ trunk/docs/Changelog	(revision 427)
@@ -1,3 +1,4 @@
 3.0.11:
+	* Fix reconnecting do database for Oracle
 	* Add better logrotate handling for the GrowingLogs policy (search
 	  rotated log and verify it, don't report if this succeeds)
Index: trunk/src/sh_database.c
===================================================================
--- trunk/src/sh_database.c	(revision 426)
+++ trunk/src/sh_database.c	(revision 427)
@@ -539,4 +539,6 @@
   char         row_query[128];
   int          retry     = 0;
+  static SH_TIMEOUT sh_timer = { 0, 3600, S_TRUE };
+
 
   SL_ENTER(_("sh_database_query"));
@@ -636,27 +638,39 @@
 	       (OraText*) db_password, sl_strlen(db_password), 
 	       (OraText*) db_name,     sl_strlen(db_name))) 
-      {   
-	OCIErrorGet(o_error, 1, NULL, &o_errorcode, 
-		    o_errormsg, sizeof(o_errormsg), OCI_HTYPE_ERROR);
-	sh_stripnl (o_errormsg);
-	sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
-			o_errormsg, 
-			_("sh_database_query"));
-	sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
-			_("check database is listed in tnsnames.ora"), 
-			_("sh_database_query"));
-	sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
-			_("check tnsnames.ora readable"), 
-			_("sh_database_query"));
-	sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
-			_("check database accessible with sqlplus"), 
-			_("sh_database_query"));
-	sl_snprintf(row_query, 127, 
-		    _("OCILogon: Connection to database '%s' failed"), 
-		    db_name); 
-	sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN, 
-			row_query, _("sh_database_query")); 
-	bad_init = 1;
-	SL_RETURN(-1, _("sh_database_query")); 
+      {
+   
+	connected = 0;
+
+	sh_timer.flag_ok = S_FALSE;
+
+	if (S_TRUE == sh_util_timeout_check(&sh_timer))
+	  {
+	    OCIErrorGet(o_error, 1, NULL, &o_errorcode, 
+			o_errormsg, sizeof(o_errormsg), OCI_HTYPE_ERROR);
+	    sh_stripnl (o_errormsg);
+	    sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
+			    o_errormsg, 
+			    _("sh_database_query"));
+	    sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
+			    _("check database is listed in tnsnames.ora"), 
+			    _("sh_database_query"));
+	    sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
+			    _("check tnsnames.ora readable"), 
+			    _("sh_database_query"));
+	    sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
+			    _("check database accessible with sqlplus"), 
+			    _("sh_database_query"));
+	    sl_snprintf(row_query, 127, 
+			_("OCILogon: Connection to database '%s' failed"), 
+			db_name); 
+	    sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN, 
+			    row_query, _("sh_database_query")); 
+
+	    goto err_out;
+	  }
+	else
+	  {
+	    SL_RETURN(0, _("sh_database_query"));
+	  }
       }
  
@@ -848,13 +862,6 @@
    * Error
    */
-  if (sh_persistent_dbconn == S_FALSE)
-    {
-      OCILogoff(o_servicecontext, o_error);
-      OCIHandleFree((dvoid *) o_statement,      OCI_HTYPE_STMT);
-      OCIHandleFree((dvoid *) o_servicecontext, OCI_HTYPE_SVCCTX);
-      OCIHandleFree((dvoid *) o_error,          OCI_HTYPE_ERROR);
-      o_error = NULL;
-      connected = 0;
-    }
+  sh_database_reset();
+
   SL_RETURN(-1, _("sh_database_query"));
 }
